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 的 var 是错误的。我将如何解决身份验证问题?多谢

4

2 回答 2

2

您可以少尝试以这种方式发送您的标头

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

添加标题

client.addSoapHeader(Autentication)

祝你好运

于 2016-11-03T17:08:17.400 回答
0

我找到了答案

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

            }
于 2015-06-20T07:03:09.097 回答