wcf.js icon indicating copy to clipboard operation
wcf.js copied to clipboard

Consuming wcf service(WSHttpbinding) in Node.js

Open praj25 opened this issue 9 years ago • 1 comments

@yaronn I am trying to consume a WCF service using NodeJS. I tried BasicHttpBinding with security mode="TransportWithMessageCredential". It is working fine. But if I try to consume the service with WsHttpBinding and security mode="TransportWithMessageCredential",

*The following error is thrown: * "The message could not be processed. This is most likely because the action 'http://tempuri.org/IService1/GetData' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding."

This is my NodeJS Code

var WSHttpBinding = require('wcf.js').WSHttpBinding , Proxy = require('wcf.js').Proxy , binding = new WSHttpBinding( { SecurityMode: "TransportWithMessageCredential" , TransportClientCredentialType:"None" , MessageClientCredentialType: "UserName" }) , proxy = new Proxy(binding, "https://localhost:44301/Service1.svc") , message = '<Envelope xmlns="http://www.w3.org/2003/05/soap-envelope">'+ '<Body>'+ '<GetData xmlns="http://tempuri.org/">'+ '<value>12345</value>'+ '</GetData>'+ '</Body>'+ '</Envelope>'

proxy.ClientCredentials.Username.Username = "xyz" proxy.ClientCredentials.Username.Password = "xyz" proxy.send(message, "http://tempuri.org/IService1/GetData", function(response, ctx) { console.log(response) });

This is my web config <bindings> <wsHttpBinding> <binding name="WsHttpBinding" maxReceivedMessageSize="104857600" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:01:00" sendTimeout="00:01:00" messageEncoding="Text" textEncoding="utf-8"> <security mode="TransportWithMessageCredential"> <transport clientCredentialType="None"/> <message clientCredentialType="UserName"/> </security> </binding> </wsHttpBinding> </bindings> <services> <service name="WcfService1.Service1" behaviorConfiguration="DefaultServiceBehaviors"> <endpoint address="" binding="wsHttpBinding" contract="WcfService1.IService1" name="WsHttpEndpoint" bindingConfiguration="WsHttpBinding"/> </service> </services>

praj25 avatar Mar 10 '16 05:03 praj25

try to compare the outgping message from node.js and a working wcf client (you can publish both here for review).

yaronn avatar Mar 12 '16 20:03 yaronn