Hi all,
I'm trying to use the JAX-RS WebClient to deserialise some xml but I'm
running into a problem with the namespace that is being specified by
the web service I'm consuming.
I have an entity:
@XmlRootElement(name = "profile")
@XmlType(propOrder = { "title", "firstName", "middleName" })
public class ProfileEntity {
private String title;
private String firstName;
private String middleName;
//Getters and Setters without annotations
}
My code to consume this looks as follows:
WebClient client = WebClient.create(url);
ProfileEntity profileEntity = webClient.path(serviceURL).accept(
"application/xml").get(ProfileEntity.class);
This works perfectly if I consume a dummy web service (producing plain
xml, no namespace),however the real web service produces xml thats
looks like this:
<profile
xmlns="http://site.com/1.0-SNAPSHOT/GuestProfile.xsd"
xsi:schemaLocation="http://site.com/1.0-SNAPSHOT/GuestProfile.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<title>Mr.</title>
<firstName>Darrin</firstName>
<middleName> </middleName>
</profile>
The inclusion of the xmlns attribute causes the following error:
0:02:58 WARN (AbstractJAXBProvider.java:530) -
javax.xml.bind.UnmarshalException: unexpected element
(uri:"http://nsite.com/1.0-SNAPSHOT/GuestProfile.xsd",
local:"profile"). Expected elements are <{}profile>
at
com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:642)
at
com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:254)
at
com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:249)
I have trawled through mail archives and tried the following on the
webclient but it doesn't make a difference
ClientConfiguration config = WebClient.getConfig(webClient);
config.getRequestContext().put("set-jaxb-validation-event-handler", "false");
I would be most grateful if someone could either tell me how I can
configure cxf to ignore the xmlns or how I can modify my ProfileEntity
to be properly representative of the xml that I'm trying to consume.
I'm using cxf 2.2.7
Thanks,
Ian