Windows服务中的wcf服务主机 - 该程序无法找到终点

时间:2015-10-29 11:45:23

标签: .net wcf service communication 3-tier

我是三层项目的新成员和wcf所以我做了三层样本项目 -

当我安装wcf服务(我使用Windows服务网络服务)并打开我的Windows窗体exe,在同一台计算机上使用wcf服务它工作正常,但当我试图在另一台计算机上打开Windows窗体exe我收到错误消息: “无法在servicemodel客户端配置部分找到名称为”xxx“且合同为”xx.xx“的端点元素。这可能是因为找不到应用程序的配置文件”

我打开了我需要的端口,以便它可以工作,我尝试用ping命令检查计算机连接没有问题

我应该怎么做才能起作用?

这是我的配置文件:

我的wcf-service库的app.config:

  <system.serviceModel>
<services>
  <service behaviorConfiguration="WcfServiceBehavior" name="WcfServiceLibrary.Service1">
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration=""
      name="WcfSvcBasicHttpEndPoint" contract="WcfServiceLibrary.IStudent" />
    <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
      name="WcfSvcBasicMexHttpEndPoint" contract="WcfServiceLibrary.IStudent" />
    <endpoint binding="netTcpBinding" bindingConfiguration="" name="WcfSvcTcpEndPoint"
      contract="WcfServiceLibrary.IStudent" />
    <host>
      <baseAddresses>
        <add baseAddress="http://xxx:8080/service" />
        <add baseAddress="net.tcp://xxx:8181/service" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="WcfServiceBehavior">
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceMetadata httpGetEnabled="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

我的host-windows服务中的app.config - 它与wcf服务的配置相同。

用户界面的app.config(一个Windows窗体):

<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="WcfSvcBasicHttpEndPoint" />
  </basicHttpBinding>
  <netTcpBinding>
    <binding name="WcfSvcTcpEndPoint" />
  </netTcpBinding>
  <wsHttpBinding>
    <binding name="WcfSvcBasicMexHttpEndPoint">
      <security mode="None" />
    </binding>
  </wsHttpBinding>
</bindings>
<client>
  <endpoint address="http://xxx:8080/service" binding="basicHttpBinding"
    bindingConfiguration="WcfSvcBasicHttpEndPoint" contract="WcfServiceLibrary.IStudent"
    name="WcfSvcBasicHttpEndPoint" />
  <endpoint address="http://xxx:8080/service/mex" binding="wsHttpBinding"
    bindingConfiguration="WcfSvcBasicMexHttpEndPoint" contract="WcfServiceLibrary.IStudent"
    name="WcfSvcBasicMexHttpEndPoint" />
  <endpoint address="net.tcp://xxx:8181/service" binding="netTcpBinding"
    bindingConfiguration="WcfSvcTcpEndPoint" contract="WcfServiceLibrary.IStudent"
    name="WcfSvcTcpEndPoint">
    <identity>
      <userPrincipalName value="User-PC\User" />
    </identity>
  </endpoint>
</client>

我正在使用Windows窗体项目中名为“WcfSvcTcpEndPoint”的连接。

       protected override void OnStart(string[] args)
    {
        if (myServiceHost != null)
        {
            myServiceHost.Close();
        }
        myServiceHost = new ServiceHost(typeof(Service1));
        myServiceHost.Open();
    }

    protected override void OnStop()
    {
        if (myServiceHost != null)
        {
            myServiceHost.Close();
            myServiceHost = null;
        }
    }

提前致谢

0 个答案:

没有答案