9

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.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
kay.herzam
  • 3,053
  • 3
  • 26
  • 37

2 Answers2

4

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]

Community
  • 1
  • 1
Dave Ziegler
  • 1,737
  • 3
  • 19
  • 36
  • 2
    I get `The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.` error when trying to download the zip file using the provided link. – Max Aug 30 '13 at 20:11
  • Possibly because this is supported natively in Visual Studio now. – Dave Ziegler Aug 31 '13 at 14:39
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());
isalgueiro
  • 1,973
  • 16
  • 20
Kevin
  • 377
  • 1
  • 9