axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Giao <gq...@yahoo.com>
Subject Re: how to add basic auth header to soap request
Date Thu, 11 Oct 2007 16:43:58 GMT
Forgot.  You need Java 1.5 or higher.
Try this.

....
HttpTransportProperties.Authenticator basicAuth = new
HttpTransportProperties.Authenticator();

List<String> auth = new ArrayList<String>();
basicAuth.setAuthSchemes(auth);
auth.add(HttpTransportProperties.Authenticator.BASIC);
basicAuth.setPreemptiveAuthentication(true);
basicAuth.setUsername("USER");
basicAuth.setPassword("PASSWORD");

options.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE,
basicAuth);
...

It works for me.
Giao Nguyen

--- Murali Krishnan <cme_mk@yahoo.com> wrote:

> Hi all,
> I'm trying to add a Basic Auth header to the
> outgoing soap request, but I'm not seeing it in the
> list of headers. This is the code I'm using. Is
> there something wrong?
>      
>         ServiceClient client = new ServiceClient();
>         Options options = new Options();
> 
>         HttpTransportProperties.Authenticator
> basicAuth = new
> HttpTransportProperties.Authenticator();
>         basicAuth.setUsername("xxxxxxx");
>         basicAuth.setPassword("xxxxxxx");
>        
>
options.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE,
> basicAuth);
>         
>         options.setAction("urn:echo");
>         options.setTo(new
> EndpointReference(args[0]));
>         
>         client.setOptions(options);
>         
>         OMElement response =
> client.sendReceive(getPayload("Dummy"));
>         
>         System.out.println(response);
> 
> 
> Outgoing SOAP request: (captured with tcpmon)
> ====================
> POST /web/wss11/services/Services_EchoWSD HTTP/1.1
> Content-Type: text/xml; charset=UTF-8
> SOAPAction: "urn:echo"
> User-Agent: Axis2
> Host: 127.0.0.1:5050
> Transfer-Encoding: chunked
> 
> f0
> <?xml version='1.0' encoding='UTF-8'?>
>    
>       <soapenv:Body>
>          
>             <input>Dummy</input>
>          </ns1:echo>
>       </soapenv:Body>
>    </soapenv:Envelope>0
> 
> 
> 
> 
>        
>
____________________________________________________________________________________
> Take the Internet to Go: Yahoo!Go puts the Internet
> in your pocket: mail, news, photos & more. 
> http://mobile.yahoo.com/go?refer=1GNXIC



       
____________________________________________________________________________________
Be a better Globetrotter. Get better travel answers from someone who knows. Yahoo! Answers
- Check it out.
http://answers.yahoo.com/dir/?link=list&sid=396545469

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Mime
View raw message