3

不太确定该问题的名称,但问题如下:

我正在 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>
4

3 回答 3

10

You can use the <useRequestHeadersForMetadataAddress> service behavior, and you should get the behavior you want:

<behaviors>
  <serviceBehaviors>
    <behavior name="CBBookingService.CBBookingServiceBehavior">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false"/>
      <dataContractSerializer maxItemsInObjectGraph="2147483647" />
      <useRequestHeadersForMetadataAddress />
    </behavior>
  </serviceBehaviors>
</behaviors>
于 2013-01-29T21:36:53.477 回答
2

您可以在配置中更改它。

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

或将https://stackoverflow.com/a/14592767/2012977用于 asp.net v4 或更高版本。

于 2013-01-29T21:48:14.313 回答
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>
于 2013-01-30T10:37:05.653 回答