Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 284
  • Last Modified:

How to call a webservice with basic authentication

My client app is calling a webservice which has basic authentication. How should i approach using java. I used wsdl2java to generate the stubs etc. But when i am actually calling the methos in the service, i am getting 401 unauthOrised..
0
Subhachandu
Asked:
Subhachandu
  • 2
1 Solution
 
SubhachanduAuthor Commented:
I used RAD6 tool to generate the client stubs. In that case, how should i be able to programmitcally pass the username/pwd for basic authentication.  Any help
0
 
SubhachanduAuthor Commented:
I want to pass username/pwd prammatically with out enabling the global security on the admin console
0
 
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
Yes its easy RAD 6 also uses axis for creating the stubs, hence you can follow this link, I am assuming you are taking about HTTP Basic authentication and not username token.
http://www.nsftools.com/stubby/ApacheAxisClientTips.htm

all you need to do is ass these lines before invoking the operation.

// to use Basic HTTP Authentication:
((Stub) service)._setProperty(Call.USERNAME_PROPERTY, "user name");
((Stub) service)._setProperty(Call.PASSWORD_PROPERTY, "password");


if you were looking for username token you can still follow my tutorial here as axis was implementaion of Jax-RPC

http://soa2world.blogspot.com/2009/05/direct-web-service-client-using-java.html
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now