tags:

views:

3019

answers:

2

Does anyone know of a good tool to generate the WSDL for a service contract written in C# (i.e. set of methods that are tagged as "[OperationContract]" using WCF)? All the tools I've found work the other way around: create code stubs from a WSDL. I don't want to have to hand-jam a WSDL file. I've found tools for php and J2EE, but not C#. Thanks!

+8  A: 

svcutil or just host it quickly and hit the MEX point :)

blowdart
+1  A: 

Easiest thing to do is host the service with a base address setup, and then just hit it from a browser with "?wsdl" appended to the end.

Here's an example of a service configuration with a base address specified. Note this goes in the <configuration><services> element in your config:

  <service name="MyServiceName" behaviorConfiguration="MyServiceBehavior">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:9000/MyService"/&gt;
      </baseAddresses>
    </host>
    <endpoint address="net.tcp://localhost:9001/MyService"
              binding="netTcpBinding"
              contract="IMyService"
              bindingConfiguration="MyServiceBinding"/>
  </service>

Once you get it hosted, just go to http://localhost:9000/MyService?wsdl to see the WSDL definition.