1
我想写一个使用WCF和它的wsHttpBinding获得来自另一台机器的数据运行的主机软件的主机/客户的风格体系,它是工作完全正常,当我使用同一台机器上的主机,但是当客户端在不同的机器上它不工作,并抛出一个EndpointNotFoundException:客户端无法连接
Unhandled Exception: System.ServiceModel.EndpointNotFoundException: There was no
endpoint listening at http://192.168.1.64/GettingStarted/CalculatorService that
could accept the message. This is often caused by an incorrect address or SOAP
action. See InnerException, if present, for more details. ---> System.Net.WebExc
eption: Unable to connect to the remote server ---> System.Net.Sockets.SocketExc
eption: A connection attempt failed because the connected party did not properly
respond after a period of time or established connection failed because connect
ed host has failed to respond 192.168.1.64:80
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddre
ss socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Sock
et s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state,
IAsyncResult asyncResult, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
at System.Net.HttpWebRequest.GetRequestStream()
at System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStre
am()
我以为我已经因为我使用的IP地址正确地完成它主机在地址而不是本地主机,但它不工作,我不知道为什么。下面是服务库我App.config文件:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
<service name="WcfServiceLibrary1.Service1">
<host>
<baseAddresses>
<add baseAddress="http://192.168.1.64/Design_Time_Addresses/WcfServiceLibrary1/Service1/" />
</baseAddresses>
</host>
<endpoint address="http://192.168.1.64/host" binding="wsHttpBinding" contract="WcfServiceLibrary1.IService1">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
这里是客户端控制台App.config文件(没有什么在App.config主机控制台:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService1">
<security mode="None"></security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://192.168.1.64/GettingStarted/CalculatorService"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService1"
contract="ServiceReference1.IService1" name="WSHttpBinding_IService1">
</endpoint>
</client>
</system.serviceModel>
</configuration>
以及客户端控制台的代码:??
ServiceReference1.Service1Client proxy = new ServiceReference1.Service1Client();
Console.WriteLine(proxy.InnerChannel.RemoteAddress);
Console.WriteLine(proxy.SayHello("Henry"));
Console.WriteLine(proxy.OsDetails());
Console.ReadKey(true);
proxy.Close();
我在做什么错了/不这样做,当客户是另一台机器上它不连接是否是与安全这是那部分每当试图制作WCF服务时,我都会陷入困境,所以我非常感谢一些帮助。谢谢。
防火墙端口是否打开? – LueTm
“(没有什么在App.config主机控制台” - 库不使用包含在库项目中的配置文件 - 它们使用的是使用该库的应用程序的配置文件尝试移动。 。''从库的App.config到控制台'App.config' –
Tim
设置我已经做到了,但它给了我在主机的错误: 未处理的异常信息:System.ArgumentException:此集合中已包含方案http的地址。可以有这个集合中每个方案中最多只有一个地址。如果你的服务是在IIS osted^h 你可以通过设置“system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled”为真或指定'解决问题system.serviceModel/serviceHostingEnvironment/baseAdd ressPrefixFilters'。 –