You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Steffen Krause <ki...@gmail.com> on 2012/06/08 15:44:18 UTC

JAXBDataBinding not picked up for

Hi,

This is my first post and I hope I'm not asking something that has been
beaten to death in earlier threads so please apologize if I violate any
rules.

I have the following problem:

My project depends on a JAR that contains a class, which handles the Web
Service invocation. More specific, this is how it invokes the client:

...
URL serviceURL = new URL("http://dev.host.com/myapp/myservice?wsdl");
QName serviceQName = new QName("urn:my:namespace:test", "MyService");
...
Service service = Service.create(serviceURL, serviceQName);
servicePort = service.getPort(MyServiceSEI.class);
SomethingResponse response = servicePort.doSomething(somethingRequest);
...

Now the "somethingRequest" object is a JAXB annotated class that is
provided together with the MyServiceSEI class in the same package. However
the SomethingRequest class allows for externally defined JAXB annotated
objects to be be set. Of course the JAXBContext will not know the
externally defined classes during the marshalling process and throws an
exception. To solve the issue I created a cxf.xml with the following client
configuration and added it to the META-INF of my main application (not the
JAR that contains the client):

...
<jaxws:client name="{urn:my:namespace:test}MyPort" createdFromAPI="true">
   <jaxws:dataBinding>
      <bean class="org.apache.cxf.jaxb.JAXBDataBinding">
         <property name="ExtraClass">
            <list>
               <value>com.my.external.package.binding.ObjectFactory</value>
            </list>
         </property>
      </bean>
   </jaxws:dataBinding>
</jaxws:client>
...

After building, deploying, and testing I still have the exception that
states that the externally defined class is not part of the JAXBContext.

What am I missing/doing wrong?

Thanks,

Steffen

Re: JAXBDataBinding not picked up for

Posted by Daniel Kulp <dk...@apache.org>.
Usually this issue is cause by a miss-match between the port name and what's 
in the config.  In most cases this is due to missing metadata in the 
@WebServcie annotation of  the SEI causing default names to be created which 
don't match.

You COULD try:
service.getPort(portQname, MyServiceSEI.class);

instead and pass the exact qname in that matches what's in your config.   
Another option could be to use the JaxWsProxyFactoryBean instead:


JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setWsdlLocation(wsdlLocation);
factory.setDataBinding(new JAXBDataBinding(.....));
....
factory.create(MyServiceSEI.class);


Dan



On Friday, June 08, 2012 09:44:18 AM Steffen Krause wrote:
> Hi,
> 
> This is my first post and I hope I'm not asking something that has been
> beaten to death in earlier threads so please apologize if I violate any
> rules.
> 
> I have the following problem:
> 
> My project depends on a JAR that contains a class, which handles the Web
> Service invocation. More specific, this is how it invokes the client:
> 
> ...
> URL serviceURL = new URL("http://dev.host.com/myapp/myservice?wsdl");
> QName serviceQName = new QName("urn:my:namespace:test", "MyService");
> ...
> Service service = Service.create(serviceURL, serviceQName);
> servicePort = service.getPort(MyServiceSEI.class);
> SomethingResponse response = servicePort.doSomething(somethingRequest);
> ...
> 
> Now the "somethingRequest" object is a JAXB annotated class that is
> provided together with the MyServiceSEI class in the same package. However
> the SomethingRequest class allows for externally defined JAXB annotated
> objects to be be set. Of course the JAXBContext will not know the
> externally defined classes during the marshalling process and throws an
> exception. To solve the issue I created a cxf.xml with the following
> client configuration and added it to the META-INF of my main application
> (not the JAR that contains the client):
> 
> ...
> <jaxws:client name="{urn:my:namespace:test}MyPort" createdFromAPI="true">
>    <jaxws:dataBinding>
>       <bean class="org.apache.cxf.jaxb.JAXBDataBinding">
>          <property name="ExtraClass">
>             <list>
>               
> <value>com.my.external.package.binding.ObjectFactory</value> </list>
>          </property>
>       </bean>
>    </jaxws:dataBinding>
> </jaxws:client>
> ...
> 
> After building, deploying, and testing I still have the exception that
> states that the externally defined class is not part of the JAXBContext.
> 
> What am I missing/doing wrong?
> 
> Thanks,
> 
> Steffen
-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com