andrepcg
andrepcg

Reputation: 1331

Node-soap Cannot find dispatch method for

I'm trying to consume a SOAP api with node-soap. I'm just running some localhost tests.

This is my wsdl: http://hastebin.com/orenizosay.xml

This is my XSD (from the 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);
    }
}

This is my node test app. The client is successfully created and client.describe() shows the methods correctly.

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

But when I try to call backgroundInsulinDose, my response is

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

and my XML message sent by node-soap is

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

Upvotes: 2

Views: 1727

Answers (1)

andrepcg
andrepcg

Reputation: 1331

After some time debugging the source I found the culprit.

On the wsdl.js file from node-soap package, on line 1481 there's a problem.

In my case, it should be entering that if statement but somehow the variable isNamespaceIgnored is holding true when it should hold false, so the problem might be around shouldIgnoreNamespace function.

EDIT: On line 1062 there are some default ignored namespaces.

So I changed

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

to

WSDL.prototype.ignoredNamespaces = [];

Upvotes: 6

Related Questions