生成的元数据(WSDL)中的.net 4 WCF端点指向节点而不是负载平衡(NLBS)IIS6上托管的虚拟主机

guu*_*lee 4 wcf wsdl iis-6 .net-4.0 nlb

这很简单.我有一个wcf服务(没什么特别的,只是新项目 - > WCF服务应用程序),在Visual Studio中运行良好.当我将它部署到集群IIS6环境时,它主要工作.我可以发送请求并得到回复.

但是,生成的元数据始终引用群集中的特定节点而不是群集虚拟名称.

https://clustername.test.com/WcfService1/Service1.svc
Run Code Online (Sandbox Code Playgroud)

在HTML中显示以下内容:

Service1 Service

You have created a service.

To test this service, you will need to create a client 
and use it to call the service. You can do this using 
the svcutil.exe tool from the command line with the 
following syntax:

svcutil.exe https://node1.test.com/DocrRetention/Service1.svc?wsdl
Run Code Online (Sandbox Code Playgroud)

它显示节点名称(node1.test.com)而不是群集名称.

https://clustername.test.com/WcfService1/Service1.svc?wsdl 
Run Code Online (Sandbox Code Playgroud)

显示以下xml:

...
    <wsdl:types>
        <xsd:schema targetNamespace="http://tempuri.org/Imports">
            <xsd:import schemaLocation="https://node1.test.com/WcfService1/Service1.svc?xsd=xsd0" namespace="http://tempuri.org/"/>
            <xsd:import schemaLocation="https://node1.test.com/WcfService1/Service1.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
            <xsd:import schemaLocation="https://node1.test.com/WcfService1/Service1.svc?xsd=xsd2" namespace="http://schemas.datacontract.org/2004/07/WcfService1"/>
        </xsd:schema>
    </wsdl:types>
...
    <wsdl:service name="Service1">
        <wsdl:port name="BasicHttpBinding_IService1" binding="tns:BasicHttpBinding_IService1">
            <soap:address location="https://node1.test.com/WcfService1/Service1.svc"/>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>
Run Code Online (Sandbox Code Playgroud)

再次,显示节点名称而不是虚拟主机.

那么我的web.config是什么样的?它很小所以我会展示整个事情.

<?xml version="1.0"?>
<configuration>

  <system.web>
    <customErrors mode="Off"/>
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding>
          <security mode="Transport"/>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="WcfService1.Service1">
        <endpoint binding="basicHttpBinding" contract="WcfService1.IService1"/>
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>
Run Code Online (Sandbox Code Playgroud)

Lad*_*nka 7

据我所知,WSDL中的URL默认来自托管服务器.某些KB for .NET 3.5 SP1引入了新行为,可以使用来自主机头的URL.此行为也包含在.NET 4.0中.检查:useRequestHeadersForMetadataAccess.在这个月底的文章您有此行为的一些描述.