簡體   English   中英

WCF客戶端調用Java Web服務

[英]WCF client calling a Java webservice

使用基本身份驗證使用HTML托管的Web服務登錄時,我遇到一個小問題。 我已經嘗試了以下方法,但是它不起作用。 有任何限制或陷阱嗎?

           var client = new WSClient();
           client.ClientCredentials.UserName.UserName = "xxx";
           client.ClientCredentials.UserName.Password = "yyy";
           client.doIt();

客戶端顯示帶有HTTP 401未授權代碼的異常,但不會嘗試登錄。 客戶端使用WCF,由Visual Studio 2008生成,服務器運行Java Apache CXF 使用網絡瀏覽器可以很好地完成基本挑戰...

經過一番調查后,這將登錄:

var binding = new BasicHttpBinding();
binding.Security.Mode=BasicHttpSecurityMode.TransportCredentialOnly;
binding.Security.Transport.ClientCredentialType=HttpClientCredentialType.Basic;
var client = new WSClient(binding, new EndpointAddress("http://localhost/myws"));
client.ClientCredentials.UserName.UserName = "xxx";
client.ClientCredentials.UserName.Password = "yyy";
client.doIt();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM