Expand my Community achievements bar.

SOLVED

How to access WebService response?

Avatar

Level 10

I have desinged a web service which will return a list object and a map object..

I could drag the fields from the Data View pallete to the form, which shows the dynamic output.

However, is there any way to save the result in a javascript variable to access them programattically?

Nith

1 Accepted Solution

Avatar

Correct answer by
Level 4

Here's an example (with WSSE headers).

function callWS(webServiceURL, userEM, passEM, user, pass){
    var response = null;   
    var url = webServiceURL
    var wsse = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"  
    var wsu = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 
    var param = "my input data";

    var stringRequest = {
        "YOUR_SERVICE_NAMESPACE/:YOUR_SERVICE_METHOD":{
         "param" : param,
         "user" : user,
         "pass" : pass
        }
    };

    var oHeader = { "Security":
             {  soapAttributes:
         { xmlns: wsse },   "UsernameToken":                        
         {     soapValue: [ {soapName: "Username", soapAttributes: {  "xmlns:wsse": wsse }, soapValue: userEM},
                          { soapName: "Password", soapAttributes: {Type:"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText", "xmlns:wsse": wsse }, soapValue: passEM },
                           ]  }  }};
            response = SOAP.request({
                    cURL: url ,
                    oReqHeader: oHeader,
                       oRequest: stringRequest ,
                    cAction: "YOUR_SERVICE_NAMESPACE",
                    bEncoded: false,
                    cNamespace: "http://schemas.xmlsoap.org/wsdl/http/",
                    cResponseStyle: "Message"
                    });
        return  response[0].soapValue[0].soapValue

}

Hope this helps

View solution in original post

3 Replies

Avatar

Correct answer by
Level 4

Here's an example (with WSSE headers).

function callWS(webServiceURL, userEM, passEM, user, pass){
    var response = null;   
    var url = webServiceURL
    var wsse = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"  
    var wsu = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" 
    var param = "my input data";

    var stringRequest = {
        "YOUR_SERVICE_NAMESPACE/:YOUR_SERVICE_METHOD":{
         "param" : param,
         "user" : user,
         "pass" : pass
        }
    };

    var oHeader = { "Security":
             {  soapAttributes:
         { xmlns: wsse },   "UsernameToken":                        
         {     soapValue: [ {soapName: "Username", soapAttributes: {  "xmlns:wsse": wsse }, soapValue: userEM},
                          { soapName: "Password", soapAttributes: {Type:"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText", "xmlns:wsse": wsse }, soapValue: passEM },
                           ]  }  }};
            response = SOAP.request({
                    cURL: url ,
                    oReqHeader: oHeader,
                       oRequest: stringRequest ,
                    cAction: "YOUR_SERVICE_NAMESPACE",
                    bEncoded: false,
                    cNamespace: "http://schemas.xmlsoap.org/wsdl/http/",
                    cResponseStyle: "Message"
                    });
        return  response[0].soapValue[0].soapValue

}

Hope this helps

Avatar

Level 10

This is what i want..

many thanks

Nith

Avatar

Level 10

This is what i want..

many thanks

Nith