Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Axis2 BASIC AUTHENTICATION

 
fatih aratma
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42967
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
fatih aratma
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42967
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll respond with suggestions once you fix your display name, like you were asked to do.
 
fatih aratma
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and now i changed displayname...
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic