You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Milisic Aleksandar <ac...@yahoo.com.au> on 2010/09/01 09:27:28 UTC

XML/HTTP with NO namespaces!

Hi,
 
I am trying to consume an XML over HTTP service which does not understand the 
concept of namespaces and I am using the JaxWsProxyFactoryBean class for that. 
Also, the names of fields of both request and response can be identical.
The default binding implementation relies on the JAXB framework and the 
framework cannot expose a web service properly (the factory.create() throws an 
exception “Two classes have the same XML type name "{http://company.blabla 
/}individual-nameType". Use @XmlType.name and @XmlType.namespace to assign 
different names to them at this point 
JAXBContext.newInstance(classes.toArray(new Class[classes.size()]), map);) 
unless I specify namespaces to calm down JAXB.
 
 
Could anyone possibly recommend the desirable approach:
 
1.      Create a custom interception which would erase namespace specific 
information before the request gets submitted along the chain.
2.      Create a custom DataBinging class and inherit it from 
AbstractDataBinding
3.      Do anything else to get it done.
 
Any suggestion would be greatly appreciated.

Kind regards,

Aleks


      

Re: XML/HTTP with NO namespaces!

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

Is it a soap-based service or just some custom XML which is coming back ?
If it is the latter then you might want to try using CXF WebClient instead
and register a custom
JAXBProvider configured to add/remove namespaces or have certain names
changed for the JAXB (un)marshalling
to succeed.

Some info is here
http://cxf.apache.org/docs/jax-rs.html#JAX-RS-CustomizingJAXBXMLandJSONinputandoutput
.

Option 1 which you mentioned is probably also worth a try

cheers, Sergey


On Wed, Sep 1, 2010 at 8:27 AM, Milisic Aleksandar <
aco_trebinje@yahoo.com.au> wrote:

> Hi,
>
> I am trying to consume an XML over HTTP service which does not understand
> the
> concept of namespaces and I am using the JaxWsProxyFactoryBean class for
> that.
> Also, the names of fields of both request and response can be identical.
> The default binding implementation relies on the JAXB framework and the
> framework cannot expose a web service properly (the factory.create() throws
> an
> exception “Two classes have the same XML type name "{http://company.blabla
> /}individual-nameType". Use @XmlType.name and @XmlType.namespace to assign
> different names to them at this point
> JAXBContext.newInstance(classes.toArray(new Class[classes.size()]), map);)
> unless I specify namespaces to calm down JAXB.
>
>
> Could anyone possibly recommend the desirable approach:
>
> 1.      Create a custom interception which would erase namespace specific
> information before the request gets submitted along the chain.
> 2.      Create a custom DataBinging class and inherit it from
> AbstractDataBinding
> 3.      Do anything else to get it done.
>
> Any suggestion would be greatly appreciated.
>
> Kind regards,
>
> Aleks
>
>
>
>

Re: XML/HTTP with NO namespaces!

Posted by Daniel Kulp <dk...@apache.org>.
With the JAX-WS related things, there really is not a way to do it.   Per 
spec, if a namespace is not specified, we have to map the package into the 
namespace and set that on the schema.   Thus, the resulting XML would at least 
have the root node qualified.    That would be proper per spec.

You could "fake" it by writing an interceptor that would wrapper the 
XMLStreamReader and strip off the namespace (or add it for a POST to make it 
match the expected input), but not really "per spec".

For the JAX-RS stuff, the rules are different and Sergey's response would 
point to the correct location.

Dan


On Wednesday 01 September 2010 3:27:28 am Milisic Aleksandar wrote:
> Hi,
> 
> I am trying to consume an XML over HTTP service which does not understand
> the concept of namespaces and I am using the JaxWsProxyFactoryBean class
> for that. Also, the names of fields of both request and response can be
> identical. The default binding implementation relies on the JAXB framework
> and the framework cannot expose a web service properly (the
> factory.create() throws an exception “Two classes have the same XML type
> name "{http://company.blabla /}individual-nameType". Use @XmlType.name and
> @XmlType.namespace to assign different names to them at this point
> JAXBContext.newInstance(classes.toArray(new Class[classes.size()]), map);)
> unless I specify namespaces to calm down JAXB.
> 
> 
> Could anyone possibly recommend the desirable approach:
> 
> 1.      Create a custom interception which would erase namespace specific
> information before the request gets submitted along the chain.
> 2.      Create a custom DataBinging class and inherit it from
> AbstractDataBinding
> 3.      Do anything else to get it done.
> 
> Any suggestion would be greatly appreciated.
> 
> Kind regards,
> 
> Aleks

-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog