2 Replies Latest reply on Jan 18, 2008 6:23 PM by Alessio Soldano

    How can I see the SoapResponse

    Vincent Jassogne Newbie

      Hello,

      I generated a client with WSConsume and register a handler to log soap messages.

      The handler gets called and display the request but I am not able to see either the soapfault nor the soapresponse.

      Here is the code of my handler. Could you pls tell me what did I wrong ?

       final String HANDLER_NAME = "LogHandler";
       // change this to redirect output if desired
       private static PrintStream out = System.out;
      
      
      
       public boolean handleMessage(SOAPMessageContext smc) {
       System.out.println("Executing " + HANDLER_NAME);
       logToSystemOut(smc);
       return false;
       }
      
       public boolean handleFault(SOAPMessageContext smc) {
       System.out.println("Une faute");
       logToSystemOut(smc);
       return false;
       }
      
       // nothing to clean up
       public void close(MessageContext messageContext) {
       }
      
       /*
       * Check the MESSAGE_OUTBOUND_PROPERTY in the context
       * to see if this is an outgoing or incoming message.
       * Write a brief message to the print stream and
       * output the message. The writeTo() method can throw
       * SOAPException or IOException
       */
       private void logToSystemOut(SOAPMessageContext smc) {
       Boolean outboundProperty = (Boolean)
       smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
      
       if (outboundProperty) {
       out.println("\nOutbound message:");
       } else {
       out.println("\nInbound message:");
       }
      
       SOAPMessage message = smc.getMessage();
       try {
       message.writeTo(out);
       out.println(""); // just to add a newline
       } catch (Exception e) {
       out.println("Exception in handler: " + e);
       }
       }
      


      Thanks in advance