Using svcutil to generate xsd files for client proxy

谁说我不能喝 提交于 2019-12-10 09:52:49

问题


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>

回答1:


If you are looking for service reference directly, you can try this

svcutil.exe http://localhost/IISCalculatorService/service.svc?wsdl

Hope this helps you.




回答2:


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



来源:https://stackoverflow.com/questions/8785441/using-svcutil-to-generate-xsd-files-for-client-proxy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!