cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Burrell, Christopher" <Christopher.Burr...@baesystemsdetica.com>
Subject CXF, JAXB and custom classes
Date Tue, 26 Feb 2013 17:27:41 GMT
Hi

 

I've got the following issue when sending SOAP messages to my service:
(Apologies in advance for all the anonymisation.)

Unmarshalling Error: unexpected element (uri:"http://myanimals.com",
local:"cat"). Expected elements are &lt;{http://myanimals.com}animal

 

In Spring, I'm using the following fragment:

 

       <jaxws:endpoint id="myEI" implementor="#springBean"
address="/myservice ">

              <jaxws:properties>

                     <entry key="jaxb.additionalContextClasses">

                           <bean

 
class="my.package.jaxws.ClassArrayFactoryBean">

                                  <property name="classNames">

                                         <list>

                                                <value>
my.package.types.Cat</value>

                                         </list>

                                  </property>

                           </bean>

                     </entry>

              </jaxws:properties>

       </jaxws:endpoint>

 

This seems to work partially. The new types appear in the WSDL,
including the inheritance hierarchy. (i.e. I have Cat, its parent
Mammal, and its parent Animal, and so on). Cat, Animal and Mammal all
live in the same namespace (http://myanimals.com). The web service
request/response objects live in a different namespace
http://myservice.com

 

CXF (almost) correctly generates the WSDL, although I seem to have 2
schemas in my WSDL. I also seem to have 2 elements named "animal", but
declared in the same namespace. I need to declare one in my xsd because
it is part of the request (i.e. function(Animal animal). And it seems
CXF generates another one by include Cat in the jaxbClasses. Not sure if
this is an issue...

 

<wsdl:types>

   <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 

     xmlns:tns="http://myservice.com" 

     xmlns:ns1="http://myanimals.com" 

     targetNamespace="http://myservice.com" version="1.0">

 

     <xs:import namespace="http://myanimals.com"/>

...

     <xs:element name="animal" type="ns1:animal"/>

     <xs:element name="cat" type="ns1:cat"/>

...

   </xs:schema>

   <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 

      xmlns:tns="http://myanimals.com" 

      xmlns:ns1="http://myservice.com" 

      targetNamespace="http://myanimals.com" version="1.0">

 

      <xs:import namespace="http://myservice.com"/>

 

      <xs:element name="animal" type="tns:animal"/>

      <xs:complexType abstract="true" name="animal">

                <xs:sequence>

          <xs:element minOccurs="0" name="value" type="xs:string"/>

        </xs:sequence>

      </xs:complexType>

 

      <xs:complexType final="extension restriction" name="cat">

        <xs:complexContent>

          <xs:extension base="tns:mammal">

            <xs:sequence/>

          </xs:extension>

        </xs:complexContent>

      </xs:complexType>

      <xs:complexType abstract="true" name="mammal">

        <xs:complexContent>

          <xs:extension base="tns:animal">

            <xs:sequence/>

          </xs:extension>

        </xs:complexContent>

      </xs:complexType>

  </xs:schema>

</wsdl:types>

 

Any ideas on what I'm doing wrong?

 

Here is the message I'm trying to send:

 

<soapenv:Envelope 

xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 

xmlns:ser="http://myservice.com"

xmlns:ns1="http://myanimals.com" 

> 

   <soapenv:Header/>

   <soapenv:Body>

      <ser:animalRequest>

         <animals>

            <cat>

                <value>someValue</value>

            </cat>

            <cat>

                <value>someValue</value>

            </cat>

            </entities>

      </ser:animalRequest>

   </soapenv:Body>

</soapenv:Envelope>

 

I've also tried with ns1:cat and with ns1:cat/ns1:slug . The error
message is just slightly different in the namespace given, in that it
can't find it in the other namespace either.

 

Any ideas what I'm doing wrong?

Chris

 

 


Please consider the environment before printing this email.
 
This message should be regarded as confidential. If you have received this email in error
please notify the sender and destroy it immediately.
 
Statements of intent shall only become binding when confirmed in hard copy by an authorised
signatory. 
 
The contents of this email may relate to dealings with other companies under the control of
BAE Systems plc details of which can be found at http://www.baesystems.com/Businesses/index.htm.
 
Detica Limited is a BAE Systems company trading as BAE Systems Detica.
Detica Limited is registered in England and Wales under No: 1337451.
Registered office: Surrey Research Park, Guildford, Surrey, GU2 7YP, England.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message