当我发布WSDL服务时,ASP.NET使用计算机名而不是域名。如何防止这种情况发生?
示例:
<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"/>发布于 2009-08-07 21:00:25
您无法阻止这种情况的发生--至少不能仅使用配置开关或类似的东西。
你也许可以通过阅读这篇文章来解决你的问题--这一章描述了你遇到的确切问题和可能的解决方案:
另一位聪明的先生在同样的问题上遇到了一些问题:
http://www.leastprivilege.com/HostHeadersSSLAndWCFMetadata.aspx
Marc
发布于 2010-09-22 08:24:13
只是为了让未来的访问者发现这个问题的正确答案:上面的评论者是不正确的。您可以通过更改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>重要的部分是get urls、标识和baseAddresses。
https://stackoverflow.com/questions/1246969
复制相似问题