You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Alessio Soldano <as...@redhat.com> on 2009/11/12 18:11:49 UTC
On MessageContext properties retrieval in handlers
Hi,
I'm currently trying to get MessageContext.WSDL_OPERATION property value
from the MessageContext passed in JAX-WS handlers. This is basically
what was described in https://issues.apache.org/jira/browse/CXF-1698 .
It's not clear to me whether any change was actually made for that
issue, but basically I think that's not working yet and I'm wondering if
you would be fine with me setting the property above (as well as the
WSDL_SERVICE, WSDL_INTERFACE, etc.) in the SOAPHandlerInInterceptor just
before starting dealing with the jaxws handlers. That of course would be
done only when the current exchange already has the current
OperationInfo, calling a method similar to what is currently in
RPCInInterceptor (which runs after the jaxws handlers and currently sets
those props only when getting the operation from its own private
getOperation(..) method):
private void setMessage(Message message,
BindingOperationInfo operation) {
Exchange ex = message.getExchange();
ex.put(BindingOperationInfo.class, operation);
ex.put(OperationInfo.class, operation.getOperationInfo());
ex.setOneWay(operation.getOperationInfo().isOneWay());
//Set standard MessageContext properties required by JAX_WS, but
not specific to JAX_WS.
message.put(Message.WSDL_OPERATION, operation.getName());
ServiceInfo si = operation.getBinding().getService();
QName serviceQName = si.getName();
message.put(Message.WSDL_SERVICE, serviceQName);
QName interfaceQName = si.getInterface().getName();
message.put(Message.WSDL_INTERFACE, interfaceQName);
EndpointInfo endpointInfo =
ex.get(Endpoint.class).getEndpointInfo();
QName portQName = endpointInfo.getName();
message.put(Message.WSDL_PORT, portQName);
URI wsdlDescription = endpointInfo.getProperty("URI", URI.class);
if (wsdlDescription == null) {
String address = endpointInfo.getAddress();
try {
wsdlDescription = new URI(address + "?wsdl");
} catch (URISyntaxException e) {
//do nothing
}
endpointInfo.setProperty("URI", wsdlDescription);
}
message.put(Message.WSDL_DESCRIPTION, wsdlDescription);
}
This would basically allow jaxws handlers to access those properties in
most of the cases.
Cheers
Alessio
--
Alessio Soldano
Web Service Lead, JBoss
Re: On MessageContext properties retrieval in handlers
Posted by Daniel Kulp <dk...@apache.org>.
On Thu November 12 2009 12:49:41 pm Alessio Soldano wrote:
> Yep, this makes sense to me, this was the other idea I had, just though
> it was excluded from the beginning.
Just a little history about this that I mentioned on IRC, but thought everyone
might benefit from hearing about.
Long long ago, we completely used a "push" model for the JAX-WS context.
Before entering any handler and before invoking the service, we would walk
through all the message properties and map them to the required JAX-WS
properties. On the way out of the handlers/service, we would walk through
all the properties again and map them back into cxf properties. This was
done for EVERY invokation, even if the service didn't use the context or
anything. After some profiling, we discovered this was a measurable amount
of time being spent (like 5% for a "echoString" type service). In the 2.1
timeframe, we did some performance work and one of the things that was done
was to start making the jaxws context a "pull" thing. The JAX-WS context
wrappers the message/exchange and on every put/get, we do the mapping to/from
cxf values.
With this way of doing it, the hit is ONLY done when the context is actually
used and ONLY for the keys that are actually requested/used. For 90% of the
time when the context is not used, the only hit is the creation of the wrapper
object (very very minor).
What you are running into is a case where not ALL of the "push" things were
remapped into pulls. Definitely worth fixing to avoid the extra processing
that doesn't really need to be done.
Dan
> Daniel Kulp wrote:
> > Note: if you make the change to WrappedMessageContext such that if it is
> > "null" on the exchange already, then do the above, I'd be happy to merge
> > that back to 2.2.x. The removal of the stuff from Message.java would
> > need to be a migration guide thing for 2.3.
>
> I created https://issues.apache.org/jira/browse/CXF-2532 , looking at
> that tomorrow.
> Thanks
> Alessio
>
--
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog
Re: On MessageContext properties retrieval in handlers
Posted by Alessio Soldano <as...@redhat.com>.
Yep, this makes sense to me, this was the other idea I had, just though
it was excluded from the beginning.
Daniel Kulp wrote:
> Note: if you make the change to WrappedMessageContext such that if it is
> "null" on the exchange already, then do the above, I'd be happy to merge that
> back to 2.2.x. The removal of the stuff from Message.java would need to be
> a migration guide thing for 2.3.
>
I created https://issues.apache.org/jira/browse/CXF-2532 , looking at
that tomorrow.
Thanks
Alessio
--
Alessio Soldano
Web Service Lead, JBoss
Re: On MessageContext properties retrieval in handlers
Posted by Daniel Kulp <dk...@apache.org>.
Well, what I'd LIKE to do (slightly disruptive so would need to be fully done
on 2.3, not 2.2.x) is to NOT set them in the various XXXInInterceptor things
at all and remove those keys off of Message.java. Instead, since they
really are jaxws things, update WrappedMessageContext in jaxws to map those
keys to the appropriate exchange.get(BindingOperationInfo.class).getName() or
whatever.
95% of the time, those keys are not used so wasting time calculating them and
storing them on the message/exchange is really just a waste of processing
cycles.
Note: if you make the change to WrappedMessageContext such that if it is
"null" on the exchange already, then do the above, I'd be happy to merge that
back to 2.2.x. The removal of the stuff from Message.java would need to be
a migration guide thing for 2.3.
Does that make sense? (just trying to remove stuff that isn't needed most of
the time and make it an "on demand" kind of thing)
Dan
On Thu November 12 2009 12:11:49 pm Alessio Soldano wrote:
> Hi,
> I'm currently trying to get MessageContext.WSDL_OPERATION property value
> from the MessageContext passed in JAX-WS handlers. This is basically
> what was described in https://issues.apache.org/jira/browse/CXF-1698 .
> It's not clear to me whether any change was actually made for that
> issue, but basically I think that's not working yet and I'm wondering if
> you would be fine with me setting the property above (as well as the
> WSDL_SERVICE, WSDL_INTERFACE, etc.) in the SOAPHandlerInInterceptor just
> before starting dealing with the jaxws handlers. That of course would be
> done only when the current exchange already has the current
> OperationInfo, calling a method similar to what is currently in
> RPCInInterceptor (which runs after the jaxws handlers and currently sets
> those props only when getting the operation from its own private
> getOperation(..) method):
>
> private void setMessage(Message message,
> BindingOperationInfo operation) {
> Exchange ex = message.getExchange();
> ex.put(BindingOperationInfo.class, operation);
> ex.put(OperationInfo.class, operation.getOperationInfo());
> ex.setOneWay(operation.getOperationInfo().isOneWay());
>
> //Set standard MessageContext properties required by JAX_WS, but
> not specific to JAX_WS.
> message.put(Message.WSDL_OPERATION, operation.getName());
>
> ServiceInfo si = operation.getBinding().getService();
> QName serviceQName = si.getName();
> message.put(Message.WSDL_SERVICE, serviceQName);
>
> QName interfaceQName = si.getInterface().getName();
> message.put(Message.WSDL_INTERFACE, interfaceQName);
>
> EndpointInfo endpointInfo =
> ex.get(Endpoint.class).getEndpointInfo();
> QName portQName = endpointInfo.getName();
> message.put(Message.WSDL_PORT, portQName);
>
>
> URI wsdlDescription = endpointInfo.getProperty("URI", URI.class);
> if (wsdlDescription == null) {
> String address = endpointInfo.getAddress();
> try {
> wsdlDescription = new URI(address + "?wsdl");
> } catch (URISyntaxException e) {
> //do nothing
> }
> endpointInfo.setProperty("URI", wsdlDescription);
> }
> message.put(Message.WSDL_DESCRIPTION, wsdlDescription);
> }
>
> This would basically allow jaxws handlers to access those properties in
> most of the cases.
>
> Cheers
> Alessio
>
--
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog