Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Axis2 BASIC AUTHENTICATION

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Rancher
Posts: 43026
76
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 43026
76
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and now i changed displayname...
 
Ulf Dittmer
Rancher
Posts: 43026
76
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?).
 
Ever since I found this suit I've felt strange new needs. And a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic