Good day,
I am connecting to a web service programmatically and with the following code I receive the result below:
var cURL = "http://localhost/soap/myservice.wsdl";
SOAP.wireDump = false;
var service = SOAP.connect(cURL);
var result = service.getReturnsIssuedPersonal("1","2");
Result:
<?xml version="1.0" ?>
Hi Roy,
You should be getting a JavaScript object back, add a console.println(result.toSource()); after the call, you should see something like;
({RHISTORY:{RETURN:"INVALID", RETURNTYPEREQ:1, PERIODREQ:2, TAXNAMEREQ:4, SUBISSUE:5, REFNOREQ:3}})
So,
console.println(result.RHISTORY.PERIODREQ);
Will return 2.
One trick if you have a repeating group returned is that the object will contain an array if there is more than 1 otherwise it will just be a nested object, so you might need some code like;
if (response.Messages !== undefined)
{
if (response.Messages.length === undefined)
{
// only one back;
}
else
{
if (response.Messages.length > 0)
{
for (var i=0; i<response.Messages.length; i++)
{
// handle multiple response.Messages[i];
}
}
}
}
Hope that helps
Bruce
the format of the response is determined by the setting of
cResponseStyle |
The default is
SOAPMessageStyle.JS |
but it looks like yours is set to
SOAPMessageStyle.XML |
If you set it to Message, then you will get back JavaScript object literal which is a bit easier to deal with, e.g response.soapValue.
North America
Europe, Middle East and Africa
Asia Pacific