如何将身份validation标头传递给node-soap

我正在尝试使用wsdl服务作为客户端,但我找不到如何设置一些标题。

我需要这个的原因是因为我试图使用的wsdl需要通过标题的用户名和密码。 这是wsdl

> POST /Service.asmx HTTP/1.1 > Host: 210.12.155.16 > Content-Type: text/xml; charset=utf-8 > Content-Length: length > SOAPAction: "http://yyyy.com:1002/apability" > > <?xml version="1.0" encoding="utf-8"?> > <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns:xsd="http://www.w3.org/2001/XMLSchema" > xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> > <soap:Header> > <AuthHeader xmlns="http://yyyy.com:1002/"> > <UserName>string</UserName> > <Password>string</Password> > </AuthHeader> > </soap:Header> > <soap:Body> > <sale xmlns="http://yyyy.com:1002/"> > <BID>string</BID> > <Amount>string</Amount> > </sale> > </soap:Body> > </soap:Envelope> 

这是代码:

  var args={BID:"123",Amount : "10000"}; var AuthHeader = { "UserName" : user, "Password" : pass }; soap.createClient(url,function(error,client){ client.addSoapHeader(AuthHeader); client.sale(args,function(error,result){ console.log(error); }); 

我必须在标题中发送身份validation,但它不起作用
我的东西soapHeader的var是错误的。 我将如何解决authentication问题? 非常感谢

你可以less尝试以这种方式发送你的头

 var Autentication ='<AuthHeader xmlns="http://yyyy.com:1002/"><UserName>user</UserName><Password>pass</Password></AuthHeader>' 

添加标题

 client.addSoapHeader(Autentication) 

祝你好运

我find答案

 var AuthHeader = {AuthHeader: { "UserName" : user, "Password" : pass, }