SUpreti
SUpreti

Reputation: 105

Unable to access Password protected Java Webservice from ASP.NET

I have the following scenario: I have a website in ASP.NET 2.0. which calls another webservice (which is in JAVA) to retrieve the user's information. This webservice is password protected and uses "https" as its transport (If I enter the webservice's address in the address bar of the browser, "Windows Security" windows pops up saying "The server at Unprotected Root [IP address] requires a username and passowrd, I don't know if this is called as password protected webservice.) After I put the user name and password, supplied by the webservice group, I am able to see their some general message which indicates that the authentication is done.

Is the following code good for above scenario:

WebServiceProxy client=new WebServiceProxy();
client.Url=@"serviceEndPoint";

...

NetworkCredential netCred=new NetworkCredential();
netCred.UserName="UserName";//*User name supplied by WebService group.
netCred.Password="Password";//*Password supplied by WebService group.
client.Credentials=netCred;
var retObject=client.GetUserInfo(userId);

Is this what I should do to pass the user name/password ?

To solve this, I created a Soap message in a tool called "soapUI" and called the service, and I am able to get the response with the user info (user object). But from the code, I get the response, but with user object as null.

Upvotes: 0

Views: 388

Answers (1)

poc
poc

Reputation: 51

Whether the service has been created in Java or DotNet. It doesn't matter, everything will be consumed in the same way.

Upvotes: 1

Related Questions