我正在尝试使用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);
}
}
这是我的节点测试应用。客户端已成功创建,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>--------------------
答案 0 :(得分:6)
经过一段时间的调试,我找到了罪魁祸首。
在node-soap包的wsdl.js文件中,第1481行出现了问题。
在我的情况下,它应该输入if语句但不知何故变量 isNamespaceIgnored 在 false 时保持 true ,所以问题可能出在 shouldIgnoreNamespace 函数周围。
编辑: 在第1062行,有一些默认的忽略名称空间。
所以我改变了
WSDL.prototype.ignoredNamespaces = ['tns', 'targetNamespace', 'typedNamespace'];
到
WSDL.prototype.ignoredNamespaces = [];