Scripted soap response will not parse, and includes mimeboundary and content tags.

devert
Tera Contributor

I am trying to use SOAP between service now and one of in house applications. I have imported the WSDL and in the test it works fine. However in the workflow it includes the Mimeboundary in the soap body. Here is the Soap function:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:gc10.good.com">

    <soapenv:Header>

<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">

<wsse:UsernameToken wsu:Id="UsernameToken-10" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">

<wsse:Username>admin - name</wsse:Username>

<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Admin - Pass</wsse:Password>

</wsse:UsernameToken>

</wsse:Security></soapenv:Header>

    <soapenv:Body>

          <urn:GetUsersRequest>

                <!--Optional:-->

                <urn:offSet>0</urn:offSet> <!--0-->

                <!--Optional:-->

                <urn:maxResults>1</urn:maxResults><!--1-->

                <!--Optional:-->

                <urn:getTotal>false</urn:getTotal><!--false-->

                <!--Optional:-->

                <urn:filter>email</urn:filter>

 

                <!--Zero or more repetitions:-->

             

                <!--You may enter ANY elements at this point-->

          </urn:GetUsersRequest>

    </soapenv:Body>

</soapenv:Envelope>

The response to the function is as follows:

--MIMEBoundaryurn_uuid_A43470F626032A364A1462980074113

Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"

Content-Transfer-Encoding: binary

Content-ID: <0.urn:uuid:A43470F626032A364A1462980074114@apache.org>

<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns2:GetUsersResponse xmlns:ns2="urn:gc10.good.com"><ns2:isPartialResult>false</ns2:isPartialResult><ns2:users><ns2:userId>3238508</ns2:userId><ns2:displayName>Thomas R</ns2:displayName><ns2:stringId>Thomas</ns2:stringId><ns2:domain>ad</ns2:domain><ns2:firstName>Thomas</ns2:firstName><ns2:lastName>Dever</ns2:lastName><ns2:status>1</ns2:status><ns2:policySetId>4088</ns2:policySetId><ns2:userPrincipalName>Thomas</ns2:userPrincipalName><ns2:nativeGuid>556b268acec42a14e4a66eaca4f52</ns2:nativeGuid><ns2:securityRealm>1</ns2:securityRealm><ns2:deviceCount>-1</ns2:deviceCount></ns2:users></ns2:GetUsersResponse></soapenv:Body></soapenv:Envelope>

--MIMEBoundaryurn_uuid_A43470F626032A364A1462980074113--

I have been unsuccessful using the OOB soap message in the workflow by assigning the variables to scratchpad. SO the run script I am trying to use is as follows:

(function() {

   

try {

var s = new sn_ws.SOAPMessageV2('GC Web Service', 'GetUsers');

        s.setSOAPAction("urn:gc10.good.com/gcServer/GetUsersRequest");

        var response = s.execute();

   

   

      var theBody= response.getBody()

   

   

      gs.log(theBody);

var xmldoc = new XMLDocument2(theBody);

   

      gs.log("THe amswer " + xmldoc.getNodeText("//ns2:userId") + ' : ' + xmldoc.getNodeText("//ns2:domain"));

var responseBody = response.getBody();

var status = response.getStatusCode();

}

catch(ex) {

var message = ex.getMessage();

      gs.log("The error " + message)

}

}());

The body responds as the test does, but I can not parse this with Xpath. The getNodeText calls respond with Null values every time.

Thanks for your help!

1 ACCEPTED SOLUTION

devert
Tera Contributor

Hi Amila,



Thank you for the response but I was able to get this squared away. Unfortunately the system I was communicating with was send back full content responses and not just the soap response. I was able to split of the mtom mime section of the response. After that, I was able to parse the message correctly.


View solution in original post

6 REPLIES 6

thanks for your reply!


when testing the necessary function. How do I set it as true? I have an Outbound SOAP Message running. All Certs, keystore are fine..


Sarah Powell
Mega Expert

Thomas,



I am trying to setup something similar to what you have here. The problem for me is the MTOM, MIME header that you mentioned. ServiceNow is still saying they don't support that. Do you mind sharing how you split the response and parsed through the data?



Thanks,
Sarah