You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Tobias Mahlmann <t....@gmail.com> on 2014/10/01 15:25:42 UTC

camel-cxf: Generic Service Endpoint Interface

HI list,
I'm currently trying to get familiar with cxf/camel/servicemix and maybe
someone here has some input on this:
I have a web service that I'm trying to consume with camel-cxf. The web
service works fine, but I'm having trouble with the 
Service Endpoint Interface. I set up the cxfEndpoint via spring as follows:
	<cxf:cxfEndpoint id="cxfEndpoint
		address="http://localhost:8080/MyServlet/services/MyService"
		serviceClass="my.package.MyInterface"
		serviceName="s:MyService" 
	
wsdlURL="http://localhost:8080/MyServlet/services/MyService?wsdl"
		endpointName="s:MyService" xmlns:s="http://my.package">
	</cxf:cxfEndpoint>

The tricky thing is, MyInterface resp. the webservice itself extends a
generic interface:
public interface MyInterface extends MyGenericInterface<A,B> { ..}
and
public MyGenericInterface<U,V>{
	U foo(V bar);
}

This will generate the following error:
javax.xml.bind.UnmarshalException: unexpected element
(uri:"http://my.package", local:"fooReturn"). Expected elements are (none)
	at
com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.handl
eEvent(UnmarshallingContext.java:647)[:1.7.0_21]

Now, if I either change MyInterface to 

MyInterface {
	A foor(B bar);
}
or make MyGenericInterface non-generic:

public interface MyInterface extends MyGenericInterface{ ..}
and
public MyGenericInterface{
	A foo(B bar);
}

everything works fine. I guess, I could inspect the Interface myself, deal
with generic parameters, omit it from the endpoint definition, set the
endpoint to PAYLOAD and deal with the cxfPayload/SOAP envelopes myself, but
I'd rather not re-invent the wheel if possible.

Am I missing something? Any comments appreciated.

Tobias


Re: camel-cxf: Generic Service Endpoint Interface

Posted by Aki Yoshida <el...@gmail.com>.
I am wondering you can simply use the transform feature of CXF to
remove the extra element that you want to drop.
http://cxf.apache.org/docs/transformationfeature.html#TransformationFeature-Droppingoutputandinputelements.

2014-10-01 15:25 GMT+02:00 Tobias Mahlmann <t....@gmail.com>:
> HI list,
> I'm currently trying to get familiar with cxf/camel/servicemix and maybe
> someone here has some input on this:
> I have a web service that I'm trying to consume with camel-cxf. The web
> service works fine, but I'm having trouble with the
> Service Endpoint Interface. I set up the cxfEndpoint via spring as follows:
>         <cxf:cxfEndpoint id="cxfEndpoint
>                 address="http://localhost:8080/MyServlet/services/MyService"
>                 serviceClass="my.package.MyInterface"
>                 serviceName="s:MyService"
>
> wsdlURL="http://localhost:8080/MyServlet/services/MyService?wsdl"
>                 endpointName="s:MyService" xmlns:s="http://my.package">
>         </cxf:cxfEndpoint>
>
> The tricky thing is, MyInterface resp. the webservice itself extends a
> generic interface:
> public interface MyInterface extends MyGenericInterface<A,B> { ..}
> and
> public MyGenericInterface<U,V>{
>         U foo(V bar);
> }
>
> This will generate the following error:
> javax.xml.bind.UnmarshalException: unexpected element
> (uri:"http://my.package", local:"fooReturn"). Expected elements are (none)
>         at
> com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.handl
> eEvent(UnmarshallingContext.java:647)[:1.7.0_21]
>
> Now, if I either change MyInterface to
>
> MyInterface {
>         A foor(B bar);
> }
> or make MyGenericInterface non-generic:
>
> public interface MyInterface extends MyGenericInterface{ ..}
> and
> public MyGenericInterface{
>         A foo(B bar);
> }
>
> everything works fine. I guess, I could inspect the Interface myself, deal
> with generic parameters, omit it from the endpoint definition, set the
> endpoint to PAYLOAD and deal with the cxfPayload/SOAP envelopes myself, but
> I'd rather not re-invent the wheel if possible.
>
> Am I missing something? Any comments appreciated.
>
> Tobias
>