You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by virajn <ma...@gmail.com> on 2014/04/11 09:58:20 UTC
Migrating to CXF with Jaxb from xfire with agesi
I'm migrating my xfire soap project which uses aegis for databinding to cxf
with jaxb. I got the new cxf project working for old xfire requests with
aegis binding. But when i move the databinding to jaxb unmarshalling errror
occurs.
This is my cxf web service definition.
<bean id="jaxbBean" class="org.apache.cxf.jaxb.JAXBDataBinding"
scope="prototype"/>
<bean id="jaxws-and-aegis-service-factory"
class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean"
scope="prototype">
<property name="dataBinding" ref="jaxbBean"/>
<property name="serviceConfigurations">
<list>
<bean
class="org.apache.cxf.jaxws.support.JaxWsServiceConfiguration"/>
<bean
class="org.apache.cxf.aegis.databinding.XFireCompatibilityServiceConfiguration"/>
<bean
class="org.apache.cxf.service.factory.DefaultServiceConfiguration"/>
</list>
</property>
</bean>
<jaxws:endpoint id="trace" address="/trace"
implementor="#traceImplBean">
<jaxws:serviceFactory>
<ref bean="jaxws-and-aegis-service-factory"/>
</jaxws:serviceFactory>
<jaxws:inInterceptors>
<bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
</jaxws:inInterceptors>
<jaxws:outInterceptors>
<bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
</jaxws:outInterceptors>
</jaxws:endpoint>
I used @XMLRootElement Annotaion on my DTOs as following.
@XmlRootElement(name = "context" )
public class Context implements Serializable {
private KeyValues keyValues;
.....
}
@XmlRootElement(name = "keyValues" )
public class KeyValues implements Serializable {
private String tag;
private String value;
....
}
One method which i tested generated following soap request for cxf
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:pay="http://example.project.com">
<soapenv:Header/>
<soapenv:Body>
<pay:trace>
<pay:context>
<keyValues>
<tag>tag</tag>
<value>value</value>
</keyValues>
</pay:context>
</pay:trace>
</soapenv:Body>
</soapenv:Envelope>
**HOWEVER** old xfire generate following request, I have mark the
difference.
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:pay="http://example.project.com" xmlns:api="http://example.com">
<soapenv:Header/>
<soapenv:Body>
<pay:trace>
<pay:context>
<api:keyValues>
***<api:KeyValues>***
<api:tag>tag</api:tag>
<api:value>value</api:value>
***</api:KeyValues>***
</api:keyValues>
</pay:context>
</pay:trace>
</soapenv:Body>
</soapenv:Envelope>
I got following exception when i tried to send xfire request to cxf service.
javax.xml.bind.UnmarshalException: unexpected element
(uri:"http://example.project.com", local:"keyValues"). Expected elements are
<{}keyValues>
So I think i need to add additional <KeyValues></KeyValues> tags to cxf
request inorder to compatible with xfire. Does anyone knows how to resolve
this ?
Thanks in advance.
--
View this message in context: http://cxf.547215.n5.nabble.com/Migrating-to-CXF-with-Jaxb-from-xfire-with-agesi-tp5742682.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: Migrating to CXF with Jaxb from xfire with agesi
Posted by Daniel Kulp <dk...@apache.org>.
JAXB, by default, uses unqualified elements whereas Aegis/XFire by default used qualified elements. Couple ways around that:
1) For every element, specify the namespace.
@XmlElement(name = "tag", namespace = "http:...")
likely easier:
2) Add a package-info.java with:
@javax.xml.bind.annotation.XmlSchema(namespace = "http://......", elementFormDefault = XmlNsForm.QUALIFIED)
The best option, if you need to be completely wire compatible, is to take the WSDL generated from the old service, run wsdl2java on it, and use the generated types. A bit more migration effort, but it’s definitely the best way to make sure it’s compatible.
Dan
On Apr 11, 2014, at 3:58 AM, virajn <ma...@gmail.com> wrote:
> I'm migrating my xfire soap project which uses aegis for databinding to cxf
> with jaxb. I got the new cxf project working for old xfire requests with
> aegis binding. But when i move the databinding to jaxb unmarshalling errror
> occurs.
>
> This is my cxf web service definition.
>
>
>
> <bean id="jaxbBean" class="org.apache.cxf.jaxb.JAXBDataBinding"
> scope="prototype"/>
>
> <bean id="jaxws-and-aegis-service-factory"
> class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean"
> scope="prototype">
> <property name="dataBinding" ref="jaxbBean"/>
> <property name="serviceConfigurations">
> <list>
> <bean
> class="org.apache.cxf.jaxws.support.JaxWsServiceConfiguration"/>
> <bean
> class="org.apache.cxf.aegis.databinding.XFireCompatibilityServiceConfiguration"/>
> <bean
> class="org.apache.cxf.service.factory.DefaultServiceConfiguration"/>
> </list>
> </property>
> </bean>
>
> <jaxws:endpoint id="trace" address="/trace"
> implementor="#traceImplBean">
> <jaxws:serviceFactory>
> <ref bean="jaxws-and-aegis-service-factory"/>
> </jaxws:serviceFactory>
> <jaxws:inInterceptors>
> <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
> </jaxws:inInterceptors>
> <jaxws:outInterceptors>
> <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
> </jaxws:outInterceptors>
> </jaxws:endpoint>
>
>
> I used @XMLRootElement Annotaion on my DTOs as following.
>
>
> @XmlRootElement(name = "context" )
> public class Context implements Serializable {
> private KeyValues keyValues;
> .....
> }
>
>
> @XmlRootElement(name = "keyValues" )
> public class KeyValues implements Serializable {
> private String tag;
> private String value;
> ....
> }
>
> One method which i tested generated following soap request for cxf
>
>
> <soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:pay="http://example.project.com">
> <soapenv:Header/>
> <soapenv:Body>
> <pay:trace>
> <pay:context>
> <keyValues>
> <tag>tag</tag>
> <value>value</value>
> </keyValues>
> </pay:context>
> </pay:trace>
> </soapenv:Body>
> </soapenv:Envelope>
>
>
> **HOWEVER** old xfire generate following request, I have mark the
> difference.
>
> <soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:pay="http://example.project.com" xmlns:api="http://example.com">
> <soapenv:Header/>
> <soapenv:Body>
> <pay:trace>
> <pay:context>
> <api:keyValues>
> ***<api:KeyValues>***
> <api:tag>tag</api:tag>
> <api:value>value</api:value>
> ***</api:KeyValues>***
> </api:keyValues>
> </pay:context>
> </pay:trace>
> </soapenv:Body>
> </soapenv:Envelope>
>
> I got following exception when i tried to send xfire request to cxf service.
>
> javax.xml.bind.UnmarshalException: unexpected element
> (uri:"http://example.project.com", local:"keyValues"). Expected elements are
> <{}keyValues>
> So I think i need to add additional <KeyValues></KeyValues> tags to cxf
> request inorder to compatible with xfire. Does anyone knows how to resolve
> this ?
>
> Thanks in advance.
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Migrating-to-CXF-with-Jaxb-from-xfire-with-agesi-tp5742682.html
> Sent from the cxf-user mailing list archive at Nabble.com.
--
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com