Regarding SOAP based Webservice Call
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
Thanks,
Raj
- Labels:
-
Connectivity
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
</ActivityId>
</s:Header>
<s:Body>
<MyOperation xmlns="http://tempuri.org">
<MyValue></MyValue>
</MyOperation>
</s:Body>
</s:Envelope>;
// 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);
/////////////////////////////////////
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks Andy.
Regards,
Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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/">
<soap:Body>
<HelloWorldResponse xmlns="tempuri.org/">
<HelloWorldResult>string</HelloWorldResult>
</HelloWorldResponse>
</soap:Body>
</soap:Envelope>;
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<GetTopTenPartsResponse xmlns="http://steris.com/">
<GetTopTenPartsResult>
<JsonRecord>
<item>
<key>
<string xmlns="">PARTNO</string>
</key>
<value>
<anyType xmlns="" xsi:type="xsd:string">P150829896</anyType>
</value>
</item>
</JsonRecord>
</GetTopTenPartsResult>
</GetTopTenPartsResponse>
</soap:Body>
</soap:Envelope>
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):
http://wso2.com/project/mashup/0.2/docs/e4xquickstart.html