Node.js 节点js中soap的响应主体中未定义名称空间。
我正在将node js与soap模块“node soap”版本0.24.0(最新版本)一起使用 我正在用下面的wsdl文件server.js文件实现一个api框架。出于组织上的原因,wsdl操作就像一个样本模板,类似于原始代码的结构。当我发出SOAP请求时,它被成功处理,但在响应中,标记中的名称空间部分是未定义的。这会给我们的客户端造成问题,他们将进行api调用,他们无法正确读取响应 我找不到解决方法,也不知道是否应该更改wsdl文件或server.js中的某些内容 wscalc1.wsdlNode.js 节点js中soap的响应主体中未定义名称空间。,node.js,soap,wsdl,node-soap,Node.js,Soap,Wsdl,Node Soap,我正在将node js与soap模块“node soap”版本0.24.0(最新版本)一起使用 我正在用下面的wsdl文件server.js文件实现一个api框架。出于组织上的原因,wsdl操作就像一个样本模板,类似于原始代码的结构。当我发出SOAP请求时,它被成功处理,但在响应中,标记中的名称空间部分是未定义的。这会给我们的客户端造成问题,他们将进行api调用,他们无法正确读取响应 我找不到解决方法,也不知道是否应该更改wsdl文件或server.js中的某些内容 wscalc1.wsdl &
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="wscalc1" targetNamespace="http://localhost:8000/wscalc1"
xmlns="http://localhost:8000/wscalc1"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<wsdl:message name="multiplicarRequest">
<wsdl:part name="a" type="xs:string"/>
<wsdl:part name="b" type="xs:string"/>
</wsdl:message>
<wsdl:message name="multiplicarResponse">
<wsdl:part name="mulres" type="xs:string"/>
</wsdl:message>
<wsdl:portType name="calcP">
<wsdl:operation name="multiplicar">
<wsdl:input message="multiplicarRequest"/>
<wsdl:output message="multiplicarResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="calcB" type="calcP">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="multiplicar">
<soap:operation soapAction="multiplicar"/>
<wsdl:input>
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ws">
<wsdl:port binding="calcB" name="calc">
<soap:address location="http://localhost:8001/wscalc1"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://localhost:8000/wscalc1" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="wscalc1" targetNamespace="http://localhost:8000/wscalc1">
<wsdl:message name="sumarRequest">
<wsdl:part name="a" type="xsd:string"></wsdl:part>
<wsdl:part name="b" type="xsd:string"></wsdl:part>
</wsdl:message>
<wsdl:message name="sumarResponse">
<wsdl:part name="sumres" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="multiplicarRequest">
<wsdl:part name="a" type="xsd:string"></wsdl:part>
<wsdl:part name="b" type="xsd:string"></wsdl:part>
</wsdl:message>
<wsdl:message name="multiplicarResponse">
<wsdl:part name="mulres" type="xsd:string"></wsdl:part>
</wsdl:message>
<wsdl:portType name="calcP">
<wsdl:operation name="sumar">
<wsdl:input message="tns:sumarRequest"></wsdl:input>
<wsdl:output message="tns:sumarResponse"/>
</wsdl:operation>
<wsdl:operation name="multiplicar">
<wsdl:input message="tns:multiplicarRequest"></wsdl:input>
<wsdl:output message="tns:multiplicarResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="calcB" type="tns:calcP">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="sumar">
<soap:operation soapAction="sumar" style="rpc"/>
<wsdl:input>
<soap:body namespace="http://localhost:8000/wscalc1" use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body namespace="http://localhost:8000/wscalc1" use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="multiplicar">
<soap:operation soapAction="multiplicar" style="rpc"/>
<wsdl:input>
<soap:body namespace="http://localhost:8000/wscalc1" use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body namespace="http://localhost:8000/wscalc1" use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ws">
<wsdl:port binding="tns:calcB" name="calc">
<soap:address location="http://localhost:8001/wscalc1"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
发布请求
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsc="http://localhost:8000/wscalc1">
<soapenv:Header/>
<soapenv:Body>
<wsc:multiplicar>
<a>2</a>
<b>3</b>
</wsc:multiplicar>
</soapenv:Body>
</soapenv:Envelope>
2.
3.
响应
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" >
<soap:Body>
<undefined:multiplicarResponse>
<undefined:mulres>6</undefined:mulres>
</undefined:multiplicarResponse>
</soap:Body>
</soap:Envelope>
6.
我也有同样的问题。我不确定如何将我的解决方案应用于您的代码,但您需要在
标记中指定名称空间,并为其指定前缀,如:
<definitions
name="ININWebService"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="WebServices.TVTraffic"
targetNamespace="WebServices.TVTraffic"
>
然后我使用相同的前缀“tns”来定义消息和元素,比如element=“tns:updatePayment”
而不是element=“updatePayment”
等等,最后我得到了工作名称空间前缀
希望有帮助。我也有同样的问题。我不确定如何将我的解决方案应用于您的代码,但您需要在
标记中指定名称空间,并为其指定前缀,如:
<definitions
name="ININWebService"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="WebServices.TVTraffic"
targetNamespace="WebServices.TVTraffic"
>
然后我使用相同的前缀“tns”来定义消息和元素,比如element=“tns:updatePayment”
而不是element=“updatePayment”
等等,最后我得到了工作名称空间前缀
希望能有所帮助。我已经能够让它工作了,但是我不得不对wsdl做一些更改,我还使用Eclipse wsdl编辑器来验证是否有任何错误。详情如下: wscalc1.wsdl
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="wscalc1" targetNamespace="http://localhost:8000/wscalc1"
xmlns="http://localhost:8000/wscalc1"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<wsdl:message name="multiplicarRequest">
<wsdl:part name="a" type="xs:string"/>
<wsdl:part name="b" type="xs:string"/>
</wsdl:message>
<wsdl:message name="multiplicarResponse">
<wsdl:part name="mulres" type="xs:string"/>
</wsdl:message>
<wsdl:portType name="calcP">
<wsdl:operation name="multiplicar">
<wsdl:input message="multiplicarRequest"/>
<wsdl:output message="multiplicarResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="calcB" type="calcP">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="multiplicar">
<soap:operation soapAction="multiplicar"/>
<wsdl:input>
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ws">
<wsdl:port binding="calcB" name="calc">
<soap:address location="http://localhost:8001/wscalc1"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://localhost:8000/wscalc1" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="wscalc1" targetNamespace="http://localhost:8000/wscalc1">
<wsdl:message name="sumarRequest">
<wsdl:part name="a" type="xsd:string"></wsdl:part>
<wsdl:part name="b" type="xsd:string"></wsdl:part>
</wsdl:message>
<wsdl:message name="sumarResponse">
<wsdl:part name="sumres" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="multiplicarRequest">
<wsdl:part name="a" type="xsd:string"></wsdl:part>
<wsdl:part name="b" type="xsd:string"></wsdl:part>
</wsdl:message>
<wsdl:message name="multiplicarResponse">
<wsdl:part name="mulres" type="xsd:string"></wsdl:part>
</wsdl:message>
<wsdl:portType name="calcP">
<wsdl:operation name="sumar">
<wsdl:input message="tns:sumarRequest"></wsdl:input>
<wsdl:output message="tns:sumarResponse"/>
</wsdl:operation>
<wsdl:operation name="multiplicar">
<wsdl:input message="tns:multiplicarRequest"></wsdl:input>
<wsdl:output message="tns:multiplicarResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="calcB" type="tns:calcP">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="sumar">
<soap:operation soapAction="sumar" style="rpc"/>
<wsdl:input>
<soap:body namespace="http://localhost:8000/wscalc1" use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body namespace="http://localhost:8000/wscalc1" use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="multiplicar">
<soap:operation soapAction="multiplicar" style="rpc"/>
<wsdl:input>
<soap:body namespace="http://localhost:8000/wscalc1" use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body namespace="http://localhost:8000/wscalc1" use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ws">
<wsdl:port binding="tns:calcB" name="calc">
<soap:address location="http://localhost:8001/wscalc1"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
soap请求
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsc="http://localhost:8000/wscalc1">
<soapenv:Header/>
<soapenv:Body>
<wsc:multiplicar>
<a>2</a>
<b>3</b>
</wsc:multiplicar>
</soapenv:Body>
</soapenv:Envelope>
2.
3.
响应
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" >
<soap:Body>
<undefined:multiplicarResponse>
<undefined:mulres>6</undefined:mulres>
</undefined:multiplicarResponse>
</soap:Body>
</soap:Envelope>
5.
我已经能够让它工作,但是我必须对wsdl做一些更改,我还使用Eclipse wsdl编辑器来验证是否存在任何错误。详情如下:
wscalc1.wsdl
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="wscalc1" targetNamespace="http://localhost:8000/wscalc1"
xmlns="http://localhost:8000/wscalc1"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<wsdl:message name="multiplicarRequest">
<wsdl:part name="a" type="xs:string"/>
<wsdl:part name="b" type="xs:string"/>
</wsdl:message>
<wsdl:message name="multiplicarResponse">
<wsdl:part name="mulres" type="xs:string"/>
</wsdl:message>
<wsdl:portType name="calcP">
<wsdl:operation name="multiplicar">
<wsdl:input message="multiplicarRequest"/>
<wsdl:output message="multiplicarResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="calcB" type="calcP">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="multiplicar">
<soap:operation soapAction="multiplicar"/>
<wsdl:input>
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ws">
<wsdl:port binding="calcB" name="calc">
<soap:address location="http://localhost:8001/wscalc1"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://localhost:8000/wscalc1" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="wscalc1" targetNamespace="http://localhost:8000/wscalc1">
<wsdl:message name="sumarRequest">
<wsdl:part name="a" type="xsd:string"></wsdl:part>
<wsdl:part name="b" type="xsd:string"></wsdl:part>
</wsdl:message>
<wsdl:message name="sumarResponse">
<wsdl:part name="sumres" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="multiplicarRequest">
<wsdl:part name="a" type="xsd:string"></wsdl:part>
<wsdl:part name="b" type="xsd:string"></wsdl:part>
</wsdl:message>
<wsdl:message name="multiplicarResponse">
<wsdl:part name="mulres" type="xsd:string"></wsdl:part>
</wsdl:message>
<wsdl:portType name="calcP">
<wsdl:operation name="sumar">
<wsdl:input message="tns:sumarRequest"></wsdl:input>
<wsdl:output message="tns:sumarResponse"/>
</wsdl:operation>
<wsdl:operation name="multiplicar">
<wsdl:input message="tns:multiplicarRequest"></wsdl:input>
<wsdl:output message="tns:multiplicarResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="calcB" type="tns:calcP">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="sumar">
<soap:operation soapAction="sumar" style="rpc"/>
<wsdl:input>
<soap:body namespace="http://localhost:8000/wscalc1" use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body namespace="http://localhost:8000/wscalc1" use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="multiplicar">
<soap:operation soapAction="multiplicar" style="rpc"/>
<wsdl:input>
<soap:body namespace="http://localhost:8000/wscalc1" use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body namespace="http://localhost:8000/wscalc1" use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ws">
<wsdl:port binding="tns:calcB" name="calc">
<soap:address location="http://localhost:8001/wscalc1"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
soap请求
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsc="http://localhost:8000/wscalc1">
<soapenv:Header/>
<soapenv:Body>
<wsc:multiplicar>
<a>2</a>
<b>3</b>
</wsc:multiplicar>
</soapenv:Body>
</soapenv:Envelope>
2.
3.
响应
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" >
<soap:Body>
<undefined:multiplicarResponse>
<undefined:mulres>6</undefined:mulres>
</undefined:multiplicarResponse>
</soap:Body>
</soap:Envelope>
5.