我无法使用WCF指定连接地址

时间:2013-10-06 19:53:50

标签: c# .net wcf visual-studio-2013

客户有这样的目的地址,如下所示。

<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都位于同一网络上。

这就是为什么我要求帮助我解决这个问题。

1 个答案:

答案 0 :(得分:1)

当您尝试访问其他计算机时,请替换

http://localhost:8080/ConsoleService/

使用其他计算机的网络地址,例如

http://othermachine:8080/ConsoleService/

确保端口号正确无误。也许它是80号港口。