'Cannot read property methodName of undefined'使用具有文档样式的 NodeJS SOAP 方法



我有一个NodeJS(node-soap(soap web服务,当我使用POSTMAN时,它可以很好地使用rpc样式,但我需要使它与文档样式一起使用。当我改变风格时,我有一个例外,没有太多信息。下一个细节:

WSDL(与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>

回应是这样的:

<?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请求:

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

更改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 &apos;methodName&apos; of undefined</soap:Text>
</soap:Reason>
</soap:Fault>
</soap:Body>
</soap:Envelope>

我不知道为什么文档样式会失败。另一件事是,如果我使用节点soap客户端的方法,我没有异常,我会正确地获得数据。

回答我的问题时,在请求中我不需要定义方法,我需要定义请求。我使用SoapUI来获得正确的请求。

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

最新更新