[英]Adding WCF service behaviors with code
我知道我可以使用一些XML配置添加服務行為,但我想用一塊C#來做,類似於如何添加端點行為。 不過,我不知道該怎么做。
換句話說,我如何添加我在下面實例化的調試行為?
var host = new ServiceHost(typeof(MyService));
var endpoint = host.AddServiceEndpoint(typeof (MysService),
new WebHttpBinding(), new Uri(myURL));
endpoint.Behaviors.Add(new WebHttpBehavior());
var debug = new ServiceDebugBehavior
{
IncludeExceptionDetailInFaults = true
};
//WHAT DO I PUT HERE?
host.Open();
host.Description.Behaviors.Add(debug);
你也可以為你的服務寫一個例子
[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
public class Service1 : IServiceChild
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.