Created
January 22, 2014 16:35
-
-
Save enreeco/8562035 to your computer and use it in GitHub Desktop.
Use SOAP module on NodeJS to consume salesforce WSDL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function test(callback){ | |
soap.createClient('./partner.wsdl', function(err, client) { | |
console.log('\t\tLogging in on Salesforce...'); | |
client.login({username: C.SF.Username,password: C.SF.Password},function(err,result,raw){ | |
console.log('\t\tDone.'); | |
if(err){ | |
console.log(error); | |
return callback(error); | |
} | |
var sheader = {SessionHeader:{sessionId: result.result.sessionId}}; | |
client.addSoapHeader(sheader,"","tns",""); | |
client.setEndpoint(result.result.serverUrl); | |
console.log('\t\tQuerying attachment...'); | |
client.query({queryString:'Select id,name,body,contentType From Attachment limit 1'},function(err,result2,raw){ | |
console.log('\t\tDone.'); | |
if(err){ | |
console.log(error); | |
return callback(error); | |
} | |
if(result2){ | |
//console.log(result2.result.records[0]); | |
return callback(null,result2); | |
} | |
}); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment