I have a NodeJS (node-soap) SOAP web service and it works good with rpc style when I consume it by POSTMAN, but I need to make it works with document style. When I change the style I have an exception with no much information. Next details:
WSDL (It works with style rpc):
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
name="files_service"
targetNamespace="http://localhost:4205/files_service"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:s="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://localhost:4205/files_service">
<wsdl:types>
<xs:schema targetNamespace="http://localhost:4205/files_service" xmlns="http://localhost:4205/files_service" attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="GetFilesRequest">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="1" name="User" type="xs:string"/>
<xs:element minOccurs="0" maxOccurs="1" name="Password" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetFilesResponse">
<xs:complexType>
<xs:sequence>
<xs:any/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="GetFilesSoapIn">
<wsdl:part name="parameters" element="tns:GetFilesRequest"/>
</wsdl:message>
<wsdl:message name="GetFilesSoapOut">
<wsdl:part name="parameters" element="tns:GetFilesResponse"/>
</wsdl:message>
<wsdl:portType name="pull_files">
<wsdl:operation name="GetFiles">
<wsdl:input message="tns:GetFilesSoapIn"/>
<wsdl:output message="tns:GetFilesSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="pull_files_binding" type="tns:pull_files">
<s:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
<wsdl:operation name="GetFiles">
<s:operation soapAction="GetFiles"/>
<wsdl:input>
<s:body use="literal" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</wsdl:input>
<wsdl:output>
<s:body use="literal" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="files">
<wsdl:port binding="tns:pull_files_binding" name="pull">
<s:address location="http://localhost:4205/files_service"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Response is something like that:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://localhost:4205/files_service">
<soap:Body>
<tns:GetFilesResponse>
<tns:GetFilesResult>
<tns:File>
<Name></Name>
<Dir></Dir>
</tns:File>
</tns:GetFilesResult>
</tns:GetFilesResponse>
</soap:Body>
</soap:Envelope>
POSTMAN request:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http:localhost:4205/files_service">
<soap:Body>
<tns:GetFiles>
<tns:User>myusername</tns:User>
<tns:Password>mypassword</tns:Password>
</tns:GetFiles>
</soap:Body>
</soap:Envelope>
Error when I change the style for document in the WSDL <s:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="http://localhost:4205/files_service">
<soap:Body>
<soap:Fault>
<soap:Code>
<soap:Value>SOAP-ENV:Server</soap:Value>
<soap:Subcode>
<soap:value>InternalServerError</soap:value>
</soap:Subcode>
</soap:Code>
<soap:Reason>
<soap:Text>TypeError: Cannot read property 'methodName' of undefined</soap:Text>
</soap:Reason>
</soap:Fault>
</soap:Body>
</soap:Envelope>
I don't have any idea why this fails with document style. Other thing is if I consume the method from a node-soap client I don't have the exception, I get the data correctly.
Answering my question, in the request I don't need to define the method, I need to define the request. I use SoapUI to get the correct request.
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http:localhost:4205/files_service">
<soap:Body>
<tns:GetFilesRequest>
<tns:User>myuser</tns:User>
<tns:Password>mypass</tns:Password>
</tns:GetFilesRequest>
</soap:Body>
</soap:Envelope>