You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Eduard Hildebrandt <ma...@eduard-hildebrandt.de> on 2012/10/09 15:47:30 UTC
@Path and @PathParam with proxy-based client
Hi guys,
I have a JAXRS service with an interface which is shared by client and
server code. For example:
@Path("/myservice/{a}/{b}/")
public interface MyService {
@POST
@Path("doSomething")
ObjectY doSomething(ObjectX x);
}
On the server-side we use Jersey and the implementations look like this:
@Path("/myservice/{a}/{b}/")
public class MyServiceImpl implements MyService {
@PathParam("a")
private String a;
@PathParam("b")
private String b;
public ObjectY doSomething(ObjectX x) {
return new ObjectY(a, b, x);
}
}
I’d like to use CXF. I created a proxy-based CXF client from the interface.
But how can I set the path-params “a” and “b”?
I could change the interface signature to:
@POST
@Path("doSomething")
public ObjectY doSomething(@PathParam(“a”) String a, @PathParam(“b”) String
b, ObjectX x);
But unfortunately this is not an option. I’m not allowed to change this
interface.
Do you have any ideas how I can solve this issue?
Your help is highly appreciated!
Many greetings from Munich.
Best regards,
Eduard Hildebrandt
Re: @Path and @PathParam with proxy-based client
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Eduard
On 09/10/12 16:07, Eduard Hildebrandt wrote:
> Hi Sergey,
>
> your solution works. Thank you very much.
>
> I would like to show you my appreciation. Please let me know if I can
> buy you a book or DVD at Amazon or send you some money via PayPal.
>
That is very kind of you, thanks. But I guess it's just a lucky case
that this specific case was addressed awhile back (after a specific
feedback) :-) and there could be few bugs lurking there :-).
Hope we can have a chat and few pints at one of the conferences in
Germany, I'm feeling really unfortunate now that I can't make it to
Apache EU :-)
Cheers, Sergey
> Best regards,
>
> Eduard
>
>
>
> Please try JAXRSClientFactory.create(__address, MyService.class,
> null, aValue, bValue);
>
> where 'null' is set for (Spring) configuration resource, I had to
> add this extra parameter to this factory method to avoid various
> overloading issues.
>
> Alternatively:
>
> JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
> bean.setAddress(address);
> bean.setServiceClass(__MyService.class);
>
> MyService proxy = bean.create(MyService.class, aValue, bValue);
>
> That should do it, give it a try please
>
> Thanks, Sergey
>
Re: @Path and @PathParam with proxy-based client
Posted by Eduard Hildebrandt <ma...@eduard-hildebrandt.de>.
Hi Sergey,
your solution works. Thank you very much.
I would like to show you my appreciation. Please let me know if I can buy
you a book or DVD at Amazon or send you some money via PayPal.
Best regards,
Eduard
> Please try JAXRSClientFactory.create(**address, MyService.class, null,
> aValue, bValue);
>
> where 'null' is set for (Spring) configuration resource, I had to add this
> extra parameter to this factory method to avoid various overloading issues.
>
> Alternatively:
>
> JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
> bean.setAddress(address);
> bean.setServiceClass(**MyService.class);
>
> MyService proxy = bean.create(MyService.class, aValue, bValue);
>
> That should do it, give it a try please
>
> Thanks, Sergey
>
>
Re: @Path and @PathParam with proxy-based client
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Eduard
On 09/10/12 14:47, Eduard Hildebrandt wrote:
> Hi guys,
>
>
> I have a JAXRS service with an interface which is shared by client and
> server code. For example:
>
>
> @Path("/myservice/{a}/{b}/")
> public interface MyService {
> @POST
> @Path("doSomething")
> ObjectY doSomething(ObjectX x);
> }
>
>
> On the server-side we use Jersey and the implementations look like this:
>
>
> @Path("/myservice/{a}/{b}/")
> public class MyServiceImpl implements MyService {
>
>
> @PathParam("a")
> private String a;
> @PathParam("b")
> private String b;
>
>
> public ObjectY doSomething(ObjectX x) {
> return new ObjectY(a, b, x);
> }
> }
>
>
> I’d like to use CXF. I created a proxy-based CXF client from the interface.
> But how can I set the path-params “a” and “b”?
>
>
> I could change the interface signature to:
>
>
> @POST
> @Path("doSomething")
> public ObjectY doSomething(@PathParam(“a”) String a, @PathParam(“b”) String
> b, ObjectX x);
>
>
> But unfortunately this is not an option. I’m not allowed to change this
> interface.
>
> Do you have any ideas how I can solve this issue?
>
> Your help is highly appreciated!
>
Please try JAXRSClientFactory.create(address, MyService.class, null,
aValue, bValue);
where 'null' is set for (Spring) configuration resource, I had to add
this extra parameter to this factory method to avoid various overloading
issues.
Alternatively:
JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
bean.setAddress(address);
bean.setServiceClass(MyService.class);
MyService proxy = bean.create(MyService.class, aValue, bValue);
That should do it, give it a try please
Thanks, Sergey
>
> Many greetings from Munich.
>
>
> Best regards,
>
>
> Eduard Hildebrandt
>