我无法使用 WCF 指定连接地址
本文关键字:连接 地址 WCF | 更新日期: 2023-09-27 18:34:12
客户端有这样的目标地址,如下所述。
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService1" />
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8080/ConsoleService/" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IService1" contract="ServiceReference1.IService1"
name="WSHttpBinding_IService1">
<identity>
<userPrincipalName value="KIRILL-PC'Кирилл" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
服务器具有此配置。
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<services>
<service name ="WcfServiceLibrary1.Service1"
behaviorConfiguration ="ConsoleServiceMEXBehavior">
<endpoint address ="mex"
binding ="mexHttpBinding"
contract ="IMetadataExchange" />
<endpoint address =""
binding ="wsHttpBinding"
contract ="WcfServiceLibrary1.IService1" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/ConsoleService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name ="ConsoleServiceMEXBehavior">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
然后我尝试发送smth,程序给出了错误
System.ServiceModel.EndpointNotFoundException
防火墙已禁用,两台 PC 位于同一网络上。
这就是为什么我请求帮助我解决这个问题的原因。
当您尝试访问另一台计算机时,请替换
http://localhost:8080/ConsoleService/
与另一台机器的网络地址,例如
http://othermachine:8080/ConsoleService/
确保端口号正确。也许是端口 80。