Using svcutil to generate xsd files for client proxy

SkeetJon picture SkeetJon · Jan 9, 2012 · Viewed 16k times · Source

I am trying to use Svcutil to export metadata for proxy generation off a locally hosted service. I dont want to go into visual studio and click 'Add service reference' as this is a learning exercise on my part(!)

I am using svcutil as follows:

Svcutil /d:c:\temp /t:metadata http://localhost/IISCalculatorService/service.svc

This then generates two WSDL files, calculatorservice.wsdl and tempuri.org.wsdl. However I was expecting it to generate two .XSD files as well. Without these .XSD files I cant use svcutil to then generate the client code.

Am I missing something in my use of svcutil or is my understading fauly? Any help appreciated.

Here's the service's web.config

<?xml version="1.0"?>
<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.0"/>
    </system.web>
  <system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior>
          <serviceMetadata httpGetEnabled="true"/>
                    <serviceDebug includeExceptionDetailInFaults="false"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
        <services>
            <service name="CalculatorService.Calculator">
                <endpoint address="" binding="basicHttpBinding" contract="CalculatorService.Contracts.ICalculator" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            </service>
        </services>
    </system.serviceModel>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
    </system.webServer>
</configuration>

Answer

KMan picture KMan · Jan 9, 2012

Use disco.exe to generate XSD files. http://msdn.microsoft.com/en-us/library/cy2a3ybs%28v=vs.80%29.aspx

Open Visual Studio Command Prompt and write disco http://localhost/IISCalculatorService/service.svc