0 Replies Latest reply on Sep 14, 2013 8:09 AM by Joseph Hwang

    Interception of SOAP xml message with SOAPHandler

    Joseph Hwang Novice

      I want to intercept and examine the whole SOAP xml message. This is my SOAPHandler class ;

       

      public class SOAPMessageHandler implements SOAPHandler<SOAPMessageContext> {

       

          @Override
          public void close(MessageContext context) {
               // TODO Auto-generated method stub

          }

       

          @Override
          public boolean handleFault(SOAPMessageContext context) {
              // TODO Auto-generated method stub
             return false;
          }

       

          @Override
          public boolean handleMessage(SOAPMessageContext context) {
               // TODO Auto-generated method stub
              System.out.println("Server : handleMessage()......");

       

              Boolean isRequest = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);

              if(!isRequest){

                 try{
                      SOAPMessage soapMsg = context.getMessage();
                      SOAPEnvelope soapEnv = soapMsg.getSOAPPart().getEnvelope();

                      SOAPHeader soapHeader = soapEnv.getHeader();
                      SOAPBody soapBody = soapEnv.getBody();


                      System.out.println(soapHeader.toString());

                      System.out.println(soapBody.toString());
                  }
                  catch(Exception e) {

                     e.printStackTrace();
                  }
             }
             return true;
         }

       

         @Override

          public Set<QName> getHeaders() {

              // TODO Auto-generated method stub

             return null;

          }

      }

       

      But the whole soap xml message are not printed. Console shows ony these messages

       

      20:48:04,217 INFO [stdout] (default task-8) Server : handleMessage()......

      20:48:04,217 INFO [stdout] (default task-8) [soap:Header: null]

      20:48:04,217 INFO [stdout] (default task-8) [soap:Body: null]

       

      How can i get the whole SOAP xml message in SOAPHandler class?

      I need your help! Thanks.