Reputation: 22847
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 {}?
Upvotes: 8
Views: 61461
Reputation: 327
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>
Upvotes: 3
Reputation: 9868
@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)
Upvotes: 3
Reputation: 919
Sometimes you have to specify the names used in the wsdl (case sensitive): <{Log}>, <{} CrewId>, <{} OrderID>, <{} OrderNumber>
@XmlElement(name = "CrewId")
protected String crewId;
@XmlElement(name = "OrderID ")
protected String orderID;
@XmlElement(name = "Login")
protected String login;
@XmlElement(name = "OrderNumber")
protected String orderNumber;
Upvotes: -2
Reputation: 1151
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
Upvotes: 22
Reputation: 1070
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.
Upvotes: 15