Well it turns out that not matter how many times you read it the transition to powerpoint tends to make code that doesn't run or compile
Slide: Callback Implementation for JAX-WS
Notice extra brackets to make the code compile, and the change of variable name in the loop.
// Deal with response @Resource WebServiceContext wsContext; public void getPriceResponse(String _return) { SOAPHeader sh = ((SOAPMessageContext)wsContext .getMessageContext()).getMessage().getSOAPHeader(); String relatesToMessageId = null; for (Iterator it = sh.getChildElements(AddressingVersion.W3C.relatesToTag); it.hasNext(); ) { SOAPHeaderElement obj =(SOAPHeaderElement)it.next(); relatesToMessageId = obj.getTextContent(); break; }
We found out later that if you are using RI then this code wont work because the message context is never of type SOAPMessageContext. So you might need to use code that looks something like the following block. Anoyingly this code wont work with non-RI based implements. (See also)
// Deal with response @Resource WebServiceContext wsContext; public void getPriceResponse(String _return) { HeaderList hl = context.getMessageContext().get(JAXWSProperties.INBOUND_HEADER_LIST_PROPERTY); Header h = hl.get(AddressingVersion.W3C.relatesToTag); String relatesToMessageId = h.getStringContent(); }
You could of course be using a Handler which will have a consistent SOAPMessageContext; but I find it makes the code just much harder to follow.
Every slide
Interestingly each and every slide has a url starting "java.dun.com", I have no idea how that typo got in there!
No comments:
Post a Comment