在NodeJs中使用WCF服务(WsHttp绑定)

我正在尝试使用NodeJS使用WCF服务。 我试着security mode="TransportWithMessageCredential" BasicHttpBinding 。 它工作正常。 但是,如果我尝试使用WsHttpBindingsecurity mode="TransportWithMessageCredential"使用该服务,将引发以下错误:

“消息不能被处理,这很可能是因为动作' http://tempuri.org/IService1/GetData '不正确,或者是因为消息包含无效或过期的安全上下文标记,或者是因为绑定之间不匹配如果服务由于不活动而中止通道,安全上下文令牌将是无效的,为了防止服务中止空闲会话过早地增加服务端点绑定的接收超时。

错误

这是我的networkingconfiguration

 <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"> <!--Maximum size of the message which can be processed by the binding is 100 MB--> <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> 

这是我的NodeJS文件

 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) }); 

       

网上收集的解决方案 "在NodeJs中使用WCF服务(WsHttp绑定)"