简体   繁体   English

Node.js - 使用 SOAP 库的问题

[英]Node.js - Problems using the SOAP library

I am trying to use this package: https://github.com/milewise/node-soap我正在尝试使用这个 package: https://github.com/milewise/node-soap

However, when I do this:但是,当我这样做时:

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);
    });
});

It returns back: "undefined".它返回:“未定义”。

My question is I don't understand when it says "args".我的问题是我不明白它什么时候说“args”。 Is it to do with the nodes in the WDSL?与WDSL中的节点有关吗?

The WSDL file is as follows: WSDL文件如下:

<xsd:element name="getAllMarkets">
  <xsd:complexType>
    <xsd:sequence>
      <xsd:element name="request" type="types:GetAllMarketsReq"/>
    </xsd:sequence>
  </xsd:complexType>
</xsd:element>

Please help.请帮忙。 Thanks.谢谢。

instead of this :而不是这个

var args = {name: 'value'};

try this :试试这个

var args = {'tns:name': 'value'};

its worked for me.它对我有用。

You are logging result , which is probably undefined because there's an error, meaning the err argument to your callback function IS defined and will have info for you.您正在记录result ,这可能是未定义的,因为存在错误,这意味着您的回调 function 的err参数已定义并将为您提供信息。 In this case since it looks like you're calling MyFunction instead of getAllMarkets , your error will probably be some sort of "Unknown Method" error.在这种情况下,由于看起来您正在调用MyFunction而不是getAllMarkets ,因此您的错误可能是某种“未知方法”错误。 Do console.log(err, result);console.log(err, result); and see what that prints out.看看打印出来的内容。

try尝试

var args = { request: { name: 'value' } };

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM