Closed hpatelc20g closed 10 years ago
This can be done. Note that you cannot specify your parameters
(or data
as it is called since version 1.3.0) using JSON. JSON is limited in comparison to XML, the latter has native support for attributes, so you'll have two options:
// create your xml as either a string or as XMLDOM object here...
var myXmlWithAttributes = '<GetAllMaterialDetailObjects xmlns:ns="http://www.c20g.org/vms/db/1.0">
<cursor id="0" position="0" numRows="5" maxRows="99999" sameConnection="false" />
</GetAllMaterialDetailObjects>';
$.soap({
data: myXmlWithAttributes
});
Another way is to use $.soap's SOAPObject. The methods of this object are not yet documented, but when you look at the $.soap code you can find the methods available. When you are familiar with jQuery, you will quickly get the hang of it. When you specify your data
as a function you will get back a reference to the SOAPObject as the first parameter of your function:
$.soap({
data: function(SOAPObject) {
return new SOAPObject('GetAllMaterialDetailObjects')
.addNamespace('ns', 'http://www.c20g.org/vms/db/1.0')
.newChild('cursor')
.attr('id', 0)
.attr('numRows', 5)
.attr('maxRows', 99999)
.attr('sameConnection', 'false')
.end(); // this line does the same as the .end() in jQuery, it returns the parent of the current node. If you would omit it the function would return the cursor node, and not the GetAllMaterialDetailObjects node.
}
});
While the XML string approach is probably the easiest to understand and implement, the choice is yours! =]
This information helps a lot. I think i will look into using $.soap's SOAPObject. Thanks!
I really like this library, but was wondering if it is possible to set attributes for parameters. For example, the result I want looks like this:
<soap:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">