Hello,
I want to add a header (which is ultimately added to the HTTP
headers) which is settable at the Service level. Take for instance the
HTTP Authorization header. Unfortunately there appears to be no way to
set a set of generic properties which are passed along in a
transport-specific manner. This is what I have had to do:
1) Subclass Service so that createCall returns a custom Call subclass
2) Subclass Call to override the setRequestMessage() method, which is
called during invocation. In this method, set the property
"Authorization" in the RequestMessage's MessageContext. This will go
into a hashtable of properties/headers.
3) Now EDIT HTTPSender class to ALLOW this header through. By default
HTTPSender blatently *ignores* any interesting HTTP headers, meaning our
"Authorization" header will be ignored even if we set it:
Axis 1.0 HTTPSender, line 319
// DO NOT IGNORE!
//} else if
(key.equalsIgnoreCase(HTTPConstants.HEADER_AUTHORIZATION)) {
//ignore
4) Even if we do all this, and finally manage to set this header in the
MessageContext properties which will be written out on the HTTP request,
the invoke() method in Call, immediately *reset()s* the MessageContext
after setRequestMessage() but before making the call. The reset()
method of MessageContext() wipes out all properties!:
Axis 1.0 Call, line 1993
public void invoke() throws AxisFault {
if (log.isDebugEnabled()) {
log.debug("Enter: Call::invoke()");
}
Message reqMsg = null ;
SOAPEnvelope reqEnv = null ;
msgContext.reset(); // <--- here
msgContext.setResponseMessage(null);
Axis 1.0 MessageContext, line 976
public void reset()
{
if (bag != null) {
// our property we set in setRequestMessage()
// is now cleared!
// we must comment this block if we want it to stick
bag.clear();
}
serviceHandler = null;
havePassedPivot = false;
currentOperation = null;
}
After doing all these things, and making modifications to the Axis
library, I can finally get my header through (I don't know what the
ramifications of not clearing the MessageContext properties before each
call is, but I don't have much of a choice).
My question is: is there a better way than this??
Aaron Hamid
Cornell University