axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "S.E.Parkin" <>
Subject Using a client-side handler to modify the target endpoint
Date Tue, 06 May 2003 11:16:57 GMT

I've recently started putting some code together for a client-side handler 
which automatically takes the target endpoint of a service, places this into a 
SOAP header entry, and then replaces it with another endpoint (which it is 
hoped can then point to a routing node, used to reliably forward the call to 
the endpoint that was originally targeted).

However, I'm having trouble insofar as I've got a Handler which extracts the 
SOAPEnvelope from the MessageContext and adds a new Header entry with the old 
endpoint address in it, but when I extract the Call object from the 
MessageContext and alter the target endpoint of this call, and then set the 
'call_object' property in the MessageContext again, although the endpoint has 
apparently been altered correctly in the MessageContext, the Call is still 
targeted at the original endpoint. A colleague has suggested that Axis is 
caching the endpoint for the call (irrespective of the message context) 
somewhere before reaching the client-side handler (which, if this is the case, 
would obviously make any endpoint alterations in the handler useless), and I'm 
wondering if this is what is actually happening, and if so where - otherwise, 
how else may I properly change the endpoint automatically in a handler?

Just for reference, here's my client wsdd file and the core functionality of 
the associated client handler ... :-)


<?xml version="1.0" encoding="UTF-8"?>
<deployment name="defaultClientConfig"
 <transport name="http" 
 <transport name="local" 
 <transport name="java" 
   <handler type="java:ClientHeaderHandler"/>

The body of the ClientHeaderHandler is as follows:

//extract the message from the context
Message requestMessage = msgContext.getRequestMessage();
//extract the original call object from the context
Call tempC = (Call)msgContext.getProperty("call_object");
//determine the address of the target endpoint
System.out.print("\nold endpoint is: " + tempC.getTargetEndpointAddress());
//get the envelope and add a new header storing the old endpoint address
SOAPEnvelope myEnv = requestMessage.getSOAPEnvelope();
myEnv.addHeader(new SOAPHeaderElement("", "target", 
//change the endpoint address and record this change in the message context
msgContext.setProperty("call_object", tempC);
//check that the change of endpoint has been carried out correctly
Call tC = (Call)msgContext.getProperty("call_object");
System.out.print("\nnew endpoint is: " + tC.getTargetEndpointAddress());

Any help would be greatly appreciated.

Simon Parkin

View raw message