Hi

On Sun, Jul 18, 2010 at 12:22 PM, Ian Petzer <[email protected]> wrote:

> Thanks,
>
> I just posted my solution specifying the namespace in the annotations.
>
> I am curious though if there is a way to ignore the default namespace
> when consuming the xml?
>
>
You might want to try adding a customized JAXBElementProvider, when creating
WebClient. This provider can use either
inElementsMap property, have a custom XmlStreamReader created, see [1] for
more info

Unfortunately, with inElementsMap, you'll need to specify all the elements
in a given XML instance if a default namespace is used, ex :
{http://somenamespace}profile : ptofile
 {http://somenamespace}title : title

etc,

One can also do :

 {http://somenamespace}* : {http://other}*

when namespaces have to be changed as opposed to dropped, but you may try

 {http://somenamespace}* : {}*

and may be it will work - I;m just not sure the support for wildcards is
available in 2.2.7

cheers, Sergey

[1]
http://cxf.apache.org/docs/jax-rs.html#JAX-RS-CustomizingJAXBXMLandJSONinputandoutput


>  On Sun, Jul 18, 2010 at 12:18 PM, Aleksei Valikov
> <[email protected]> wrote:
> > Hi,
> >
> >> 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);
> >
> > You class does not have namespace annotations. Either add namespace
> > into your @Xml... annotations or @XmlSchema/@XmlNs in your
> > package-info.
> >
> > Bye.
> > /lexi
> >
>

Reply via email to