Node-soap无法找到调度方法

and*_*pcg 2 soap wsdl jax-ws node.js

我正在尝试使用node-soap来使用SOAP api.我刚刚运行了一些localhost测试.

这是我的wsdl:http://hastebin.com/orenizosay.xml

这是我的XSD(来自WSDL):http://hastebin.com/zaqogicabo.xml

public class InsulinEndpoint {

    public static void main(String[] argv) {

        Insulin insulin = new Insulin ();
        String address = "http://localhost:8081/insulin/";
        Endpoint.publish(address, insulin);
        System.out.println("Webservices online at: " + address);
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的节点测试应用程序.客户端已成功创建,client.describe()正确显示方法.

soap.createClient(url, function(err, client) {
    if (err) throw err;

    client.backgroundInsulinDose({arg0: 10}, function(err, result) {
         if(err)
            console.error(err);
        else
            console.log(result);
    });
});
Run Code Online (Sandbox Code Playgroud)

但是当我尝试调用backgroundInsulinDose时,我的回答是

<faultstring>Cannot find dispatch method for {}backgroundInsulinDose</faultstring>
Run Code Online (Sandbox Code Playgroud)

而且我的node-soap发送的XML消息是

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:tns="http://server/"><soap:Body><backgroundInsulinDose><arg0>10</arg0></backgroundInsulinDose></soap:Body></soap:Envelope>--------------------
Run Code Online (Sandbox Code Playgroud)

and*_*pcg 6

经过一段时间调试源,我找到了罪魁祸首.

在node-soap包的wsdl.js文件中,在第1481行有一个问题.

在我的情况下,应该进入,如果语句,但不知何故变量isNamespaceIgnored拿着时,应持假的,所以这个问题可能是周围shouldIgnoreNamespace功能.

编辑:在第1062行,有一些默认忽略的命名空间.

所以我改变了

WSDL.prototype.ignoredNamespaces = ['tns', 'targetNamespace', 'typedNamespace'];
Run Code Online (Sandbox Code Playgroud)

WSDL.prototype.ignoredNamespaces = [];
Run Code Online (Sandbox Code Playgroud)

  • 为避免更改node_modules,您可以在fly var soap = require('soap')上覆盖; soap.WSDL.prototype.ignoredNamespaces = ['xs','xsd']; (6认同)