Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flat WSDL for WCF 4 Service

Tags:

wsdl

wcf

wcf-4

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.

like image 482
kay.herzam Avatar asked Apr 27 '11 08:04

kay.herzam


2 Answers

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]

like image 167
Dave Ziegler Avatar answered Nov 16 '22 16:11

Dave Ziegler


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());
like image 22
Kevin Avatar answered Nov 16 '22 16:11

Kevin