WCF服务“找不到默认端点元素”

时间:2014-03-07 12:54:24

标签: wcf-binding

大约一周前,我第一次开始使用WCF,到目前为止,我觉得我没有取得任何进展。我正在使用Visual Studio 2010,.NET 4.0(据我所知,还安装了4.5)和Windows 7专业版。

目前的问题是,我有一个WCF服务和一个客户端。当我运行客户端时,以下行导致异常:

Dim client As ABC_webservice.IService1 = New ABC_webservice.Service1Client

在此处发布代码之前,我稍微更改了服务的实际名称。

这会导致以下异常:

Could not find default endpoint element that references contract
'ABC_webservice.IService1' in the ServiceModel client configuration section. 
This might be because no configuration file was found for your application, or 
because no endpoint element matching this contract could be found in the client
element.

这是webservice项目的App.config的相关部分:

<?xml version="1.0"?>
<configuration>

  <system.serviceModel>

    <behaviors>
      <serviceBehaviors>
        <behavior name="MEX">
          <serviceMetadata/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

    <bindings>
      <netNamedPipeBinding>
        <binding name="NamedPipeBinding" receiveTimeout="10:01:00" sendTimeout="00:01:00" transferMode="Streamed" maxReceivedMessageSize="4294967294" maxBufferSize="65536"/>
      </netNamedPipeBinding>
      <netTcpBinding>
        <binding name="NetTcpBindingConf" receiveTimeout="10:01:00" sendTimeout="10:01:00" transferMode="Streamed" maxBufferSize="65536" maxReceivedMessageSize="4294967294"/>
      </netTcpBinding>
    </bindings>

    <services>
      <service behaviorConfiguration="MEX" name="ABC.ABC_webservice.ABC_webservice">
        <endpoint address="IService1" binding="netTcpBinding" name="NetTcpFileTransfer" contract="ABC.ABC_webservice.IService1"/>
        <endpoint address="IService1" binding="netNamedPipeBinding" bindingConfiguration="NamedPipeBinding" name="NetPipeFileTransfer" contract="ABC.ABC_webservice.IService1"/>
        <endpoint address="MEX" binding="mexTcpBinding" bindingConfiguration="" name="MetadatEndpoint" contract="IMetadataExchange" kind="" endpointConfiguration=""/>
        <host>
          <baseAddresses>
            <!-- <add baseAddress="http://localhost:8732/Design_Time_Addresses/ABC_webservice/Service1/"/> -->
            <add baseAddress="net.tcp://localhost:8732"/>
            <add baseAddress="net.pipe://localhost"/>
          </baseAddresses>
        </host>
      </service>
    </services>

  </system.serviceModel>

    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
    </startup>
</configuration>

这是客户端项目的app.config的相关部分:

<?xml version="1.0"?>
<configuration>

  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>

  <system.serviceModel>

    <bindings>
      <netNamedPipeBinding>
        <binding name="NetPipeFileTransfer" transferMode="Streamed" />
      </netNamedPipeBinding>
      <netTcpBinding>
        <binding name="NetTcpFileTransfer" />
      </netTcpBinding>
    </bindings>

    <client>
      <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
        contract="IMetadataExchange" />
      <endpoint address="net.tcp://localhost:8732/IService1" binding="netTcpBinding"
        bindingConfiguration="NetTcpFileTransfer" contract="ABC_webservice.IService1"
        name="NetTcpFileTransfer">
        <identity>
          <userPrincipalName value="LAPTOP-XYZ\XYZ" />
        </identity>
      </endpoint>
      <endpoint address="net.pipe://localhost/IService1" binding="netNamedPipeBinding"
        bindingConfiguration="NetPipeFileTransfer" contract="ABC_webservice.IService1"
        name="NetPipeFileTransfer">
        <identity>
          <userPrincipalName value="LAPTOP-XYZ\XYZ" />
        </identity>
      </endpoint>
    </client>

  </system.serviceModel>

</configuration>

配置文件来自http://www.gonetdotnet.info/posts/wcf-articles/transfer-huge-file-to-wcf,但说实话,我真的不知道我在做什么。

首先,我想为此错误找到解决方案。最终我正在尝试构建一个能够将文件从服务下载到客户端的Web服务和客户端组合。目前,我的笔记本电脑上的服务和客户端都在运行,我希望在避免出现安全问题的同时首先使用该服务,但最终客户端和服务将在互联网上的不同服务器上运行,我猜这个过程有用证书担保。任何帮助将不胜感激。

0 个答案:

没有答案
相关问题