首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在IIS托管的WCF服务中,如何禁用地址转换?

在IIS托管的WCF服务中,如何禁用地址转换?
EN

Stack Overflow用户
提问于 2009-08-07 20:57:08
回答 2查看 2.4K关注 0票数 1

当我发布WSDL服务时,ASP.NET使用计算机名而不是域名。如何防止这种情况发生?

示例:

代码语言:javascript
复制
<wsdl:import namespace="http://ListenerService" 
     location="http://MACHINE_NAME/ListenerService/service.svc?wsdl=wsdl0"/>
<soap:address location="http://MACHINE_NAME/ListenerService/service.svc"/>

当我真正想要的时候:

代码语言:javascript
复制
<wsdl:import namespace="http://ListenerService" 
     location="http://MYDOMAIN.COM/ListenerService/service.svc?wsdl=wsdl0"/>
<soap:address location="http://MYDOMAIN.COM/ListenerService/service.svc"/>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2009-08-07 21:00:25

您无法阻止这种情况的发生--至少不能仅使用配置开关或类似的东西。

你也许可以通过阅读这篇文章来解决你的问题--这一章描述了你遇到的确切问题和可能的解决方案:

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

Marc

票数 3
EN

Stack Overflow用户

发布于 2010-09-22 08:24:13

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

代码语言:javascript
复制
<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>

重要的部分是get urls、标识和baseAddresses。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1246969

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档