使用 svcutil 为客户端代理生成 xsd 文件 [英] Using svcutil to generate xsd files for client proxy

查看:26
本文介绍了使用 svcutil 为客户端代理生成 xsd 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Svcutil 从本地托管服务导出用于代理生成的元数据.我不想进入 Visual Studio 并单击添加服务引用",因为这是我的学习练习(!)

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(!)

我使用 svcutil 如下:

I am using svcutil as follows:

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

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

这会生成两个 WSDL 文件,calculatorservice.wsdl 和 tempuri.org.wsdl.但是我希望它也生成两个 .XSD 文件.如果没有这些 .XSD 文件,我将无法使用 svcutil 生成客户端代码.

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.

我在使用 svcutil 时是否遗漏了某些东西,还是我的理解错误?任何帮助表示赞赏.

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

这是服务的 web.config

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>

推荐答案

如果直接找服务参考,可以试试这个

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

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

希望对你有帮助.

这篇关于使用 svcutil 为客户端代理生成 xsd 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆