如何将Authentication Header传递给node-soap [英] How to pass Authentication Header to node-soap

查看:145
本文介绍了如何将Authentication Header传递给node-soap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to use a wsdl service as a client but I cannot find how to set some headers.

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

The reason I need this is because the wsdl I am trying to use requires the username and password via the headers. this is 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);

            });

我必须在标头
中发送身份验证但它不起作用

i thing soapHeader的var是错误的。
我将如何解决身份验证问题?
非常感谢

i have to send authentication in header but it doesn't work
i thing soapHeader's var is wrong . what would i do to solve authentication problem ? thanks a lot

推荐答案

您可以尝试以这种方式发送标题

You can less try sending your header in this way

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

添加标题

client.addSoapHeader(Autentication)

好运气

这篇关于如何将Authentication Header传递给node-soap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆