简体   繁体   English

使用WCF服务时找不到端点元素

[英]Could not find endpoint element when consume WCF service

Getting the below error when trying to consume WCF service . 尝试使用WCF service时出现以下错误。 I looked into this issue and both name and contract values are same in both config files . I looked into this issue and both name and contract values are same in both config files

Could not find endpoint element with name 'BasicHttpBinding_IService1' and contract 'ServiceReference1.IService1' in the ServiceModel client configuration section. 在ServiceModel客户端配置部分中找不到名称为'BasicHttpBinding_IService1'和合同'ServiceReference1.IService1'的终结点元素。 This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element. 这可能是因为找不到您的应用程序的配置文件,或者是因为在客户端元素中找不到与该名称匹配的端点元素。

WCF service is class liberary in my solution and i am trying consume it in another class liberary project under same solution. WCF服务在我的解决方案中是类库,我正尝试在同一解决方案下的另一个类库项目中使用它。

Client.config 客户端配置

  <endpoint address="http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/"
    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
    contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" />
</client>

WCF config file WCF配置文件

<configuration>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <services>
      <service name="WcfServiceLibrary1.Service1">
        <host>
          <baseAddresses>
            <add baseAddress = "http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/" />
          </baseAddresses>
        </host>
        <!-- Service Endpoints -->
        <!-- Unless fully qualified, address is relative to base address supplied above -->
        <endpoint address="" binding="basicHttpBinding" contract="WcfServiceLibrary1.IService1">
          <!-- 
              Upon deployment, the following identity element should be removed or replaced to reflect the 
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
              automatically.
          -->
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <!-- Metadata Endpoints -->
        <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
        <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

</configuration>

I think your problem as you said in your question" You are trying to consume the service in a class library and calling the class library from another project." 我认为您的问题就像您在问题中所说的:“ You are trying to consume the service in a class library and calling the class library from another project." Refer to this link for original answer. 请参阅此链接以获取原始答案。 link 链接

To solve your issue you just need to copy client binding details to main caller project configuation file. 要解决您的问题,您只需要将客户端绑定详细信息复制到主调用方项目配置文件即可。

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IService1" />
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
        contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" />
    </client>
  </system.serviceModel>

Try fullname identifiers with complete namespaces for your service name and contract. 尝试使用具有完整名称空间的全名标识符来表示您的服务名称和合同。

<service name="SOLUTIONNAME.WcfServiceLibrary1.Service1">
     <endpoint address="" binding="basicHttpBinding" 
     contract="SOLUTIONNAME.WcfServiceLibrary1.IService1">
     ...

 </service>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用WCF服务 - 找不到默认端点元素 - Consume WCF Service - Could not find default endpoint element 当被其他类库访问时,类库中消耗的WCF服务给出“找不到端点元素……”错误 - WCF Service consumed in Class Library, when accessed by other Class Library gives “Could not find endpoint element…” Error 找不到名称为WCF的端点元素 - Could not find endpoint element with name WCF 在WCF客户端中找不到默认端点元素… - Could not find default endpoint element … in WCF Client WCF Web服务找不到端点元素 - WCF web service can not find endpoint element WCF 端点错误:找不到默认端点元素 - WCF Endpoint Error: Could not find default endpoint element 找不到引用合同的默认终结点元素(简单的WCF服务不起作用) - Could not find default endpoint element that references contract (simple WCF Service not working) 温莎WCF客户端-当配置中不存在时,“找不到默认端点元素” - Windsor WCF Client - “Could not find default endpoint element” when not present in config 找不到引用合同的默认端点元素 - 托管wcf - Could not find default endpoint element that references contract - Hosting wcf 例外:从RESTFUL服务调用Bing翻译服务时找不到默认端点元素 - Exception: Could not find default endpoint element when call Bing translate service from RESTFUL service
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM