收到jax-ws响应,但响应对象为空

时间:2013-05-03 15:29:42

标签: java web-services jax-ws

我正在使用jdk 6中的wsimport创建soap webservice客户端。 更具体地说,JDK 6中的JAX-WS RI 2.1.6。

这是wsdl

   <?xml version="1.0" encoding="UTF-8" standalone="no"?>
   <wsdl:definitions name="customerSearch" targetNamespace="http://customer-search-gui.ws.com" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://customer-search-gui.ws.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://customer-search-gui.ws.com">
   <wsdl:types>
    <xsd:schema targetNamespace="http://customer-search-gui.ws.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <xsd:element name="STATUS">
            <xsd:complexType>
                <xsd:sequence>
                    <xsd:element name="STATUS_CODE" type="xsd:integer"/>
                    <xsd:element name="ERROR_CODE" type="xsd:string" minOccurs="0"/>
                    <xsd:element name="ERROR_DESCRIPTION" type="xsd:string" minOccurs="0"/>
                </xsd:sequence>
            </xsd:complexType>
        </xsd:element>
        <xsd:element name="customer">
            <xsd:complexType>
                <xsd:sequence>
                    <xsd:element name="firstName" type="xsd:string" nillable="true"/>
                    <xsd:element name="lastName" type="xsd:string" nillable="true"/>
                    <xsd:element name="street" type="xsd:string" nillable="true"/>
                    <xsd:element name="number" type="xsd:string" nillable="true"/>
                    <xsd:element name="city" type="xsd:string" nillable="true"/>
                    <xsd:element name="zipCode" type="xsd:string" nillable="true"/>
                </xsd:sequence>
            </xsd:complexType>
        </xsd:element>

        <xsd:element name="customerSearchCRMRequest">
            <xsd:complexType>
                <xsd:sequence>
                    <xsd:element name="searchCriteria">
                        <xsd:complexType>
                            <xsd:sequence>
                                <xsd:element name="firstName" minOccurs="0" type="xsd:string"/>
                                <xsd:element name="lastName" minOccurs="0" type="xsd:string"/>
                            </xsd:sequence>
                        </xsd:complexType>
                    </xsd:element>
                    <xsd:element name="trackingId" type="xsd:string"/>
                </xsd:sequence>
            </xsd:complexType>
        </xsd:element>
        <xsd:element name="customerSearchCRMResponse">
            <xsd:complexType>
                <xsd:sequence>
                    <xsd:element name="customerList">
                        <xsd:complexType>
                            <xsd:sequence>
                                <xsd:element ref="tns:customer" maxOccurs="unbounded" minOccurs="0"/>
                            </xsd:sequence>
                        </xsd:complexType>
                    </xsd:element>
                    <xsd:element name="trackingId" type="xsd:string"/>
                    <xsd:element ref="tns:STATUS"/>
                </xsd:sequence>
            </xsd:complexType>
        </xsd:element>         
    </xsd:schema>
</wsdl:types>
<wsdl:message name="searchCrmRequest">
    <wsdl:part name="request" element="tns:customerSearchCRMRequest"/>
</wsdl:message>
<wsdl:message name="searchCrmResponse">
    <wsdl:part name="response" element="tns:customerSearchCRMResponse"/>
</wsdl:message>
<wsdl:portType name="search">
    <wsdl:operation name="searchCrm">
        <wsdl:input message="tns:searchCrmRequest"/>
        <wsdl:output message="tns:searchCrmResponse"/>
    </wsdl:operation>
</wsdl:portType>
<wsdl:binding name="searchSOAP" type="tns:search">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="searchCrm">
        <soap:operation soapAction="/searchCrm"/>
        <wsdl:input>
            <soap:body use="literal" namespace="http://customer-search-gui.ws.com"/>
        </wsdl:input>
        <wsdl:output>
            <soap:body use="literal" namespace="http://customer-search-gui.ws.com"/>
        </wsdl:output>
    </wsdl:operation>
</wsdl:binding>
<wsdl:service name="customerSearch">
    <wsdl:port binding="tns:searchSOAP" name="searchSOAP">
        <soap:address location="http://192.192.192.192:10001/customSearch"/>
    </wsdl:port>
</wsdl:service>

这是请求:

    <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:customerSearchCRMRequest xmlns:ns2="http://customer-search-gui.ws.com"><searchCriteria><firstName>John</firstName></searchCriteria><trackingId>track001</trackingId></ns2:customerSearchCRMRequest></S:Body></S:Envelope>

以下是回复:

   <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><customerSearchCRMResponse xmlns="http://customer-search-gui.ws.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><customerList><customer><firstName>John</firstName><lastName>Stone</lastName></customer></customerList><trackingId>track001</trackingId><STATUS><STATUS_CODE>0</STATUS_CODE></STATUS></customerSearchCRMResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

所以,就像你可以看到有回应的东西。但问题是在java中customerSearchCRMResponse对象为空且不包含任何值!

没有错误或异常呕吐。一切似乎都很好。反序列化反应存在明显的问题。但是我能做些什么呢?

问题出在哪里?有什么问题?

谢谢

0 个答案:

没有答案