4 Replies Latest reply on May 27, 2014 7:17 AM by paic RSS
    rajgs Apprentice

    Regarding SOAP based Webservice Call

    Hi All,

            Could any one know how to call the SOAP based webservice call from java script. I have seen the REST based web service call in the video tutorial. But i didn't get the SOAP based video tutorial reference.



      • Regarding SOAP based Webservice Call
        andyb Explorer




            <MyOperation xmlns="http://tempuri.org">





        // SOAPEndpoint and SoapAction

        var url = "valid SOAPEndpoint URL here.";

        var headers = new Object();

        headers.SOAPAction = "valid soap action URL here";

        var params = {

        timeout : 60,

        headers : headers,

        ignoreSSLErrors : true,

        url : url,

        content : content


        // PostXML(timeout:NUMBER(60), headers:JSON, password:STRING, ignoreSSLErrors:BOOLEAN, username:STRING, url:STRING, content:XML):XML

        var returnContent = Resources['ContentLoaderFunctions'].PostXML(params);



        • Regarding SOAP based Webservice Call
          rajgs Apprentice

          Thanks Andy.



            • Regarding SOAP based Webservice Call
              rajgs Apprentice


              Hi Andy,

              I made SOAP webservice call as you have suggested. Please see below.

              var url = "Valid Local webservice Url"
              var headers = new Object();
              headers.SOAPAction = "tempuri.org/HelloWorld";
              var content  =
              <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
                  <HelloWorldResponse xmlns="tempuri.org/">
              var params = {
                      url : url,
                      headers : headers,
                      ignoreSSLErrors : true,
                      content : content,
                      timeout : 120
              var query = Resources['ContentLoaderFunctions'].PostXML(params);

              I got the result as follows
              <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body> <HelloWorldResponse xmlns="tempuri.org/">
               <HelloWorldResult>Hello World</HelloWorldResult> </HelloWorldResponse> </soap:Body> </soap:Envelope>

              Now i want to get the output as the response string only i.e "Hello World". How do i get it?
              I tried result = query.Result.HelloWorldResponse.HelloWorldResult; but i am getting only the header result.Please help.

                • Regarding SOAP based Webservice Call
                  paic Collaborator

                  Here is a really nice generic example on how to do it, without needing to declare name spaces.

                  <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/




                          <GetTopTenPartsResponse xmlns="http://steris.com/">





                                              <string xmlns="">PARTNO</string>



                                              <anyType xmlns="" xsi:type="xsd:string">P150829896</anyType>








                  Here: http://stackoverflow.com/questions/922668/e4x-grab-nodes-with-namespaces , is a simple way to parse, just use the generic * all-namespace-placeholder in your path resolution.

                  E.g. if you want top get the value the item key from the above message and you assigned the message to the var xmlDoc the snippet line must be:


                  var itemKey = xmlDoc.::Body.::GetTopTenPartsResponse.::GetTopTenPartsResult.::JsonRecord.::item.::key.*::string;

                  Unless you have the same element names of different namespaces and you need the namespaces to differentiate the nodes, this approach will work.

                  BTW: a quick overview of e4x for xml-to-javascript conversions in scriplets can be found here (including advanced XPath equivalents, how to build xml and more at the end of the page):