You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Manjula Rathnayake <ma...@gmail.com> on 2012/01/03 07:42:47 UTC
How to access a custom property in the backend service implementation
Hi all,
I am trying to achieve the $Subject.
I tried out to set the custom property to message context using an
interceptor and access the property in service implementation.
But I could not access the message context inside the
'handleMessage(Message message)'. So I set the property using
message.setContextualProperty("CUSTOM_PROPERTY","Custom property value.").
But inside the service implementation I could not get the custom property
value using the following code.
@Resource
WebServiceContext wsc;
@WebMethod
public String hello(String echo) {
MessageContext messageContext = wsc.getMessageContext();
String customProperty= messageContext.get("CUSTOM_PROPERTY");
return echo;
}
So How can I set a custom property using an interceptor and access it
inside the service implementation?
Any help or suggestions are welcome.
Thank you.
Re: How to access a custom property in the backend service implementation
Posted by Manjula Rathnayake <ma...@gmail.com>.
Hi all,
Please point me any documents or sample code where an interceptor is used
to set a property in message context.
I found following link where it mentions that we do not have access to the
message context in an interceptor.
http://depressedprogrammer.wordpress.com/2007/07/31/cxf-ws-security-using-jsr-181-interceptor-annotations-xfire-migration/
If we do not have access to message context, is there any other option we
can set a property so that it is available in cxf service implementation?
Thank you.
On Tue, Jan 3, 2012 at 12:12 PM, Manjula Rathnayake
<ma...@gmail.com>wrote:
> Hi all,
>
> I am trying to achieve the $Subject.
>
> I tried out to set the custom property to message context using an
> interceptor and access the property in service implementation.
> But I could not access the message context inside the
> 'handleMessage(Message message)'. So I set the property using
> message.setContextualProperty("CUSTOM_PROPERTY","Custom property value.").
>
> But inside the service implementation I could not get the custom property
> value using the following code.
> @Resource
> WebServiceContext wsc;
>
> @WebMethod
> public String hello(String echo) {
> MessageContext messageContext = wsc.getMessageContext();
> String customProperty= messageContext.get("CUSTOM_PROPERTY");
> return echo;
> }
>
> So How can I set a custom property using an interceptor and access it
> inside the service implementation?
> Any help or suggestions are welcome.
>
> Thank you.
>
--
Manjula Rathnayaka
Department of Computer Science & Engineering,
University Of Moratuwa,
Moratuwa,
Sri Lanka.
Re: How to access a custom property in the backend service implementation
Posted by Manjula Rathnayake <ma...@gmail.com>.
Hi Daniel and Glen,
Thanks for information. I was able to get it work with your tip. I missed
the message.get()/put() operations.
Thank you.
On Wed, Jan 4, 2012 at 2:26 AM, Glen Mazza <gm...@talend.com> wrote:
> My ClientInterceptors.java file here: http://www.jroller.com/gmazza/**
> entry/jaxwshandlers_to_**cxfinterceptors<http://www.jroller.com/gmazza/entry/jaxwshandlers_to_cxfinterceptors>,
> has an example of reading a custom property from within an interceptor.
>
> HTH,
> Glen
>
>
> On 01/03/2012 02:45 PM, Daniel Kulp wrote:
>
>> The message itself is the context for the message. Thus, just call:
>>
>> message.setProperty("CUSTOM_**PROPERTY","Custom property value.");
>>
>> and then you can "get" it from the WebServiceContext via the same key.
>>
>> Dan
>>
>>
>> On Tuesday, January 03, 2012 12:12:47 PM Manjula Rathnayake wrote:
>>
>>> Hi all,
>>>
>>> I am trying to achieve the $Subject.
>>>
>>> I tried out to set the custom property to message context using an
>>> interceptor and access the property in service implementation.
>>> But I could not access the message context inside the
>>> 'handleMessage(Message message)'. So I set the property using
>>> message.setContextualProperty(**"CUSTOM_PROPERTY","Custom property
>>> value.").
>>>
>>> But inside the service implementation I could not get the custom property
>>> value using the following code.
>>> @Resource
>>> WebServiceContext wsc;
>>>
>>> @WebMethod
>>> public String hello(String echo) {
>>> MessageContext messageContext = wsc.getMessageContext();
>>> String customProperty= messageContext.get("CUSTOM_**
>>> PROPERTY");
>>> return echo;
>>> }
>>>
>>> So How can I set a custom property using an interceptor and access it
>>> inside the service implementation?
>>> Any help or suggestions are welcome.
>>>
>>> Thank you.
>>>
>>
>
> --
> Glen Mazza
> Talend Community Coders
> http://coders.talend.com
> blog: http://www.jroller.com/gmazza
>
>
--
Manjula Rathnayaka
Department of Computer Science & Engineering,
University Of Moratuwa,
Moratuwa,
Sri Lanka.
Re: How to access a custom property in the backend service implementation
Posted by Glen Mazza <gm...@talend.com>.
My ClientInterceptors.java file here:
http://www.jroller.com/gmazza/entry/jaxwshandlers_to_cxfinterceptors,
has an example of reading a custom property from within an interceptor.
HTH,
Glen
On 01/03/2012 02:45 PM, Daniel Kulp wrote:
> The message itself is the context for the message. Thus, just call:
>
> message.setProperty("CUSTOM_PROPERTY","Custom property value.");
>
> and then you can "get" it from the WebServiceContext via the same key.
>
> Dan
>
>
> On Tuesday, January 03, 2012 12:12:47 PM Manjula Rathnayake wrote:
>> Hi all,
>>
>> I am trying to achieve the $Subject.
>>
>> I tried out to set the custom property to message context using an
>> interceptor and access the property in service implementation.
>> But I could not access the message context inside the
>> 'handleMessage(Message message)'. So I set the property using
>> message.setContextualProperty("CUSTOM_PROPERTY","Custom property value.").
>>
>> But inside the service implementation I could not get the custom property
>> value using the following code.
>> @Resource
>> WebServiceContext wsc;
>>
>> @WebMethod
>> public String hello(String echo) {
>> MessageContext messageContext = wsc.getMessageContext();
>> String customProperty= messageContext.get("CUSTOM_PROPERTY");
>> return echo;
>> }
>>
>> So How can I set a custom property using an interceptor and access it
>> inside the service implementation?
>> Any help or suggestions are welcome.
>>
>> Thank you.
--
Glen Mazza
Talend Community Coders
http://coders.talend.com
blog: http://www.jroller.com/gmazza
Re: How to access a custom property in the backend service implementation
Posted by Daniel Kulp <dk...@apache.org>.
The message itself is the context for the message. Thus, just call:
message.setProperty("CUSTOM_PROPERTY","Custom property value.");
and then you can "get" it from the WebServiceContext via the same key.
Dan
On Tuesday, January 03, 2012 12:12:47 PM Manjula Rathnayake wrote:
> Hi all,
>
> I am trying to achieve the $Subject.
>
> I tried out to set the custom property to message context using an
> interceptor and access the property in service implementation.
> But I could not access the message context inside the
> 'handleMessage(Message message)'. So I set the property using
> message.setContextualProperty("CUSTOM_PROPERTY","Custom property value.").
>
> But inside the service implementation I could not get the custom property
> value using the following code.
> @Resource
> WebServiceContext wsc;
>
> @WebMethod
> public String hello(String echo) {
> MessageContext messageContext = wsc.getMessageContext();
> String customProperty= messageContext.get("CUSTOM_PROPERTY");
> return echo;
> }
>
> So How can I set a custom property using an interceptor and access it
> inside the service implementation?
> Any help or suggestions are welcome.
>
> Thank you.
--
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com