Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a single WSDL file from existing WCF service?

How do I create a single flat WSDL file (with no external references from within) from an existing WCF service? This WSDL will be used (imported) into an older programming technology that only supports BasicHttpBinding. Please address your answer to a beginner.

like image 772
Sam Avatar asked Mar 07 '11 06:03

Sam


People also ask

What is WSDL file in WCF?

WSDL stands for Web Service Description Language. The WCF service exposes the WSDL document for the clients, to generate proxies and the configuration file. The WSDL file provides the following information for the consumers of the WCF service.

Does WCF use WSDL?

You can use WCF to export WSDL documents from a ServiceDescription instance for your service. WSDL documents are automatically generated for your service when you publish metadata endpoints.

Can a WSDL have multiple services?

Especially, if each service exposes only a single operation? WSDL1. 2 specification mentions that "WSDL 1.1 supports having multiple services in a single WSDL file.

Can WCF be SOAP?

Normally, a WCF service will use SOAP, but if you build a REST service, clients will be accessing your service with a different architectural style (calls, serialization like JSON, etc.). Exposing a WCF service with both SOAP and REST endpoints, requires just a few updates to the codebase and configuration.


2 Answers

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

like image 67
Irwin Avatar answered Oct 19 '22 08:10

Irwin


I had to do this, too. And I used the WSDLExtras library. It's not too big of a deal.

Here is a step by step instruction for using it:

  1. Download the WCFExtras from here, extract it and add a reference to it in VS.

  2. Add a reference to your Web.config/App.config like this:

    <system.serviceModel>
        <extensions>
            <behaviorExtensions>
                <add name="wsdlExtensions" type="WCFExtras.Wsdl.WsdlExtensionsConfig, WCFExtras, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
            </behaviorExtensions>
        </extensions>
    </system.serviceModel>
    
  3. Add the extension to your endpoint behavior and set the singleFile attribute to true

    <endpointBehaviors>
         <behavior name="singleFileEndpointBehavior">
             <wsdlExtensions singleFile="True" />
         </behavior>
    </endpointBehaviors>
    
  4. Use the endpointbehavior for your service-endpoint.

    <endpoint address="YourEndPoint/Address" binding="YourBinding" behaviorConfiguration="singleFileEndpointBehavior" contract="IYourContract">
    

This worked fine for me. You can also download a full example from the WCFExtras project page: ProjectPage

Edit: For the sake of completeness: You can use the ''?singleWsdl'' query parameter since .NET 4.5 as stated in Irwins answer. See the link he posted for more details.

like image 31
Philipp Grathwohl Avatar answered Oct 19 '22 08:10

Philipp Grathwohl