【问题标题】:WCF - auto generated WSDL not workingWCF - 自动生成的 WSDL 不起作用
【发布时间】:2014-04-10 09:32:54
【问题描述】:

我有一个 WCF 服务 MyService.svc,托管在 IIS 7 中。该服务的配置如下:

<system.serviceModel>
  <services>
      <service name="MyService">
          <endpoint address="" binding="basicHttpBinding" contract="MyPortType"></endpoint>
      </service>
  </services>
  <behaviors>
      <serviceBehaviors>
          <behavior name="defaultBehaviour">
              <serviceMetadata httpGetEnabled="true"  />
              <serviceDebug includeExceptionDetailInFaults="true" />
          </behavior>
      </serviceBehaviors>
  </behaviors>
</system.serviceModel>

问题是,我的服务不提供自动生成的 WSDL(将 ?wsdl 添加到服务的 URL),尽管我包含了标签

 <serviceMetadata httpGetEnabled="true"  />

如果我尝试通过 SoapUI 调用它,服务本身正在运行。当我尝试访问 WSDL 时,我收到 HTTP 错误 400 并且没有 WSDL 响应。

请务必注意,我使用 .NET 3.5 和 Visual Studio 2008 是出于遗留原因(它是一个旧应用程序)。数据契约是通过命令行使用 VS2008 中的 svcutil.exe 生成的。当我在 VS 2013/.NET 4.5(使用 VS2013 中的 svcutil.exe 重新生成数据合同类)下尝试相同的服务和相同的配置时,自动生成的 WSDL 出现没有问题。

如何才能让自动生成的 WSDL 在 .NET 3.5/VS2008 下工作?

谢谢你, 迈克尔

【问题讨论】:

    标签: c# .net wcf wsdl svcutil.exe


    【解决方案1】:

    将元数据端点添加到服务

    <services>
          <service name="MyService">
              <endpoint address="" binding="basicHttpBinding" contract="MyPortType"></endpoint>
         <endpoint address=”mex” binding=”mexHttpBinding” contract=”IMetadataExchange”/>
       </service>
    </services>
    

    【讨论】:

      【解决方案2】:

      如果您删除行为的名称,它应该会选择它。

         <serviceBehaviors>
            <behavior name="defaultBehaviour">
                <serviceMetadata httpGetEnabled="true"  />
                <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
        </serviceBehaviors>
      

            <serviceBehaviors>
            <behavior>
                <serviceMetadata httpGetEnabled="true"  />
                <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
        </serviceBehaviors>
      

      【讨论】:

      • 我试过这个,不幸的是它不起作用。行为仍然相同。不过还是谢谢你。
      猜你喜欢
      • 1970-01-01
      • 2016-04-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-04
      • 1970-01-01
      相关资源
      最近更新 更多