2015-06-14 63 views
1

我试图将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); 

      }); 

我必须在头 发送身份验证,但它不工作
我的事情SOAPHEADER的变种是错误的。 我会怎样解决认证问题? 非常感谢

回答

0

我找到答案

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

      } 
+0

在我的情况下不工作:s :( –

1

你可以少尝试这种方式

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

添加页眉

client.addSoapHeader(Autentication) 

好运

发送你的头
相关问题