![](/img/trans.png)
[英]How to add soap header using node-soap or strong-soap in node.js
[英]Node.js - Problems using the SOAP library
我正在嘗試使用這個 package: https://github.com/milewise/node-soap
但是,當我這樣做時:
var soap = require('soap');
var url = 'http://example.com/wsdl?wsdl';
var args = {name: 'value'};
soap.createClient(url, function(err, client) {
client.MyFunction(args, function(err, result) {
console.log(result);
});
});
它返回:“未定義”。
我的問題是我不明白它什么時候說“args”。 與WDSL中的節點有關嗎?
WSDL文件如下:
<xsd:element name="getAllMarkets">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="request" type="types:GetAllMarketsReq"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
請幫忙。 謝謝。
而不是這個:
var args = {name: 'value'};
試試這個:
var args = {'tns:name': 'value'};
它對我有用。
您正在記錄result
,這可能是未定義的,因為存在錯誤,這意味着您的回調 function 的err
參數已定義並將為您提供信息。 在這種情況下,由於看起來您正在調用MyFunction
而不是getAllMarkets
,因此您的錯誤可能是某種“未知方法”錯誤。 做console.log(err, result);
看看打印出來的內容。
嘗試
var args = { request: { name: 'value' } };
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.