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