[英]WCF web service discovery on network interfaces with multiple IP addresses
[英]WCF client has inconsistent behavior with multiple network interfaces
我有如下所示的WCF客戶端:
public static string Execute(string a)
{
WebHttpBinding b = new WebHttpBinding();
b.Security.Mode = WebHttpSecurityMode.Transport;
WebChannelFactory<IAnimalService> f = new WebChannelFactory<IAnimalService>(b, new Uri(a));
f.Endpoint.Behaviors.Add(new WebHttpBehavior());
IWebService client = f.CreateChannel();
return client.SayHello("moo");
}
我正在針對來自2台不同計算機(A,B)的對應服務測試客戶端(在控制台主機中),並且得到了不同的結果。 以下是A和B之間的異同:
X-Squid-Error -> ERR_ACCESS_DENIED 0
)。 例外:
Unhandled Exception: System.ServiceModel.Security.MessageSecurityException: The HTTP request was forbidden with client authentication scheme
'Anonymous'. ---> System.Net.WebException: The remote server returned an error: (403) Forbidden.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
--- End of inner exception stack trace ---
我還查詢了機器B上的路由表,它表明請求應該已經在外部網絡接口上發出了。 我假設內部路由表將由TCP-IP堆棧的下層查詢,以便將數據包轉發到正確的(網絡)介質。
因此,我想知道是否有人會知道如何讓我的客戶選擇機器B上的正確接口。我不確定如何進一步解決該問題。 因此,關於如何在機器B上解決這種問題的任何建議/提示都將受到歡迎。
嘗試在配置文件中使用此代碼段,以便您將能夠使用默認憑據在代理服務器中自動啟動。
<system.net>
<defaultProxy useDefaultCredentials="true" />
</system.net>
似乎默認情況下,綁定試圖在計算機B上尋找默認的代理設置。添加以下綁定配置解決了該問題:
b.UseDefaultWebProxy = false;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.