Flat WSDL for WCF 4 Service

陌路散爱 提交于 2019-12-30 01:30:05

问题


Using WCF 3.5 and the FlatWsdl EndpointBehavior from Christian Weyer, I was able to get a single flat WSDL file for my WCF services without any <import> directives.

Now with WCF 4, this doesn't work anymore for some reason.

I have tried everything described in a lot of blog entries including using the WcfExtras behavior extension.

They all either refer to Chr. Weyers solution or recommend the WcfExtras. I also made sure I specified the same namespace for the binding, ServiceContract and ServiceBehavior.

In the custom service host, when the FlatWsdlExtension is about to be injected, the Description.Endpoints collection is always empty. I tried to configure my service endpoint with or without an adress, so far without luck.

What do I need to do in order to get a single flat WSDL for my WCF 4 service?

Thanks for any answers.


回答1:


I was having this exact problem. After several attempts today, I finally got it to work by doing the following:

Read this blog post in full.

Make sure you specify exactly the same namespace attribute in: ServiceContract, ServiceBehavior, and bindingNamespace (.config->services/service/endpoint section).

Be mindful of this problem, which I did encounter at one point.

Download this zip file and include FlatWsdl/Extensions: FlatWsdl.cs, FlatWsdlServiceHost.cs, and FlatWsdlServiceHostFactory.cs somewhere in your project.

Make sure you specify the fully-qualified classname for your version of FlatWsdlServiceHostFactory.cs (minus .cs of course) in the ServiceHost Factory attribute of your .svc file.

I tried WcfExtras among other things today -- there may be more or less to it, but these steps finally got me going. Good luck!

[edit]




回答2:


Late answer, hope it helps someone.

Had the same issue, solved it by manually adding the behavior to the serviceendpoint:

   FlatWsdlServiceHost serviceHost = new FlatWsdlServiceHost(typeof(MyService));

   ServiceEndpoint endp = serviceHost.AddServiceEndpoint(typeof(IMyService), new BasicHttpBinding(), "MyService");
   endp.Behaviors.Add(new FlatWsdl());


来源:https://stackoverflow.com/questions/5801128/flat-wsdl-for-wcf-4-service

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!