我有一个axis2 web服务应用程序。它是使用轴2 1.7.8建造的。
以下是Web服务调用"关闭"的wsdl
<wsdl:definitions targetNamespace="vish_testweb_close" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="vish_testweb_close" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl">
<wsdl:documentation>vish_testweb_close</wsdl:documentation>
<wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="vish_testweb_close">
<xs:element name="close">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="authToken" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="closeResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="return" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="closeRequest">
<wsdl:part name="parameters" element="ns:close"/>
</wsdl:message>
<wsdl:message name="closeResponse">
<wsdl:part name="parameters" element="ns:closeResponse"/>
</wsdl:message>
<wsdl:portType name="vish_testweb_closePortType">
<wsdl:operation name="close">
<wsdl:input message="ns:closeRequest" wsaw:Action="urn:close"/>
<wsdl:output message="ns:closeResponse" wsaw:Action="urn:closeResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="vish_testweb_closeSoap11Binding" type="ns:vish_testweb_closePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="close">
<soap:operation soapAction="urn:close" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="vish_testweb_closeSoap12Binding" type="ns:vish_testweb_closePortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="close">
<soap12:operation soapAction="urn:close" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="vish_testweb_closeHttpBinding" type="ns:vish_testweb_closePortType">
<http:binding verb="POST"/>
<wsdl:operation name="close">
<http:operation location="close"/>
<wsdl:input>
<mime:content type="application/xml" part="parameters"/>
</wsdl:input>
<wsdl:output>
<mime:content type="application/xml" part="parameters"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="vish_testweb_close">
<wsdl:port name="vish_testweb_closeHttpsSoap11Endpoint" binding="ns:vish_testweb_closeSoap11Binding">
<soap:address location=""/>
</wsdl:port>
<wsdl:port name="vish_testweb_closeHttpSoap11Endpoint" binding="ns:vish_testweb_closeSoap11Binding">
<soap:address location="http://localhost:8080/vish-800_latest/services/vish_testweb_close.vish_testweb_closeHttpSoap11Endpoint/"/>
</wsdl:port>
<wsdl:port name="vish_testweb_closeHttpSoap12Endpoint" binding="ns:vish_testweb_closeSoap12Binding">
<soap12:address location="http://localhost:8080/vish-800_latest/services/vish_testweb_close.vish_testweb_closeHttpSoap12Endpoint/"/>
</wsdl:port>
<wsdl:port name="vish_testweb_closeHttpsSoap12Endpoint" binding="ns:vish_testweb_closeSoap12Binding">
<soap12:address location=""/>
</wsdl:port>
<wsdl:port name="vish_testweb_closeHttpsEndpoint" binding="ns:vish_testweb_closeHttpBinding">
<http:address location=""/>
</wsdl:port>
<wsdl:port name="vish_testweb_closeHttpEndpoint" binding="ns:vish_testweb_closeHttpBinding">
<http:address location="http://localhost:8080/vish-800_latest/services/vish_testweb_close.vish_testweb_closeHttpEndpoint/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
我正在尝试以RESTFUL风格调用上述web服务。
http://localhost:8080/LabWare-800_latest/services/labware_weblims_close/close
数据以application/json格式的POST发送:
{
"close": {
"authToken":"authtoken1112334"
}
}
但轴心国的阴谋抛出了以下"错误">
{"Fault": "<soapenv:Fault xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>soapenv:Server</faultcode><faultstring>namespace mismatch require vish_testweb_close found vish_testweb_authenticate</faultstring><detail/></soapenv:Fault>"}
命名空间中还有另一个web服务:vish_testweb_authenticate
。以下是wsdl:
<wsdl:definitions targetNamespace="vish_testweb_authenticate" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="vish_testweb_authenticate" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl">
<wsdl:documentation>vish_testweb_authenticate</wsdl:documentation>
<wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="vish_testweb_authenticate">
<xs:element name="authenticateWithRole">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="username" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="password" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="role" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="limsDSName" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="limsServiceName" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="authenticateWithRoleResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="authenticate">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="username" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="password" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="limsDSName" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="limsServiceName" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="authenticateResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="authenticateRequest">
<wsdl:part name="parameters" element="ns:authenticate"/>
</wsdl:message>
<wsdl:message name="authenticateResponse">
<wsdl:part name="parameters" element="ns:authenticateResponse"/>
</wsdl:message>
<wsdl:message name="authenticateWithRoleRequest">
<wsdl:part name="parameters" element="ns:authenticateWithRole"/>
</wsdl:message>
<wsdl:message name="authenticateWithRoleResponse">
<wsdl:part name="parameters" element="ns:authenticateWithRoleResponse"/>
</wsdl:message>
<wsdl:portType name="vish_testweb_authenticatePortType">
<wsdl:operation name="authenticate">
<wsdl:input message="ns:authenticateRequest" wsaw:Action="urn:authenticate"/>
<wsdl:output message="ns:authenticateResponse" wsaw:Action="urn:authenticateResponse"/>
</wsdl:operation>
<wsdl:operation name="authenticateWithRole">
<wsdl:input message="ns:authenticateWithRoleRequest" wsaw:Action="urn:authenticateWithRole"/>
<wsdl:output message="ns:authenticateWithRoleResponse" wsaw:Action="urn:authenticateWithRoleResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="vish_testweb_authenticateSoap11Binding" type="ns:vish_testweb_authenticatePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="authenticate">
<soap:operation soapAction="urn:authenticate" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="authenticateWithRole">
<soap:operation soapAction="urn:authenticateWithRole" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="vish_testweb_authenticateSoap12Binding" type="ns:vish_testweb_authenticatePortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="authenticate">
<soap12:operation soapAction="urn:authenticate" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="authenticateWithRole">
<soap12:operation soapAction="urn:authenticateWithRole" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="vish_testweb_authenticateHttpBinding" type="ns:vish_testweb_authenticatePortType">
<http:binding verb="POST"/>
<wsdl:operation name="authenticate">
<http:operation location="authenticate"/>
<wsdl:input>
<mime:content type="application/xml" part="parameters"/>
</wsdl:input>
<wsdl:output>
<mime:content type="application/xml" part="parameters"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="authenticateWithRole">
<http:operation location="authenticateWithRole"/>
<wsdl:input>
<mime:content type="application/xml" part="parameters"/>
</wsdl:input>
<wsdl:output>
<mime:content type="application/xml" part="parameters"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="vish_testweb_authenticate">
<wsdl:port name="vish_testweb_authenticateHttpSoap11Endpoint" binding="ns:vish_testweb_authenticateSoap11Binding">
<soap:address location="http://localhost:8080/vish-800_latest/services/vish_testweb_authenticate.vish_testweb_authenticateHttpSoap11Endpoint/"/>
</wsdl:port>
<wsdl:port name="vish_testweb_authenticateHttpsSoap11Endpoint" binding="ns:vish_testweb_authenticateSoap11Binding">
<soap:address location=""/>
</wsdl:port>
<wsdl:port name="vish_testweb_authenticateHttpsSoap12Endpoint" binding="ns:vish_testweb_authenticateSoap12Binding">
<soap12:address location=""/>
</wsdl:port>
<wsdl:port name="vish_testweb_authenticateHttpSoap12Endpoint" binding="ns:vish_testweb_authenticateSoap12Binding">
<soap12:address location="http://localhost:8080/vish-800_latest/services/vish_testweb_authenticate.vish_testweb_authenticateHttpSoap12Endpoint/"/>
</wsdl:port>
<wsdl:port name="vish_testweb_authenticateHttpEndpoint" binding="ns:vish_testweb_authenticateHttpBinding">
<http:address location="http://localhost:8080/vish-800_latest/services/vish_testweb_authenticate.vish_testweb_authenticateHttpEndpoint/"/>
</wsdl:port>
<wsdl:port name="vish_testweb_authenticateHttpsEndpoint" binding="ns:vish_testweb_authenticateHttpBinding">
<http:address location=""/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
我们将非常感谢在这方面提供的任何帮助。
最终解决了问题。问题出现在close.aar服务的services.xml中(这两项服务都已部署为archive.
services.xml错误地将xmlNamespace设置为";vish_testweb_authenticate";在关闭服务service.xml 中
<service name="vish_testweb_close" targetNamespace="vish_testweb_close">
<description>
This service is to close connection
</description>
<schema schemaNamespace="labware_weblims_close"/>
<parameter name="ServiceClass">vish.web.ws.service.CloseService</parameter>
<parameter name="xmlToJsonNamespaceMap">
<mappings>
<mapping xmlNamespace="vish_testweb_authenticate" jsonNamespace=""/>
</mappings>
</parameter>
<operation name="close">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
<messageReceiver class="org.apache.axis2.json.gson.rpc.JsonRpcMessageReceiver"/>
</operation>
<module ref="soapmonitor"/>
</service>
更正后的service.xml如下(请参阅"xmlToJsonNamespaceMap"部分(
<service name="vish_testweb_close" targetNamespace="vish_testweb_close">
<description>
This service is to close connection
</description>
<schema schemaNamespace="labware_weblims_close"/>
<parameter name="ServiceClass">vish.web.ws.service.CloseService</parameter>
<parameter name="xmlToJsonNamespaceMap">
<mappings>
<mapping xmlNamespace="vish_testweb_close" jsonNamespace=""/>
</mappings>
</parameter>
<operation name="close">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
<messageReceiver class="org.apache.axis2.json.gson.rpc.JsonRpcMessageReceiver"/>
</operation>
<module ref="soapmonitor"/>
</service>