【问题标题】:In IIS hosted WCF services, how to disable address translation?在 IIS 托管的 WCF 服务中,如何禁用地址转换?
【发布时间】:2009-08-07 20:57:07
【问题描述】:

当我发布我的 ASP.NET WCF 服务时,WSDL 使用机器名而不是域名。如何预防?

例子:

<wsdl:import namespace="http://ListenerService" 
     location="http://MACHINE_NAME/ListenerService/service.svc?wsdl=wsdl0"/>
<soap:address location="http://MACHINE_NAME/ListenerService/service.svc"/>

当我真正想要时:

<wsdl:import namespace="http://ListenerService" 
     location="http://MYDOMAIN.COM/ListenerService/service.svc?wsdl=wsdl0"/>
<soap:address location="http://MYDOMAIN.COM/ListenerService/service.svc"/>

【问题讨论】:

    标签: .net asp.net wcf iis wsdl


    【解决方案1】:

    你无法阻止这种情况的发生——至少不能仅仅通过配置开关或类似的东西。

    您可能可以通过查看本文来解决您的问题 - 一个描述您遇到的确切问题以及可能的解决方法的章节:

    http://www.codemeit.com/wcf/wcf-wsdl-xsdimport-schemalocations-link-to-local-machine-name-not-domain-name-while-hosted-in-iis.html

    另一位聪明的绅士在同样的问题上遇到了一些问题:

    http://www.leastprivilege.com/HostHeadersSSLAndWCFMetadata.aspx

    马克

    【讨论】:

      【解决方案2】:

      只是为了让未来的访问者发现这个问题的正确答案:上述评论者不正确。您可以通过更改 web.config 中的几个选项来解决此问题。这是我的设置方式:

      <system.serviceModel>
          <services>
            <service name="ourWebService.ourService" behaviorConfiguration="ourWebService.ourServiceBehavior">
          <host>
                  <baseAddresses>
                      <add baseAddress="http://oursitename.com:83/ourService.svc" />
                  </baseAddresses>
              </host>
              <endpoint bindingNamespace="http://oursitename.com:83/ourService.svc" 
              address="" binding="basicHttpBinding" contract="ourIWebService.IourService" 
              bindingConfiguration="customBinding2">
                <identity>
                  <dns value="oursitename.com" />
                </identity>
              </endpoint>
              <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            </service>
          </services>
          <bindings>
          <basicHttpBinding>
              <binding name="customBinding2" >
                <readerQuotas maxArrayLength="2147483" maxStringContentLength="2147483647" maxNameTableCharCount="2147483647" />
              </binding>
            </basicHttpBinding>
          </bindings>
          <behaviors>
            <serviceBehaviors>
              <behavior name="ourWebService.ourServiceBehavior" httpGetUrl="http://oursitename.com:83/ourService.svc">
                <serviceMetadata httpGetEnabled="true" httpGetUrl="http://oursitename.com:83/ourService.svc/mex"/>
                <serviceDebug includeExceptionDetailInFaults="true" />
              </behavior>
            </serviceBehaviors>
          </behaviors>
        </system.serviceModel>
      

      重要的位是获取网址、身份和基本地址。

      【讨论】:

        猜你喜欢
        • 2011-12-05
        • 2012-06-06
        • 1970-01-01
        • 1970-01-01
        • 2022-12-13
        • 2020-04-26
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多