WCF: how to generate a single WSDL document, without WSDL:import?

前端 未结 6 1207
既然无缘
既然无缘 2020-12-08 05:25

I\'m troubling into an issue... I\'m trying to find a way to generate a single wsdl document from my WCF service, i.e. without any link to external documents. I\'ve used Fla

相关标签:
6条回答
  • 2020-12-08 05:58

    (EDIT: Previous answer about FlatWSDL deleted, because as you pointed out it was about eliminating xsd:import not wsdl:import.)

    Look at this blogpost: Control generated WSDL in WCF

    "... There is always one WSDL generated for one target namespace URI ..."

    Do you have different namespace for ServiceContract, DataContract, ServiceBehavior, etc. ?

    0 讨论(0)
  • 2020-12-08 06:02

    my problem was in endpoint definitions, that are in tempuri.org namespace adding bindingNamespace to endpoint declarations fix my problem. thanks to all for help :)

    0 讨论(0)
  • 2020-12-08 06:03

    This is a late answer, but I had the same problem with a few of our WCF services. If you're on .NET 4.5, like the earlier answer, use ?singleWSDL, but if you're not targeting .NET 4.5 then I added the following to my web.config to fix the issue...

    <useRequestHeadersForMetadataAddress>
      <defaultPorts>
        <add port="80" scheme="http" />
        <add port="443" scheme="https" />
      </defaultPorts>
    </useRequestHeadersForMetadataAddress>
    

    This goes in your behavior. That way I didn't have to flatten the WSDL because all references were to MyURL instead of MyServer.

    Hope this helps others with a similar issue.

    0 讨论(0)
  • 2020-12-08 06:04

    You can now do this natively in .net 4.5 (beta). There is an option (?singleWsdl instead of ?wsdl) for telling the service to output everything in a single wsdl document. More info on the new stuff here: http://msdn.microsoft.com/en-us/library/dd456789(v=vs.110).aspx

    0 讨论(0)
  • 2020-12-08 06:05

    In addition to Jim's answer above, if you're using C# code to configure a WCF ServiceHost directly:

    using System.ServiceModel.Configuration;
    

    and when setting up your ServiceHost:

    UseRequestHeadersForMetadataAddressBehavior urh = new UseRequestHeadersForMetadataAddressBehavior();
    serviceHost.Description.Behaviors.Add(urh);
    

    I struggled to find this information online, as simple as it is. Hopefully helps someone in a similar situation.

    0 讨论(0)
  • 2020-12-08 06:09

    You could also use the WCFExtras project it has an extension to create a single WSDL-file.

    WCFExtras

    A collection of useful WCF extensions including Soap Header support, WSDL documentation and more.

    The WCF platform is very extensible and allows you to easily add features that are not part of the core product. This project contains some extensions I needed in a WCF based project:

    • SOAP Header support for WCF Adding WSDL
    • Documentation from Source Code XML Comments
    • Override SOAP Address Location URL
    • Single WSDL file for better compatibility with older SOAP tools.

    http://wcfextras.codeplex.com/

    0 讨论(0)
提交回复
热议问题