【问题标题】:Node-soap Cannot find dispatch method forNode-soap 找不到调度方法
【发布时间】:2015-04-30 01:51:39
【问题描述】:

我正在尝试使用带有 node-soap 的 SOAP api。我只是在运行一些本地主机测试。

这是我的 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);
    }
}

这是我的节点测试应用。客户端创建成功,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);
    });
});

但是当我尝试调用 backgroundInsulinDose 时,我的反应是

<faultstring>Cannot find dispatch method for {}backgroundInsulinDose</faultstring>

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>--------------------

【问题讨论】:

    标签: node.js soap wsdl jax-ws


    【解决方案1】:

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

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

    在我的情况下,它应该输入 if 语句,但不知何故变量 isNamespaceIgnored 在它应该保持 false 时保持 true,所以问题可能与 shouldIgnoreNamespace 函数有关。

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

    所以我改变了

    WSDL.prototype.ignoredNamespaces = ['tns', 'targetNamespace', 'typedNamespace'];
    

    WSDL.prototype.ignoredNamespaces = [];
    

    【讨论】:

    • 为避免更改 node_modules,您可以即时覆盖 var soap = require('soap'); soap.WSDL.prototype.ignoredNamespaces = ['xs', 'xsd'];
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-27
    相关资源
    最近更新 更多