【问题标题】:Wrong URL in WSDL hyperlink when using WCF (https)使用 WCF (https) 时 WSDL 超链接中的 URL 错误
【发布时间】:2011-04-14 15:17:07
【问题描述】:

我的 WCF 服务使用 HTTPS 运行,它显示信息页,但“要测试此服务,...使用以下语法:”下面的 URL 是:

svcutil.exe https://servername.group.service.com/MyService.svc?wsdl(服务器的完整地址)

我怎样才能让它显示正确的 URL (<URL of the Service> + ?wsdl),而不是正确的 URL https://my.service.com/MyService.svc?wsdl(分配的主机头)?

<services>
  <service name="MyService" behaviorConfiguration="MyServer.MyServiceBehavior">
    <endpoint binding="basicHttpBinding" bindingConfiguration="basicHttpBigStrings" contract="IMyService">
    </endpoint>
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="MyService.MyServiceBehavior">
      <serviceCredentials>
        <serviceCertificate findValue="my.service.com" x509FindType="FindBySubjectName"/>
      </serviceCredentials>
      <serviceMetadata httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <basicHttpBinding>
    <binding name="basicHttpBigStrings">
      <security mode="Transport">
        <transport clientCredentialType="None"/>
      </security>
      <readerQuotas maxStringContentLength="1048576" />
    </binding>
  </basicHttpBinding>
</bindings>

我已经尝试将&lt;serviceMetadata httpsGetEnabled="true"/&gt; 更改为&lt;serviceMetadata httpsGetEnabled="true" httpsGetUrl="https://my.service.com/MyService.svc"/&gt;,但它只是说:“URI https://my.service.com/MyService.svc 的注册已经存在”

【问题讨论】:

  • 我也有同样的问题。你找到解决方案了吗?
  • 不,到目前为止还没有,抱歉...
  • 您是否在 IIS 中托管此服务?如果是这样,则 IIS 确定该 URL,而不是 WCF。
  • 我将它托管在 IIS 中,是的!来自 IIS 的 URL 是正确的,但是 WCF 生成并呈现在可读页面中的链接是错误的。

标签: .net wcf https mex


【解决方案1】:

您指定已设置主机标头。它是为 SSL 设置的还是只是为 Http 设置的。请记住,IIS UI 没有为 SSL 设置 Host-header 的字段。对于更高版本的 IIS,您需要使用管理脚本 (IIS 6.0) 或 netsh.exe。

【讨论】:

  • Host Header 只为 Http 设置,你有设置 SSL 的 Host Header 的链接吗?
  • 如何解决这个问题?
  • 阿米特 - 谢谢!!经过数小时寻找解决方案后,这成功了。我们删除了 http 和 https 的主机标头以适应我们的负载平衡器配置。重新添加它们可以解决问题。顺便说一句,在尝试通过 HTTPS 请求 WSDL 时,我们还看到了一个带有 400 错误请求错误的空白页面(对于遇到相同问题的任何人)。
【解决方案2】:

您可以在下面的 StackOverflow link 中找到有关这方面的一些背景知识——我会尝试的第一件事(他们给出了几个涉及更多的不同场景)是在服务端点定义上设置监听 URI。当我在我的应用程序中正确获取 WSDL 地址时遇到问题,我可以设置它来纠正它。在那种情况下,我只是试图修复该方案(我们在 BIGIP 之后并且它正在终止 SSL,因此该方案需要是 https,即使服务器端的 WCF 认为它正在获取 http)。

<endpoint address="https://www.sslloadbalancer.com" binding="someBinding" contract="IMyServiceInterface" listenUri="http://www.servicehost.com" ...  />

我相信这将为您修复 WSDL

【讨论】:

  • 服务托管在 IIS 中,所以 IIS 确定 URL,我无法在 config 中手动设置端点地址。
  • 我的示例来自 IIS 托管服务 - 您知道您在 IIS 上的哪个位置部署服务,那么为什么不能在配置中设置端点地址?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-12-02
  • 2014-03-08
  • 1970-01-01
  • 2010-12-14
  • 1970-01-01
  • 2015-06-02
  • 1970-01-01
相关资源
最近更新 更多