Glen,
On Saturday 01 May 2010 10:46:06 am Glen Mazza wrote:
> Hello, I recently blogged an example[1] of setting (from the client) and
> reading (from the web service provider) MessageContext properties that
> could be read by the jax-ws handlers or created by the handlers,
> respectively:
>
> SOAP client:
> ((BindingProvider) port).getRequestContext().put("MAX_VALUE", "200");
>
> web service:
> @Resource
> private WebServiceContext context;
> ...
> context.getMessageContext().get("termOne"));
>
>
> I'd like to do the same for an Interceptor-based implemention, where the
> client would set a property for a interceptor Message object that would be
> readable by client-side interceptors, and the web service provider could
> read a message property that was created by a service-side interceptor. I
> can see how to get/set properties from within the interceptors, as they are
> passed in a Message property they can work with, but am not sure how (or
> even if) the client- and service-side endpoints can add/read property
> values to/from a Message object as you can with JAX-WS handlers--in other
> words, how do they get access to a Message object so they can add/read
> properties to/from it?
Pretty much exactly the same way. Anything set on the Message as a property
is available via the normal WebServiceContext in the service. Anything set
via the RequestContext is available in an interceptor on the client via the
Message.
> Also, do interceptor Message properties offer a scoping attribute, similar
> to the JAX-WS handler scoping concept of HANDLER/APPLICATION scope, where
> properties with the latter scope can be subsequently read by the (client or
> service) endpoint but those of the former can be read by the handlers only?
Not really. You could grab the Map<String, Scope> from the message in the
interceptor via:
msg.get("org.apache.cxf.jaxws.context.WrappedMessageContext.SCOPES")
which is where the JAX-WS scopes are recorded. You can add your own entries
and such there if you really wanted to.
Dan
> I couldn't see any from the Javadocs, but just wanted to confirm.
>
> Thanks,
> Glen
>
> [1] http://www.jroller.com/gmazza/entry/jaxws_handler_tutorial
--
Daniel Kulp
[email protected]
http://dankulp.com/blog