File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Axis2 BASIC AUTHENTICATION Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Axis2 BASIC AUTHENTICATION" Watch "Axis2 BASIC AUTHENTICATION" New topic
Author

Axis2 BASIC AUTHENTICATION

fatih aratma
Greenhorn

Joined: Oct 15, 2009
Posts: 3
Hi,
I am using axi2 1.4 for generate java client code from WSDL. The service that i want use is a .net service. IIS basic AUTHENTICATION property is active, so i must authenticate before call the service method.
Code:
HttpTransportProperties.Authenticator basicAuth = new HttpTransportProper ties.Authenticator();
basicAuth.setUsername(user);
basicAuth.setPassword(password) ;

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

SessionServiceStub binding = null;
try {
binding = new SessionServiceStub( );
} catch (AxisFault e1) {
}
ServiceClient client;
client = binding._getServiceClient();

client.setOptions( options);
binding._setServiceClient(client) ;
binding.method( );

----------------------
and also i try this code :
HttpTransportProperties.Authenticator basicAuth = new HttpTransportProperties.Authenticator();
List auth = new ArrayList();
auth.add(Authenticator.BASIC);
basicAuth.setAuthSchemes(auth);
basicAuth.setUserna me(user);
basicAuth.setPasswo rd(password) ;

instead of
HttpTransportProperties.Authenticator basicAuth = new HttpTransportProper ties.Authenticator();
basicAuth.setUsername(user);
basicAuth.setPassword(password) ;

--------------------------------

when i use this code, i cant authenticate. Also, i examine the SOAP message that send to web service from my client, password and user property did not add soap header part.
SOAP message :
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
-----------
</soapenv:Body>
</soapenv:Envelope>

But i think it should like this :
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Header>
<h:BasicAuth xmlns:h="http://soap-authentication.org/basic/2001/10/" SOAP-ENV:mustUnderstand="1">
<Name>user</Name>
<Password>password</Password>
</h:BasicAuth>
</soapenv:Header>
<soapenv:Body>
-----------
</soapenv:Body>
</soapenv:Envelope>

how can i authenticate web servise that host on the IIS that BASIC AUTHENTICATION property is active ?

thanks...
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41626
    
  55
Welcome to JavaRanch. Please check your private messages for an important message (click on "My Private Messages" at the top of the page).

HTTP auth. uses HTTP headers, not SOAP headers. Does the tool you're using to examine the SOAP also show those?

Generally, the way to use HTTP auth. would look something like this:


Ping & DNS - my free Android networking tools app
fatih aratma
Greenhorn

Joined: Oct 15, 2009
Posts: 3
my stub dont have property and method like those.
how can i authenticate use HttpTransportProperties or if you know different way for authenticate , you can suggest me, please. I try to add element to soap header, use axiom, but i cant authenticate.
thanks...
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41626
    
  55
I'll respond with suggestions once you fix your display name, like you were asked to do.
fatih aratma
Greenhorn

Joined: Oct 15, 2009
Posts: 3
and now i changed displayname...
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41626
    
  55
Look through all the generated classes, and also the classes which they extend; I'm fairly certain that one of them has these methods.

Another possibility would be to use the SAAJ MimeHeaders: http://faq.javaranch.com/java/WebServicesHowTo#http-headers if you can get at those, but I think Axis2 still has a bug that prevents you from setting those.

And again: This is an HTTP header, not a SOAP header. The stuff about "h:BasicAuth" is obsolete (not that I think it was ever used widely - where did you read about that?).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Axis2 BASIC AUTHENTICATION