You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Jervis Liu (JIRA)" <ji...@apache.org> on 2006/12/20 09:25:22 UTC
[jira] Resolved: (CXF-319) Support for accessing message payload
from Logical handler when dispatch is used.
[ http://issues.apache.org/jira/browse/CXF-319?page=all ]
Jervis Liu resolved CXF-319.
----------------------------
Resolution: Fixed
> Support for accessing message payload from Logical handler when dispatch is used.
> ---------------------------------------------------------------------------------
>
> Key: CXF-319
> URL: http://issues.apache.org/jira/browse/CXF-319
> Project: CXF
> Issue Type: New Feature
> Components: JAX-WS Runtime
> Reporter: Jervis Liu
> Assigned To: Jervis Liu
>
> Support for accessing message payload from Logical handler when dispatch is used. For example, following code snippet should work (but does not work).
> URL wsdl = getClass().getResource("/wsdl/addNumbers.wsdl");
> assertNotNull(wsdl);
> AddNumbersService service = new AddNumbersService(wsdl, serviceName);
> assertNotNull(service);
> JAXBContext jc = JAXBContext.newInstance("org.apache.hello_world_soap_http.types");
> //Dispatch<Object> disp = service.createDispatch(portName, jc, Service.Mode.PAYLOAD);
> Dispatch<Object> disp = service.createDispatch(portName, jc, Service.Mode.PAYLOAD);
> //Add client side handlers programmatically
> SmallNumberHandler sh = new SmallNumberHandler();
> List<Handler> newHandlerChain = new ArrayList<Handler>();
> newHandlerChain.add(sh);
> ((BindingProvider)disp).getBinding().setHandlerChain(newHandlerChain);
>
> org.apache.handlers.types.AddNumbers req = new org.apache.handlers.types.AddNumbers();
> req.setArg0(10);
> req.setArg1(20);
> Object response = disp.invoke(req);
> In the SmallNumberHandler:
> public final boolean handleMessage(LogicalMessageContext messageContext) {
> //System.out.println("LogicalMessageHandler handleMessage called");
> try {
> boolean outbound = (Boolean)messageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
> if (outbound) {
> // get the LogicalMessage from our context
> //
> LogicalMessage msg = messageContext.getMessage();
> // check the payload, if its an AddNumbers request, we'll intervene
> //
> JAXBContext jaxbContext = JAXBContext.newInstance(AddNumbers.class);
> Object payload = msg.getPayload(jaxbContext);
> We got an NPE:
> java.lang.NullPointerException
> at org.apache.cxf.jaxws.handler.LogicalMessageImpl.getPayload(LogicalMessageImpl.java:49)
> at org.apache.cxf.systest.handlers.SmallNumberHandler.handleMessage(SmallNumberHandler.java:56)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira