getting method parameters from SOAPMessageContext

Is it possible to get the parameters passed through a web-service call by using a handler on the client side? I'm trying to log the parameters i've sent to the web-service, everytime i do so.

In this chase, using a jax-ws handler that i've assigned to the web-service. This is a simple and common example of the handler look and methods.

    public class RafaSOAPHandler implements SOAPHandler<SOAPMessageContext> {

        @Override
        public boolean handleMessage(SOAPMessageContext context) {
        System.out.println("Client : handleMessage()......");
             // TODO: GET METHOD PARAMETERS HERE.
        return true;
        }

        @Override
        public boolean handleFault(SOAPMessageContext context) {
        System.out.println("Client : handleFault()......");
        return true;
        }

        @Override
        public void close(MessageContext context) {
        System.out.println("Client : close()......");
        }

        @Override
        public Set<QName> getHeaders() {
        System.out.println("Client : getHeaders()......");
        return null;
        }

    }

Upvotes: 0

Views: 5224

Answers (1)

Paulius Matulionis
Paulius Matulionis

Reputation: 23415

Is it possible to get the parameters passed through a web-service call by using a handler on the client side?

The answer is simple: Yes it is possible. You can extract the soap message from SOAPMessageContext like this:

public boolean handleMessage(SOAPMessageContext context) {
    SOAPMessage message = context.getMessage();
    SOAPHeader header = message.getSOAPHeader();
    SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
}

And as long as you have soap envelope you get any parameter from your SOAP message.

Upvotes: 2

Related Questions