Hi
Contexts do not work on the client side...
You can probably use
UriBuilder.fromUri("/").path(RegistrationService.class).path(registrationMethod).toUri();
where registrationMethod is a java Method. May be it's simpler to write a
reflection code yourself :-).
You can also do it the CXF specific way.
1.Use JAXRSClientFactoryBean for creating the proxy, ex,
JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
bean.setAddress("http://localhost");
RegistrationService proxy = bean.create(RegistrationService.class);
and then do
2. List<ClassResourceInfo> list =
bean.getServiceFactory().getClassResourceInfo();
this represents a list of resources such as RegistrationService.
ClassResourceInfo gives you a list of
OperationResourceInfo and thus you can find the actual Path values...
Also you can probably do
this.client = WebClient.fromClient(this.service, true);
WebClient.client(proxy) is a utility that just casts a proxy to Client so
that proxies can modify their headers, check responses, etc.
WebClient.fromClient(this.service, true); will create the WebClient which is
a Client and the 'true' flag will ensure the headers such as Accept and
Content-Type discovered during the proxy creation are copied across
Hope it helps, Sergey
On Tue, Jan 4, 2011 at 1:34 PM, Glen Mazza <[email protected]> wrote:
> I think UriInfo.getPath() (do no via @javax.ws.rs.core.Context) is what
> you're looking for.
>
> Glen
>
>
> On 04.01.2011 02:29, mike wrote:
>
>> Hi,
>>
>> is it possible to get the value of a @Path annotation in the cxf client?
>>
>> What i have is:
>>
>> Webservice Interface:
>> @Path("/RegistrationService")
>> @Consumes( { "application/xml" })
>> @Produces( { "application/xml" })
>> public interface RegistrationService {
>>
>> @POST
>> @Path("/user/register")
>> public void register(RegistrationData registrationData);
>> }
>>
>> Client-Side Implementation:
>> public class RegistrationServiceImpl implements RegistrationService {
>>
>> private RegistrationService service;
>> private Client client;
>>
>> public RegistrationServiceImpl() {
>>
>> // create proxy
>> this.service = JAXRSClientFactory.create("http://localhost
>> ",
>> RegistrationService.class);
>>
>> // convert proxy to client (acts then like a browser)
>> this.client =
>>
>> WebClient.client(this.service).accept(MediaType.APPLICATION_XML).type(MediaType.APPLICATION_XML);
>>
>> }
>>
>> @Override
>> public void register(final RegistrationData registrationData) {
>>
>> String path = ??? // path should be "/user/register"
>>
>> registrationData.setMessageId(createMessageId(path,
>> registrationData.getMail()));
>>
>> this.service.register(registrationData);
>>
>> }
>> }
>>
>> does cxf offer a way to get that path value or do i have to get it with
>> reflection?
>>
>> Thanks in advance
>> mike
>>
>
>
> --
>
> Glen Mazza
> gmazza at apache dot org
> http://www.jroller.com/gmazza
>