【发布时间】:2012-02-05 19:29:17
【问题描述】:
我正在尝试使用 Svcutil 导出元数据以从本地托管服务生成代理。我不想进入 Visual Studio 并单击“添加服务参考”,因为这是我的学习练习(!)
我使用svcutil如下:
Svcutil /d:c:\temp /t:metadata http://localhost/IISCalculatorService/service.svc
这会生成两个 WSDL 文件,calculatorservice.wsdl 和 tempuri.org.wsdl。但是我希望它也能生成两个 .XSD 文件。如果没有这些 .XSD 文件,我将无法使用 svcutil 生成客户端代码。
我在使用 svcutil 时是否遗漏了什么,或者我的理解错误?任何帮助表示赞赏。
这是服务的 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>
【问题讨论】:
-
您可以使用 svcutil
生成代理,然后如果您不想通过添加服务引用在项目中使用代理。如果您希望与 wsdl 相关的 xsd 验证其中的某些内容,那么您只需从 wsdl 中的指定 url 下载它并将其添加到您的项目中
标签: wcf proxy svcutil.exe