【问题标题】:how to replace Machine Name with Domain name in WCF Service wsdl link如何在 WCF 服务 wsdl 链接中用域名替换机器名
【发布时间】:2013-01-13 12:18:53
【问题描述】:

不知道该如何命名这个问题,但问题如下:

我正在 IIS 6 上部署 WCF 服务,该服务将由外部源使用。 它所在的盒子是外部托管的,但有一个 DC,所以在我的网络上有效('mydomain'),内部它被称为'prod'说。 该服务需要通过 SSL 运行,因此我们获得了该服务将响应的域的 SSL 证书:service.oursite.com 可以说

DNS 已全部过滤,我确实可以打开该服务 https://service.oursite.com/service.svc 它踢出了小 svcutil 链接。 问题是链接指向的地址不是 https://service.oursite.com/service.svc?wsdl 如我所愿

它是

https://prod.mydomain.com/service.svc?wsdl 所以当然 SSL 保释,因为证书不是为了那个 如果我点击进入 wsdl,所有 schemaLocation 链接都是错误的,再次指向内部而不是外部名称

问题是: 为什么要这样做? 和 我该如何阻止它这样做?

是在配置中添加一些东西的问题吗? (请说是 :))

任何帮助都非常感激

如果有帮助,这里是配置

<services>
  <service name="CBBookingService.CBBookingService" behaviorConfiguration="CBBookingService.CBBookingServiceBehavior">
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="TransportSecurity" contract="CBBookingService.ICBBookingService" />
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
  </service>
</services>
<bindings>
  <basicHttpBinding>
    <binding name="BasicSecurity" maxReceivedMessageSize="2147483647">
      <security mode="None" />
    </binding>
    <binding name="TransportSecurity" maxReceivedMessageSize="2147483647">
      <!--https-->
      <security mode="Transport">
        <transport clientCredentialType="None" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="CBBookingService.CBBookingServiceBehavior">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false"/>
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
    </behavior>
  </serviceBehaviors>
</behaviors>

【问题讨论】:

    标签: c# .net wcf iis-6


    【解决方案1】:

    感谢您的回答 不幸的是,我使用的是 .net 3.5,所以下面的答案不起作用 我最终这样做了

     <system.serviceModel>
        <services>
          <service name="CBBookingService.CBBookingService" behaviorConfiguration="CBBookingService.CBBookingServiceBehavior">
            <endpoint address="https://service.oursite.com/CBBookingService.svc" binding="basicHttpBinding" bindingConfiguration="TransportSecurity" contract="CBBookingService.ICBBookingService" name="SSL" />
            <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
          </service>
        </services>
        <bindings>
          <basicHttpBinding>
            <binding name="BasicSecurity" maxReceivedMessageSize="2147483647">
              <security mode="None" />
            </binding>
            <binding name="TransportSecurity" maxReceivedMessageSize="2147483647">
              <!--https-->
              <security mode="Transport">
                <transport clientCredentialType="None" />
              </security>
            </binding>
          </basicHttpBinding>
        </bindings>
        <behaviors>
          <serviceBehaviors>
            <behavior name="CBBookingService.CBBookingServiceBehavior">
              <serviceMetadata httpsGetEnabled="true" httpsGetUrl="https://service.oursite.com/CBBookingService.svc/SSL" /> 
              <serviceDebug includeExceptionDetailInFaults="false"/>
              <dataContractSerializer maxItemsInObjectGraph="2147483647" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true">
        </serviceHostingEnvironment>
      </system.serviceModel>
    

    【讨论】:

    • 只是想说声谢谢!您的回答帮助我解决了我的问题
    【解决方案2】:

    您可以在配置中更改它。

    <serviceMetadata httpGetEnabled="true"  
     externalMetadataLocation="https://service.oursite.com/service.svc?wsdl"/>
    

    或者对于 asp.net v4 或更高版本使用https://stackoverflow.com/a/14592767/2012977

    【讨论】:

      【解决方案3】:

      你可以使用&lt;useRequestHeadersForMetadataAddress&gt;服务行为,你应该得到你想要的行为:

      <behaviors>
        <serviceBehaviors>
          <behavior name="CBBookingService.CBBookingServiceBehavior">
            <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
            <serviceDebug includeExceptionDetailInFaults="false"/>
            <dataContractSerializer maxItemsInObjectGraph="2147483647" />
            <useRequestHeadersForMetadataAddress />
          </behavior>
        </serviceBehaviors>
      </behaviors>
      

      【讨论】:

      • 这看起来是最好的选择,但遗憾的是我使用的是 .net 3.5,所以它不喜欢那个元素。从现在开始,当我使用 .net 4 时我会这样做 - 谢谢
      • 现在无法对其进行测试,但我认为这就是我无法让某些 WCF 服务在使用 SSL 证书的共享托管服务器上运行的原因。我认为这可以解决这个问题。确实验证了它适用于 .NET 4 WCF 服务(内部托管)。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-21
      • 1970-01-01
      • 1970-01-01
      • 2010-10-02
      • 1970-01-01
      相关资源
      最近更新 更多