Created
September 28, 2015 19:25
-
-
Save gbutt/18e6ca105cdbfaa36c5f to your computer and use it in GitHub Desktop.
This file contains 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
public static String buildSoapLogin(String username, String password) { | |
def builder = new StreamingMarkupBuilder() | |
builder.encoding = 'UTF-8' | |
def soapEnv = builder.bind { | |
mkp.xmlDeclaration() | |
mkp.declareNamespace(soapenv: SOAP.SOAP11_NS) | |
mkp.declareNamespace(tns: 'urn:partner.soap.sforce.com') | |
mkp.declareNamespace(ens: 'urn:sobject.partner.soap.sforce.com') | |
'soapenv:Envelope' { | |
'soapenv:Header' { | |
if (sessionId) { | |
'tns:SessionHeader' { | |
'tns:sessionId' sessionId | |
} | |
} | |
} | |
'soapenv:Body' { | |
'tns:login' { | |
'tns:username' username | |
'tns:password' password | |
} | |
} | |
} | |
} | |
def writer = new StringWriter() | |
soapEnv.writeTo(writer) | |
return writer.toString() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment