I am having an issue exposing SOAP results from the Node.js SOAP module .
The following code successfully makes an authenticated soup request.
var soap = require('soap');
var url = 'http://example.com/soap.php?wsdl';
var args = {SecurityToken: '123abc456def789'};
soap.createClient(url, function(err, client) {
client.GetAllMarketAreas(args, function(err, result){
console.log(result);
});
});
But the console.log returns the following:
{ GetAllMarketAreasResult: { ROOT: { METHODINFO: [Object], DATA: [Object] } } }
I am assuming that the data is being sent back, I'm just not able to view it through the reference in the console.log. Does this sound correct and if so, how would I expose the date through Node's parsing?
The SOAP response looks like the following if done through SoupUI:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.eventinventory.com/webservices/">
<SOAP-ENV:Body>
<ns1:GetAllMarketAreasResponse>
<ns1:GetAllMarketAreasResult>
<ROOT>
<METHODINFO>
<channelName>Basic View</channelName>
<methodName>GetAllMarketAreas</methodName>
<parameters>SecurityToken=123abc456def789</parameters>
<processTime type="milliseconds">20.8221</processTime>
</METHODINFO>
<DATA xmlns:sql="urn:schemas-microsoft-com:xml-sql">
<row ID="0" Name="International/Unknown"/>
<row ID="1" Name="Calgary, AB"/>
<row ID="4" Name="Abilene, TX"/>
<row ID="6" Name="Aguadilla, PR"/>
<row ID="7" Name="Boston, MA"/>
...
So my end goal is to view that data through a JSON object in Node JS.
You can use the built-in util library's inspect method to introspect those objects.
var util = require('util')
...
console.log(util.inspect(result))
You can mess with depth, colors, etc via the interface to the command.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.