WCF 发现找到端点但地址是 localhost [英] WCF discovery finds the endpoint but the address is localhost

查看:70
本文介绍了WCF 发现找到端点但地址是 localhost的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为GetNameService"的 wcf 可发现服务,它托管在 PC @ 10.0.0.5:8732 上.它由 wsHttpBinding 托管,可通过 UdpEndpoint 发现.我还有一个客户端@ 10.0.0.9,它在同一网络中发现此类服务.当我运行客户端时,我能够发现该服务,但发现的服务的终点是其中包含 localhost.这怎么会发生,请帮我解决这个问题.

I have a wcf discoverable service called "GetNameService" which is hosted on a PC @ 10.0.0.5:8732. It is hosted with wsHttpBinding and is discoverable thru' UdpEndpoint. I also have a client @ 10.0.0.9 which discovers for such services in the same network. When I ran the client, I am able to discover the service but the end point of the service discovered is having localhost in it. How can this happen, please help me out in this.

更多信息,

使用的 App.config

App.config used

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

 <system.web>
  <compilation debug="true" />
 </system.web>
 <!-- When deploying the service library project, the content of the config file must be added to the host's
 app.config file. System.Configuration does not support config files for libraries. -->
 <system.serviceModel>
  <services>
   <service name="NameService.GetNameService">
    <host>
     <baseAddresses>
      <add baseAddress = "http://10.0.0.5:8732/Design_Time_Addresses/NameService/GetNameService/" />
     </baseAddresses>
    </host>
    <!-- Service Endpoints -->
    <!-- Unless fully qualified, address is relative to base address supplied above -->
    <endpoint address ="" binding="wsHttpBinding" contract="NameService.IGetNameService">
     <!--
       Upon deployment, the following identity element should be removed or replaced to reflect the
       identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
       automatically.
     -->
     <identity>
      <dns value="localhost"/>
     </identity>
    </endpoint>
    <!-- Metadata Endpoints -->
    <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
    <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
   </service>
  </services>
  <behaviors>
   <serviceBehaviors>
    <behavior>
     <!-- To avoid disclosing metadata information,
     set the value below to false and remove the metadata endpoint above before deployment -->
     <serviceMetadata httpGetEnabled="True"/>
     <!-- To receive exception details in faults for debugging purposes,
     set the value below to true. Set to false before deployment
     to avoid disclosing exception information -->
     <serviceDebug includeExceptionDetailInFaults="False" />
    </behavior>
   </serviceBehaviors>
  </behaviors>
 </system.serviceModel>

</configuration>

我在客户端机器上打开浏览器并输入服务地址,我可以看到服务详细信息页面,但 wsdl 链接仍然指向 localhost(如下所示)

I opened up the browser in the client machine and typed the service address, I get to see the service details page but still the wsdl link points to localhost (shown below)

svcutil.exe http://localhost:8732/Design_Time_Addresses/NameService/GetNameService/?wsdl

svcutil.exe http://localhost:8732/Design_Time_Addresses/NameService/GetNameService/?wsdl

代替

svcutil.exe http://10.0.0.5:8732/Design_Time_Addresses/NameService/GetNameService/?wsdl

svcutil.exe http://10.0.0.5:8732/Design_Time_Addresses/NameService/GetNameService/?wsdl

此外,同样的应用程序似乎可以在我的工作场所工作,那里有可用的 dns 并且系统通过交换机连接,因为它在我家中的电脑上不起作用通过路由器连接.这会影响什么吗?!?

更新它不是在 IIS 中运行,而是通过一个普通的控制台应用程序托管

Update It is not running in IIS, it is hosted thru' a normal console application

推荐答案

如果您在 IIS 上运行,则您的站点必须具有默认主机名规则:

If you are running on IIS, you have to have a default hostname rule for your site:

  1. 打开 IIS
  2. 右键点击您的网站,然后点击属性"
  3. 点击网站"标签,然后点击网站标识"标题下的高级"按钮
  4. 您应该拥有网站的默认身份(TCP 端口 8732).编辑它并确保主机标头值是您网站的域名(因此它应该显示为 www.yourdomain.com)

请参阅 http://forums.asp.net/p/1096811/1659596.aspx 来自更多细节.

See http://forums.asp.net/p/1096811/1659596.aspx from more details.

这篇关于WCF 发现找到端点但地址是 localhost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆