CXF: Unmarshalling error: unexpected elements, what {} means?

55,085

Solution 1

Have you noted space between OrderID and '>'? Expected is <{}OrderID > and you send "OrderID". Check if you don't have spaces in your element names.

Solution 2

Have you noted space between OrderID and '>'? Expected is <{}OrderID > and you send >"OrderID". Check if you don't have spaces in your element names.

While the above answer from Stepan Vihor helped you get what you needed, let me answer your question of what the "{}" means:

It means that the JAX-B Unmarshaller is expecting your OrderID element to have no namespace, i.e. the namespace uri for that element needs to be equal to "".

See here for a brief intro on XML Namespaces

Solution 3

@icyitscold, the comment I want to add from my experience is that you can change the elementFormDefault to "qualified" as elementFormDefault="qualified" in xs:schema element. The namespace will be qualified by default.

That's for the WSDL-first approach, if you use code-first approach, you may consider add the change as

@javax.xml.bind.annotation.XmlSchema( attributeFormDefault = javax.xml.bind.annotation.XmlNsForm.UNQUALIFIED, elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)

Solution 4

I got same error,

javax.xml.ws.soap.SOAPFaultException: Unmarshalling Error: unexpected element (uri:"", local:"country"). Expected elements are <{}seconds>,<{}month>,<{}hour>,<{}year>,<{}minutes>,<{}day>

Then I find on the web service side the response type added a new property 'country'.

To ignore the new added property, add following propertys in 'jaxws:client' setting.

<jaxws:client id="abc"
              serviceClass="someClass"
              address="url">
    <jaxws:properties>
        <entry key="schema-validation-enabled" value="false"/>
        <entry key="set-jaxb-validation-event-handler" value="false"/>
    </jaxws:properties>
</jaxws:client>
Share:
55,085
Danubian Sailor
Author by

Danubian Sailor

I prefer to be anonymouse.

Updated on January 25, 2020

Comments

  • Danubian Sailor
    Danubian Sailor over 4 years

    I get error while connecting to my web service:

    javax.xml.ws.soap.SOAPFaultException: Unmarshalling Error: unexpected element (uri:"", local:"OrderID"). Expected elements are <{}Login>,<{}CrewId>,<{}OrderID >,<{}OrderNumber >

    Service is exposed using org.apache.cxf.transport.servlet.CXFServlet and jaxws:endpoint annotation. The client is generated using CXF. Firstly, suprising for me is that I'm using the same technology on both ends and the solution is not working, secondly, this mysterious {} in error messages.

    So, what is wrong and how to understand this {}?