1
我們有幾個客戶端(10s)使用端點與我們的WCF服務器連接,目前他們都使用下面給出的代碼。WCF所有客戶端都使用web.config值,而不管客戶端提供的設置如何
我們可以在我們的web.config中指定所有設置,例如由於我們的WCF Web服務託管在一個單獨的服務器上,並且忽略客戶端提供給我們的東西,我希望它們不向我們提供像超時和綁定這樣的值,所以我查看了證書身份驗證,但未看到客戶將來增加的值。
HttpClientCredentialType credType = myCred.httpClientCredentialType;
//Set the binding security & authentication type
BasicHttpBinding binding = new BasicHttpBinding();
binding.Security.Mode = BasicHttpSecurityMode.Transport;
binding.Security.Transport.ClientCredentialType = credType;
TimeSpan ts = new TimeSpan(0, 0, 10, 0);
binding.CloseTimeout = ts;
binding.OpenTimeout = ts;
binding.ReceiveTimeout = ts;
binding.SendTimeout = ts;
//set the webservice endpoint address
EndpointAddress endpoint = new EndpointAddress(someURL + "/_vti_bin/ourWCF/fruits.svc");
ChannelFactory<WebServices.Internal.IFruits> factory = new ChannelFactory<WebServices.Internal.IFruits>(binding);
factory.Credentials.Windows.ClientCredential = myCred;
factory.Credentials.UserName.UserName = myCred.UserName;
factory.Credentials.UserName.Password = myCred.Password;
WebServices.Internal.IFruits proxy = factory.CreateChannel(endpoint);
string someThing = proxy.GetFruitsList();