简体   繁体   English

无法从ASP.NET访问受密码保护的Java Web服务

[英]Unable to access Password protected Java Webservice from ASP.NET

I have the following scenario: I have a website in ASP.NET 2.0. 我有以下情形:我在ASP.NET 2.0中有一个网站。 which calls another webservice (which is in JAVA) to retrieve the user's information. 它调用另一个Web服务(在JAVA中)以检索用户的信息。 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. 此Web服务受密码保护,并使用“ https”作为其传输方式(如果我在浏览器的地址栏中输入Web服务的地址,则会弹出“ Windows安全”窗口,并显示“未受保护的根[IP地址]上的服务器需要用户名, passowrd,我不知道这是否称为受密码保护的webservice。)在输入了webservice组提供的用户名和密码后,我可以看到他们的一些通用消息,这些消息指示身份验证已完成。

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). 为了解决这个问题,我在一个名为“ soapUI”的工具中创建了一条Soap消息并称为服务,并且我能够获得带有用户信息(用户对象)的响应。 But from the code, I get the response, but with user object as null. 但是从代码中,我得到了响应,但是用户对象为null。

Whether the service has been created in Java or DotNet. 服务是用Java还是DotNet创建的。 It doesn't matter, everything will be consumed in the same way. 没关系,所有内容都将以相同的方式消耗。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM