2015-06-04 2 views
0

Я использую последнюю версию IntelliJ, JDK 1.7 и CXF 3.1 Я использовал их для создания кода клиента Java из WSDL.Ошибка Unmarshalling CXF

Вот WSDL

<?xml version="1.0" encoding="UTF-8"?> 
<wsdl:definitions 
    targetNamespace="http://myserver/definitions" 
    xmlns:tns="http://myserver/definitions" 
    xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" 
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" 
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:icd="http://myserver/schemas/GlobalID"> 

    <!-- schema imports + elements --> 
    <wsdl:types> 
     <xs:schema targetNamespace="http://myserver/definitions"> 
      <xs:import namespace="http://myserver/schemas/GlobalID" schemaLocation="http://myserver/schemas/GlobalID.xsd" /> 
     </xs:schema> 
    </wsdl:types> 

    <!-- message definitions --> 
    <wsdl:message name="AddressingRequest"> 
     <wsdl:part name="Body" element="icd:Addressing" /> 
    </wsdl:message> 
    <wsdl:message name="AddressingResponse"> 
     <wsdl:part name="Body" element="icd:AddressingResponse" /> 
    </wsdl:message> 


    <!-- ports -->  
    <wsdl:portType name="WebServicePortType"> 
     <wsdl:operation name="AddressingRequest"> 
      <wsdl:input message="tns:AddressingRequest" /> 
      <wsdl:output message="tns:AddressingResponse" /> 
     </wsdl:operation> 
    </wsdl:portType> 

    <!-- service bindings --> 
    <wsdl:binding name="WebServiceBinding" type="tns:WebServicePortType"> 
     <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> 
     <wsdl:operation name="AddressingRequest"> 
      <soap:operation soapAction="Addressing" /> 
      <wsdl:input> 
       <soap:body use="literal" /> 
      </wsdl:input> 
      <wsdl:output> 
       <soap:body use="literal" /> 
      </wsdl:output> 
     </wsdl:operation> 
    </wsdl:binding> 

    <!-- service --> 
    <wsdl:service name="GlobalIDWebService"> 
     <wsdl:port name="WebServicePort" binding="tns:WebServiceBinding"> 
      <soap:address location="${soap.address.location}"/> 
     </wsdl:port> 
    </wsdl:service> 

    <wsdl:service name="GlobalIDWebServiceSecure"> 
     <wsdl:port name="SecureWebServicePort" binding="tns:WebServiceBinding"> 
      <soap:address location="${soap.address.location.secure}"/> 
     </wsdl:port> 
    </wsdl:service>  

</wsdl:definitions> 

И некоторые определения XSD, которые необходимы:

<?xml version="1.0" encoding="UTF-8"?> 
<xs:schema 
    elementFormDefault="unqualified" 
    attributeFormDefault="unqualified" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    targetNamespace="http://myserver/schemas/GlobalID" 
    xmlns:globalid="http://myserver/schemas/GlobalID" 
    xmlns:common="http://myserver/schemas/Common"> 

    <xs:import namespace="http://myserver/schemas/Common" schemaLocation="http://myserver/schemas/Common.xsd"/> 

    <xs:element name="Addressing" type="globalid:AddressingSearchType"/> 
    <xs:complexType name="AddressingSearchType"> 
     <xs:sequence> 
      <xs:element name="Authentication" type="common:AuthenticationType" minOccurs="1" 
       maxOccurs="1"/> 
      <xs:choice> 
       <xs:element name="Address" type="common:AddressType" minOccurs="1" maxOccurs="1"/> 
       <xs:element name="ComponentAddress" type="globalid:AddressingRecordType" 
        minOccurs="1" maxOccurs="1"/> 
       <xs:sequence> 
        <xs:element name="FullAddress" type="xs:string" minOccurs="1" maxOccurs="1"/> 
        <xs:element name="CountryCode" type="common:CountryCodeType" minOccurs="1" 
         maxOccurs="1"/> 
       </xs:sequence> 
      </xs:choice> 
     </xs:sequence> 
     <xs:attribute name="maxrows" type="xs:integer"/> 
    </xs:complexType> 

    <xs:element name="AddressingResponse" type="globalid:AddressingResponseType"/> 
    <xs:complexType name="AddressingResponseType"> 
     <xs:sequence> 
      <xs:element name="Result" type="globalid:AddressingRecordType" minOccurs="0" 
       maxOccurs="unbounded"/> 
     </xs:sequence> 
     <xs:attribute name="recordcount" type="xs:integer"/> 
    </xs:complexType> 


    <xs:complexType name="AddressingRecordType"> 
     <xs:group ref="globalid:AddressingRecordGroup"/> 
    </xs:complexType> 


    <xs:group name="AddressingRecordGroup"> 
     <xs:all> 
      <xs:element name="AddressLine1" type="xs:string" minOccurs="0" maxOccurs="1"/> 
      <xs:element name="AddressLine2" type="xs:string" minOccurs="0" maxOccurs="1"/> 
      <xs:element name="AddressLine3" type="xs:string" minOccurs="0" maxOccurs="1"/> 
      <xs:element name="AddressLine4" type="xs:string" minOccurs="0" maxOccurs="1"/> 
      <xs:element name="AddressLine5" type="xs:string" minOccurs="0" maxOccurs="1"/> 
      <xs:element name="AddressLine6" type="xs:string" minOccurs="0" maxOccurs="1"/> 
      <xs:element name="AddressLine7" type="xs:string" minOccurs="0" maxOccurs="1"/> 
      <xs:element name="AddressLine8" type="xs:string" minOccurs="0" maxOccurs="1"/> 
      <xs:element name="CountryCode" type="common:CountryCodeType" minOccurs="1" maxOccurs="1"/> 
     </xs:all> 
    </xs:group> 

</xs:schema> 

И я получаю ошибку

org.apache.cxf.interceptor.Fault: Unmarshalling Error: unexpected element (uri:" http://myserver/schemas/GlobalID ", local:"Result"). Expected elements are <{}Result>

Я перепробовал много разных подходов, добавление и удаление пространств имен в POJO ... без эффекта. Все подобные решения этой проблемы, которые я искал в Интернете, не помогли ... :(

ответ

0

Кажется, мне нужно было определить пространство имен в аннотации в моих POJO ... dunno, почему CXF не генерировал его должным образом.

Смежные вопросы