2014-03-19 175 views
0

我创建了一个WCF应用程序,该应用程序必须可以在Internet上访问。 我使用IIS在WS2008 R2服务器上部署了此应用程序。此服务器有一个专用IP,但我配置端口35000上的NAT重定向。使用公共IP部署WCF服务

当我在Web浏览器上放置正确的URI(使用公共IP)时,我可以正确显示服务页面,但IIS生成的链接显示WSDL是不正确的,我有服务器的名称,而不是公网IP的是这样的:的

http://serverName:35000/ServiceName.svc?wsdl 

代替

http://publicIP:35000/ServiceName.svc?wsdl 

所以当我点击链接,服务器名称不能被解析。

在我的web.config文件中,我添加了一个具有正确IP的端点,并且我也尝试添加一个标识标签和DNS标签与公共IP,但它不起作用。

这是我的web.config:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <system.serviceModel> 
    <services> 
     <service name="myNamespace.ServiceName.svc"> 
     <endpoint address="http://xxx.xxx.xxx.xxx:35000/myNamespace/ServiceName/" binding="wsHttpBinding" contract="myNamespace.IServiceName"> 
      <identity> 
      <dns value="xxx.xxx.xxx.xxx" /> 
      </identity> 
     </endpoint> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 
<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 
</configuration> 

这是WSDL的末尾:

<wsdl:service name="ServiceName"> 
    <wsdl:port name="BasicHttpBinding_IServiceName" binding="tns:BasicHttpBinding_IServiceName"> 
<soap:address location="http://serverName:35000/ServiceName.svc"/> 
</wsdl:port> 
</wsdl:service> 

我也尝试在IIS中的公网IP添加为主机名,但我得到一个错误。

感谢您的帮助

回答

0

的解决方案是增加MEX终结点:

<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 

和它的作品完美...