0

I am consuming my WCF service using Node.js. I am using WCF.js package. I am able to communicate with the service but not able to fetch data. I am getting the response action method in response.

I have tried WCF.js package.

Following is the code that i tried

var result;
var BasicHttpBinding = require('wcf.js').BasicHttpBinding
  , Proxy = require('wcf.js').Proxy
  , binding = new BasicHttpBinding()
  , proxy = new Proxy(binding, " http://domain:port/myservice.svc")
  , message = '<Envelope xmlns=' +
            '"http://schemas.xmlsoap.org/soap/envelope/">' +
                 '<Header />' +
                   '<Body>' +
                     '<GetConnections xmlns="http://tempuri.org/"/>' +
                    '</Body>' +
               '</Envelope>'

proxy.send(message, "http://tempuri.org/IMyInterface/GetConnections", function(result, ctx) {
  console.log(result)
});

I am getting following response

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header>
        <ActivityId CorrelationId="ba0b223b-a823-47ff-826d-467d595f0bc7"
xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">47ff68ec-2083-417f-b29d-52571c4cd153
        </ActivityId>
    </s:Header>
    <s:Body>
        <GetConnectionsResponse xmlns="http://tempuri.org/">
            <GetConnectionsResult xmlns:a="http://schemas.datacontract.org/2004/07/vRanger.API.Types.Common" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/>
        </GetConnectionsResponse>
    </s:Body>
</s:Envelope>

I want the data to be returned. Can anyone help me with this.

Aswad
  • 29
  • 2
  • 5

1 Answers1

0

I didn’t get your point, this xml response is the returned result. What is the data? If you want to parse XML document, we could use the below JavaScript DOMParser.
Parse XML using JavaScript
https://developer.mozilla.org/en-US/docs/Web/Guide/Parsing_and_serializing_XML
In addition, it seems that the result is empty in the GetConnectinResult node.

<GetConnectionsResult xmlns:a="http://schemas.datacontract.org/2004/07/vRanger.API.Types.Common" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/>

If the GetConnections method has the returned result, there might be some parameters in the method signature. Thereby we need to add the value of the parameter.

 "<GetConnections xmlns='http://tempuri.org/'>" +
   "<value>123</value>" +
 "</GetConnections>" +

At last, I do not see the library's support for complex data types, where the result returned is a custom object.
https://github.com/yaronn/wcf.js
Please try the below link.
How to consume WCF soap web service in node.js

Abraham Qian
  • 7,117
  • 1
  • 8
  • 22
  • 1
    Thanks abraham for the response. The issue was with my request message xml. Rectified the same. – Aswad Aug 01 '19 at 09:13