論壇有個代碼下載但是運行不了.
網上拼湊的代碼
Host = new ServiceHost(typeof(WcfService1.Service1));
//系結
System.ServiceModel.Channels.Binding httpBinding = new BasicHttpBinding();
//終結點
Host.AddServiceEndpoint(typeof(WcfService1.Service1), httpBinding, "http://localhost:8002/");
if (Host.Description.Behaviors.Find<System.ServiceModel.Description.ServiceMetadataBehavior>() == null)
{
//行為
ServiceMetadataBehavior behavior = new ServiceMetadataBehavior();
behavior.HttpGetEnabled = true;
//元資料地址
behavior.HttpGetUrl = new Uri("http://localhost:8002/Service1");
Host.Description.Behaviors.Add(behavior);
//啟動
Host.Open();
MessageBox.Show("1");
}
只能訪問http://localhost:8002/Service1 回傳的是XML
但是訪問 http://localhost:8002/Service1/GetFun2?UserID=as&OperaID=23 里面的方法就不行
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/273480.html
標籤:C#
