Reputation: 6530
At the moment I facing the Problem that i need to add an custom HTTP Header to an org.apache.axis.client.Call
. But all I can find on how to do this is something like adding SOAP Headers, but this isn't what i was looking for.
Adding a simple SOAPHeader
would be easy:
SOAPHeaderElement header = new SOAPHeaderElement(new javax.xml.namespace.QName("SessionID"), sessionId);
_call.addHeader(header);
But can i do something simiular for HTTPHeaders
?
Thanks a lot.
Upvotes: 4
Views: 11545
Reputation: 31
Just wanted to add. This worked for me:
((Stub) service)._setProperty(Call.SESSION_MAINTAIN_PROPERTY, new Boolean(true));
((Stub) service)._setProperty(HTTPConstants.HEADER_COOKIE, "AuthToken=abc123");
Upvotes: 3
Reputation: 61
I generate my client using the wizard of eclipse, so I solved my problem extended the method on my service locator
@Override
public Call createCall() throws ServiceException {
_call = new org.apache.axis.client.Call(this) {
@Override
public void setRequestMessage(Message msg) {
super.setRequestMessage(msg);
MimeHeaders mimeHeaders = msg.getMimeHeaders();
mimeHeaders.addHeader("SessionID", SessionID);
}
};
return _call;
}
Upvotes: 6
Reputation: 187
Its been explained on following url:
http://www.coderanch.com/how-to/java/WebServicesHowTo
MessageContext msgContext = _call.getMessageContext();
MimeHeaders hd = msgContext.getMessage().getMimeHeaders();
hd.addHeader("SessionID", sessionId);
Upvotes: 1