You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Kr <ba...@gmail.com> on 2005/08/10 10:54:05 UTC

Unable to capture Request Headers

Hi All,

I am trying to consume a web service that uses basic authentication. I
use <stub object>.setUsername("sdf") and <stub
object>.setPassword("dfd) to pass the basic authentication information
in the request header. Now I try to print the request headers using
below code snippet of a handler :

....
....
public void invoke(org.apache.axis.MessageContext messageContext)
throws org.apache.axis.AxisFault {
	try {
		Message reqMessage = messageContext.getRequestMessage();
		javax.xml.soap.MimeHeaders mimeHeader = reqMessage.getMimeHeaders();
		org.apache.axis.message.MimeHeaders axisMimeHeaders =
(org.apache.axis.message.MimeHeaders)mimeHeader;
		Iterator iterator = axisMimeHeaders.getAllHeaders();
		while (iterator.hasNext()) {
			String key = (String)iterator.next();
			String value[] = axisMimeHeaders.getHeader(key);
			System.out.println ("key:"+key+"\t*** value:"+value);
		}
	}
....
.....



However I dont see any request headers printed onto console using
above code. Am i doing anything wrong here. Please suggest ...


Thanks & Regards,
Kr.

Re: Unable to capture Request Headers

Posted by James Wilson <wi...@ociweb.com>.
My services are using HTTP as the transport, and I'm able to get the username
and password the client provided for Basic Authentication straight from the
MessageContext object.  Though I'm doing this in the service implementation,
not a handler.  I'm not sure when in the handler chain the values are
populated.
        MessageContext msgContext = MessageContext.getCurrentContext();
        msgContext.getUsername()
        msgContext.getPassword());

Hope it helps,
-james


Quoting Kr <ba...@gmail.com>:

> Hi All,
>
> I am trying to consume a web service that uses basic authentication. I
> use <stub object>.setUsername("sdf") and <stub
> object>.setPassword("dfd) to pass the basic authentication information
> in the request header. Now I try to print the request headers using
> below code snippet of a handler :
>
> ....
> ....
> public void invoke(org.apache.axis.MessageContext messageContext)
> throws org.apache.axis.AxisFault {
> 	try {
> 		Message reqMessage = messageContext.getRequestMessage();
> 		javax.xml.soap.MimeHeaders mimeHeader = reqMessage.getMimeHeaders();
> 		org.apache.axis.message.MimeHeaders axisMimeHeaders =
> (org.apache.axis.message.MimeHeaders)mimeHeader;
> 		Iterator iterator = axisMimeHeaders.getAllHeaders();
> 		while (iterator.hasNext()) {
> 			String key = (String)iterator.next();
> 			String value[] = axisMimeHeaders.getHeader(key);
> 			System.out.println ("key:"+key+"\t*** value:"+value);
> 		}
> 	}
> ....
> .....
>
>
>
> However I dont see any request headers printed onto console using
> above code. Am i doing anything wrong here. Please suggest ...
>
>
> Thanks & Regards,
> Kr.
>