node-soap icon indicating copy to clipboard operation
node-soap copied to clipboard

Error calling service

Open jafl opened this issue 15 years ago • 7 comments

Here is my wsdl:

<wsdl:definitions name="HelloWorldImplService" targetNamespace="http://impl.ws.test.com/" xmlns:ns1="http://ws.test.com/" xmlns:ns2="http://cxf.apache.org/bindings/xformat" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://impl.ws.test.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> wsdl:types <xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://ws.test.com/" xmlns:tns="http://ws.test.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="greet" type="tns:greet"/> <xs:element name="greetResponse" type="tns:greetResponse"/> <xs:complexType name="greet"> xs:sequence <xs:element minOccurs="0" name="name" type="xs:string"/> /xs:sequence /xs:complexType <xs:complexType name="greetResponse"> xs:sequence <xs:element minOccurs="0" name="return" type="xs:string"/> /xs:sequence /xs:complexType /xs:schema /wsdl:types <wsdl:portType name="HelloWorld"> <wsdl:operation name="greet"> <wsdl:input message="ns1:greet" name="greet"> /wsdl:input <wsdl:output message="ns1:greetResponse" name="greetResponse"> /wsdl:output /wsdl:operation /wsdl:portType

<wsdl:message name="greet">
    <wsdl:part element="ns1:greet" name="parameters">
    </wsdl:part>
</wsdl:message>
<wsdl:message name="greetResponse">
    <wsdl:part element="ns1:greetResponse" name="parameters">
    </wsdl:part>
</wsdl:message>
<wsdl:binding name="HelloWorldImplServiceSoapBinding" type="ns1:HelloWorld">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="greet">
        <soap:operation soapAction="" style="document"/>
        <wsdl:input name="greet">
            <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output name="greetResponse">
            <soap:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
</wsdl:binding>
<wsdl:service name="HelloWorldImplService">
    <wsdl:port binding="tns:HelloWorldImplServiceSoapBinding" name="HelloWorldImplPort">
        <soap:address location="http://.../HelloWorld"/>
    </wsdl:port>
</wsdl:service>

/wsdl:definitions

The usual ugly mess :(

My code is:

var soap = require('soap'); soap.createClient('./HelloWorld.wsdl', function(err, client) { client.greet( { name: 'jafl' }, function(err, result) { console.log(err); console.log(result); }); });

The request sent by node-soap is:

soap:Header/soap:Headersoap:Bodyns0:greetns0:namejafl/ns0:name/ns0:greet/soap:Body/soap:Envelope

This is the first problem: It should be , not ns0:name

However, I still get a response. The response received is:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">soap:Body<ns1:greetResponse xmlns:ns1="http://ws.test.com/">Hello, null!/ns1:greetResponse/soap:Body/soap:Envelope

The second problem is that this generates the following error, printed by my console.log(err) statement:

{ stack: [Getter/Setter], arguments: [ 'indexOf', undefined ], type: 'non_object_property_call', message: [Getter/Setter] }

jafl avatar Sep 28 '11 17:09 jafl

Argh! It completely botched the XML. Let me try again:

<wsdl:definitions name="HelloWorldImplService" targetNamespace="http://impl.ws.test.com/" xmlns:ns1="http://ws.test.com/" xmlns:ns2="http://cxf.apache.org/bindings/xformat" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://impl.ws.test.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    wsdl:types
        <xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://ws.test.com/" xmlns:tns="http://ws.test.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
            <xs:element name="greet" type="tns:greet"/>
            <xs:element name="greetResponse" type="tns:greetResponse"/>
            <xs:complexType name="greet">
                xs:sequence
                    <xs:element minOccurs="0" name="name" type="xs:string"/>
                /xs:sequence
            /xs:complexType
            <xs:complexType name="greetResponse">
                xs:sequence
                    <xs:element minOccurs="0" name="return" type="xs:string"/>
                /xs:sequence
            /xs:complexType
        /xs:schema
    /wsdl:types
    <wsdl:portType name="HelloWorld">
        <wsdl:operation name="greet">
            <wsdl:input message="ns1:greet" name="greet">
            /wsdl:input
            <wsdl:output message="ns1:greetResponse" name="greetResponse">
            /wsdl:output
        /wsdl:operation
    /wsdl:portType

<wsdl:message name="greet"> <wsdl:part element="ns1:greet" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:message name="greetResponse"> <wsdl:part element="ns1:greetResponse" name="parameters"> </wsdl:part> </wsdl:message> <wsdl:binding name="HelloWorldImplServiceSoapBinding" type="ns1:HelloWorld"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="greet"> <soap:operation soapAction="" style="document"/> <wsdl:input name="greet"> <soap:body use="literal"/> </wsdl:input> <wsdl:output name="greetResponse"> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="HelloWorldImplService"> <wsdl:port binding="tns:HelloWorldImplServiceSoapBinding" name="HelloWorldImplPort"> <soap:address location="http://.../HelloWorld"/> </wsdl:port> </wsdl:service>


/wsdl:definitions


jafl avatar Sep 28 '11 18:09 jafl

OK, I give up. GitHub markdown sucks. I can email you the wsdl.

jafl avatar Sep 28 '11 18:09 jafl

no worries... i got the WSDL fine over email. thanks for the bug report. i will track down why its generating that exception.

vpulim avatar Sep 28 '11 18:09 vpulim

If you're trying to do syntax highlighting, start with three backticks + xml, end with three backticks.

I believe the issue is that soap:body input elements aren't being parsed in the WSDL parsing code, like this:

<binding type="tns:InboundWSPort" name="InboundWSPort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"></soap:binding>
<operation name="receiveEstimate">
<soap:operation style="rpc" soapAction=""></soap:operation>
<input>
<soap:body namespace="http://tempuri.org/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded"></soap:body>
</input>
<output>
<soap:body namespace="http://tempuri.org/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded"></soap:body>
</output>
</operation>

jbuchbinder avatar Sep 29 '11 05:09 jbuchbinder

Is there a URL for an endpoint I can use to test this WSDL?

milewise avatar Nov 15 '11 22:11 milewise

It seems to be a code example from a book.

My suggestion to test this is to take a normal WSDL file downloaded from a server, modify the URL it contains, then attempt to pass the original URL to setEndpoint().

jbuchbinder avatar Nov 15 '11 22:11 jbuchbinder

please try the latest release and let me know if there is still an issue. if so, please open a new issue since this is quite old now.

milewise avatar Dec 16 '11 01:12 milewise