The way I do this is:

Client side handler, handleRequest --> tweak request --> soapCtx.setMessage(soapMsg); --> send to web service --> service side handler,  handleRequest --> evaluate tweaked request.

So you have two handlers - one client side, other service side. Each tweak has to be put back into the SOAPContext. One tweak by a handler is read by another. So the first step is to verify with tcpmon or the soap monitor that your tweak is being put in properly. Then you have to decide where you want to use it.

HTH,
Robert
http://www.braziloutsource.com/

On 4/14/06, Riadh BEN HALIMA < [EMAIL PROTECTED]> wrote:
Hi,
I'm using Handler to intercept SOAP message.
I append "an information" to the soap message Request, but i can't find it in the response!!
Can you help me?
 
My Handler contains this:
 
/****************************/
public boolean handleRequest(javax.xml.rpc.handler.MessageContext context) {
if (context instanceof SOAPMessageContext) {
try {
SOAPMessageContext soapMsgCtx = (SOAPMessageContext)context;
SOAPMessage soapMsg = soapMsgCtx.getMessage();
SOAPPart sp = soapMsg.getSOAPPart();
SOAPEnvelope se = sp.getEnvelope();
SOAPBody sb = se.getBody();
SOAPHeader sh = se.getHeader();
 
// soap message enrichment
Name name = se.createName("Test");
SOAPHeaderElement hdr = sh.addHeaderElement(name);
hdr.addTextNode("DATA");
}catch (SOAPException ex) {ex.printStackTrace();}
}
return true;
}
 public boolean handleResponse(javax.xml.rpc.handler.MessageContext context) {
if (context instanceof SOAPMessageContext) {
        try {
            SOAPMessageContext soapMsgCtx = (SOAPMessageContext)context;
            SOAPMessage soapMsg = soapMsgCtx.getMessage();
            SOAPPart sp = soapMsg.getSOAPPart();
            SOAPEnvelope se = sp.getEnvelope();
            SOAPBody sb = se.getBody();
            SOAPHeader sh = se.getHeader();

java.util.Iterator it= sh.examineAllHeaderElements();
    String tab[]=new String[10];
  try{
    int i=0;
  while (it.hasNext()) 
  {
   SOAPHeaderElement e =(SOAPHeaderElement)it.next(); 
    tab[i] =e.getValue();
   System.out.println(tab[i]);
   i++;
   // I can't find (int the table) the request enrichment (Test & DATA)
  }
 }
         catch (SOAPException ex) {ex.printStackTrace();}
        }
return true;
}
/****************************/
 
Thanks in advance.
Riadh

Reply via email to