我正在编写一个Web服务,从编写WSDL开始。我一直使用wsimport生成服务器端框架代码,然后编写自己的实现类。我在Axis2服务器上运行Web服务。使用soapUI时,来自和来自服务的SOAP消息看起来很好,但是当使用Web服务客户端时,我在客户端存根中得到null。我听说这可能是命名空间问题,但我看错了。这是我的WSDL副本。任何帮助将不胜感激。
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://test.sa.lmco.com" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://test.sa.lmco.com">
<!-- **************** -->
<!-- ** Types ** -->
<!-- **************** -->
<wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://test.sa.lmco.com">
<xs:element name="sayHello">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="s" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="sayHelloResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getTaxonomyNode">
<xs:complexType>
<xs:sequence>
<xs:element name="taxonomyId" minOccurs="1" maxOccurs="1" type="xs:int" />
<xs:element name="nodeId" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getTaxonomyNodeResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="resultNode" type="ns:TaxonomyNode" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getChildren">
<xs:complexType>
<xs:sequence>
<xs:element name="taxonomyId" minOccurs="1" maxOccurs="1" type="xs:int" />
<xs:element name="parentNodeId" minOccurs="1" maxOccurs="1" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getChildrenResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="childNodes" minOccurs="0" maxOccurs="unbounded" type="ns:TaxonomyNode" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="TaxonomyNode">
<xs:sequence>
<xs:element name="taxonomyId" type="xs:int" />
<xs:element name="nodeId" type="xs:int" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="LCD">
<xs:sequence>
<xs:element name="language" type="xs:string" />
<xs:element name="content" type="xs:string" />
<xs:element name="description" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<!-- ***************** -->
<!-- ** Messages ** -->
<!-- ***************** -->
<wsdl:message name="sayHelloRequest">
<wsdl:part name="parameters" element="ns:sayHello"/>
</wsdl:message>
<wsdl:message name="sayHelloResponse">
<wsdl:part name="parameters" element="ns:sayHelloResponse"/>
</wsdl:message>
<wsdl:message name="getTaxonomyNodeRequest">
<wsdl:part name="parameters" element="ns:getTaxonomyNode" />
</wsdl:message>
<wsdl:message name="getTaxonomyNodeResponse">
<wsdl:part name="parameters" element="ns:getTaxonomyNodeResponse" />
</wsdl:message>
<wsdl:message name="getChildrenRequest">
<wsdl:part name="parameters" element="ns:getChildren" />
</wsdl:message>
<wsdl:message name="getChildrenResponse">
<wsdl:part name="parameters" element="ns:getChildrenResponse" />
</wsdl:message>
<!-- ******************* -->
<!-- ** PortTypes ** -->
<!-- ******************* -->
<wsdl:portType name="HelloWSPortType">
<wsdl:operation name="sayHello">
<wsdl:input message="ns:sayHelloRequest" wsaw:Action="urn:sayHello"/>
<wsdl:output message="ns:sayHelloResponse" wsaw:Action="urn:sayHelloResponse"/>
</wsdl:operation>
<wsdl:operation name="getTaxonomyNode">
<wsdl:input message="ns:getTaxonomyNodeRequest" wsaw:Action="urn:getTaxonomyNode" />
<wsdl:output message="ns:getTaxonomyNodeResponse" wsaw:Action="urn:getTaxonomyNodeResponse" />
</wsdl:operation>
<wsdl:operation name="getChildren">
<wsdl:input message="ns:getChildrenRequest" wsaw:Action="urn:getChildren" />
<wsdl:output message="ns:getChildrenResponse" wsaw:Action="urn:getChildrenResponse" />
</wsdl:operation>
</wsdl:portType>
<!-- ****************** -->
<!-- ** Bindings ** -->
<!-- ****************** -->
<wsdl:binding name="HelloWSServiceSoap11Binding" type="ns:HelloWSPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="sayHello">
<soap:operation soapAction="urn:sayHello" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getTaxonomyNode">
<soap:operation soapAction="urn:getTaxonomyNode" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getChildren">
<soap:operation soapAction="urn:getChildren" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<!-- **************** -->
<!-- ** Service ** -->
<!-- **************** -->
<wsdl:service name="HelloWS">
<wsdl:port name="HelloWSServiceHttpSoap11Endpoint" binding="ns:HelloWSServiceSoap11Binding">
<soap:address location="http://162.16.129.25:9090/axis2/services/HelloWS"/>
</wsdl:port>
</wsdl:service>
答案 0 :(得分:0)
这可能是因为单独的WSDL文件。
如果在META-INF中单独指定WSDL,则AXIS2将Web服务的参数作为OMElement传递。
即。如果你在服务API中使用了其他数据类型作为参数,并且你在META-INF中有一个WSDL,那么在调用Service时参数是OMElement而不是String / int或者等...
答案 1 :(得分:0)
我遇到了与Soap Web服务相同的问题,即我得到了null响应。我发现原因是我需要在请求中添加适当的Header字段:比如说 - 内容类型,内容编码等,具体取决于所写的服务。您最好与编写Web服务的人核实