Hello,

 

I have a web service deployed and I need to deal with SOAP messages both
inbound and outbound ones (I have to add some headers, but I need the whole
SOAP message (Envelope element) ). I have added two interceptors: one for
inbound messages and other one for outbound messages and, by the moment,
they only print the SOAP message intercepted.

 

As far as the inbound interceptor is concerned, it extends
AbstractSoapInterceptor and is included in PRE_PROTOCOL phase after
SAAJInInterceptor. Here, I managed to print the SOAP Message, and I get the
whole message correctly.

 

However, the outbound interceptor also extends AbstractSoapInterceptor and
is included in Pre_protocol phase after SAAJOutInterceptor. Here, I managed
to print the SOAP Message, but I get the body element empty!! -> The client
receives a complete SOAP message, with element body filled in.

 

I would like to know:

1)      If my interceptors extend correct class.

2)      If they are added in the correct phase (should I add an ending
interceptor to my outbound interceptor? Or is it better to include it in
POST_PROTOCOL phase?).

3)      Why I am not able to get a complete outbound SOAP message and what
is the way of get it.

 

I include my interceptors java code.

 

///////////////////////////////// INBOUND INTERCEPTOR
///////////////////////////////////////

public class InterceptorMensajeSOAPIn extends AbstractSoapInterceptor {

 

      private static Logger log =
Logger.getLogger(InterceptorMensajeSOAPIn.class);

      

      private SAAJInInterceptor saajIn = new SAAJInInterceptor();

 

      public InterceptorMensajeSOAPIn(){

            super(Phase.PRE_PROTOCOL);

            getAfter().add(SAAJInInterceptor.class.getName());

      } 

      

      public void handleMessage(SoapMessage message) throws Fault {

      

        SOAPMessage soapMessage = getSOAPMessage(message);

        try {

                  soapMessage.writeTo(System.out);

            } catch (Exception e) {

                  e.printStackTrace();

            }

      

      }

      

      private SOAPMessage getSOAPMessage(SoapMessage smsg){

            SOAPMessage soapMessage = smsg.getContent(SOAPMessage.class);

        if (soapMessage == null) {

            saajIn.handleMessage(smsg);

            soapMessage = smsg.getContent(SOAPMessage.class);

        }   

        return soapMessage;

      }

}

 

 

///////////////////////////////// OUTBOUND INTERCEPTOR
///////////////////////////////////////

 

public class InterceptorMensajeSOAPOut extends AbstractSoapInterceptor {

 

      private static Logger log =
Logger.getLogger(InterceptorMensajeSOAPOut.class);

      

      private SAAJOutInterceptor saajOut = new SAAJOutInterceptor();

 

      public InterceptorMensajeSOAPOut(){

            super(Phase.PRE_PROTOCOL);

            getAfter().add(SAAJOutInterceptor.class.getName());

 

      } 

      

      public void handleMessage(SoapMessage message) throws Fault {

      

       SOAPMessage soapMessage = getSOAPMessage(message);

        try {

                  soapMessage.writeTo(System.out);

            } catch (Exception e) {

                  e.printStackTrace();

            }

      }

      

      

      private SOAPMessage getSOAPMessage(SoapMessage smsg){

            SOAPMessage soapMessage = smsg.getContent(SOAPMessage.class);

        if (soapMessage == null) {

            

            saajOut.handleMessage(smsg);

            soapMessage = smsg.getContent(SOAPMessage.class);

        }   

        return soapMessage;

      }

}

 

 

 

Could you be so kind as to help me, please?

 

Regards,

Inma.

 

Reply via email to