如何在不指定uri/url/baseaddress的情況下使用WCF?無論如何要讓它自動獲得這些東西?在不指定uri的情況下使用WCF
我的意思是我希望使它像asp.net網站和webservices一樣工作,我們不提及uri和東西,只要我們在IIS中正確配置它就會自行處理它。 我需要WCF上的類似解決方案。
請幫忙...
謝謝。
編輯: 下面是一個使用此定製ServiceHostFactory我的服務器端code.I'm ...
protected override System.ServiceModel.ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
{
BasicHttpBinding basichttpbinding = new BasicHttpBinding(BasicHttpSecurityMode.None);
basichttpbinding.CloseTimeout=TimeSpan.MaxValue;
basichttpbinding.OpenTimeout=TimeSpan.MaxValue;
basichttpbinding.ReceiveTimeout=TimeSpan.MaxValue;
basichttpbinding.SendTimeout=TimeSpan.MaxValue;
// basichttpbinding.TransferMode = TransferMode.Buffered;
ServiceEndpoint servicepoint=new ServiceEndpoint(ContractDescription.GetContract(serviceType));
servicepoint.Binding=basichttpbinding;
ServiceHost servicehost = new ServiceHost(serviceType, baseAddresses);
((ServiceDebugBehavior)servicehost.Description.Behaviors[typeof(ServiceDebugBehavior)]).IncludeExceptionDetailInFaults=true;
servicehost.OpenTimeout = TimeSpan.MaxValue;
servicehost.CloseTimeout = TimeSpan.MaxValue;
servicepoint.Binding.SendTimeout = TimeSpan.MaxValue;
servicepoint.Binding.ReceiveTimeout = TimeSpan.MaxValue;
basichttpbinding.MaxBufferPoolSize = 999999999;
// basichttpbinding.MaxConnections = 999999999;
//basichttpbinding.MaxConnections = 999999999;
basichttpbinding.MaxReceivedMessageSize = 999999999;
XmlDictionaryReaderQuotas quotas = new XmlDictionaryReaderQuotas();
quotas.MaxArrayLength = 999999999;
quotas.MaxBytesPerRead = 999999999;
quotas.MaxDepth = 999999999;
quotas.MaxNameTableCharCount = 999999999;
quotas.MaxStringContentLength = 999999999;
basichttpbinding.ReaderQuotas = quotas;
//foreach (Uri uri in baseAddresses)
//{
servicehost.AddServiceEndpoint(typeof(IService), basichttpbinding, "http://localhost:52855/WCFService1/Service.svc");
// }
return servicehost;
}
你可以更具體一點。 「我如何使用WCF」和「工作列表asp.net網站」的含義是什麼? –
特別是沒有指定URI。我需要使用而不指定uri/baseaddress並使其自動獲取它們。 – Josh