3

我正在使用 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 对象为空且不包含任何值!

并且没有错误或异常抛出。一切似乎都很好。反序列化响应存在明显问题。但是我能用它做什么呢?

问题出在哪里?

谢谢

4

0 回答 0