Getting Method Signature Name form a SOAPMessage on JAX-WS
I'm using JAX-WS to consume SOAP web services and I'm looking for an easy way to find the method that's being called via SOAP which generated my current SOAPMessage
I believe one way would be to chec开发者_运维百科k the SOAP Body first node (that's the name of the method called) but I don't have a clue on how to parse the SOAP Body from this SOAPMessage
As of now I can output the message to my console
thanks in advance
I'm not sure that I understand your question, however:
if you're processing the soap message as part of a handler, you can get the service and operation being invoked from the SOAPMessageContext:
QName svcn = (QName) context.get(MessageContext.WSDL_SERVICE);
svcn.getLocalPart();
QName opn = (QName) context.get(MessageContext.WSDL_OPERATION);
opn.getLocalPart();
if you just want to deal with SOAPMessage in your client code, and want to know what element is contained in the SOAP Body:
msg.getSOAPBody().getFirstChild().getLocalName()
The SOAPMessage exposes each part of the envilope as a DOM object, so you can do normal "DOM"ish things with it.
Maybe useful for someone, this is the answer to FrustratedWithFormsDesigner question: It appears to be NULL in my message handler.
Please see this. This is exactly the explanation why it is null:
http://blog.vinodsingh.com/2009/03/how-to-get-operation-name-in-jax-ws.html
精彩评论