简体   繁体   English

WCF服务无端点

[英]WCF Service no Endpoint

When I run WCF Test Client I get an error : 当我运行WCF测试客户端时,出现错误消息:

Error: Cannot obtain Metadata from localhost:52875/ControllersInfo.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. 错误:无法从localhost:52875 / ControllersInfo.svc获取元数据。如果这是您有权访问的Windows(R)Communication Foundation服务,请检查是否已在指定地址启用元数据发布。
Metadata contains a reference that cannot be resolved: localhost:52875/ControllersInfo.svc'. 元数据包含无法解析的引用:localhost:52875 / ControllersInfo.svc'。 There was no endpoint listening at localhost:52875/ControllersInfo.svc that could accept the message. 在localhost:52875 / ControllersInfo.svc上没有侦听终结点的端点可以接受该消息。 This is often caused by an incorrect address or SOAP action. 这通常是由不正确的地址或SOAP操作引起的。 See InnerException, if present, for more details. 有关更多详细信息,请参见InnerException(如果存在)。

Here is my web.config file 这是我的web.config文件

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
  </system.web>
  <system.serviceModel>
    <standardEndpoints>
      <webHttpEndpoint>
        <standardEndpoint helpEnabled="true" automaticFormatSelectionEnabled="true" />
      </webHttpEndpoint>
    </standardEndpoints>
    <services>
      <service name="dev_FineReceiptsService.ControllersInfo">
        <endpoint kind="webHttpEndpoint" contract="dev_FineReceiptsService.IControllersInfo" />
      </service>
    </services>
  </system.serviceModel>
  <connectionStrings>
    <add name="FineReceiptsTestEntities" connectionString="metadata=res://*/FineTest.csdl|res://*/FineTest.ssdl|res://*/FineTest.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=msdev01;Initial Catalog=FineReceiptsTest;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
</configuration>

Can anyone tell me what I have done wrong ? 谁能告诉我我做错了什么?

I tried to find similar question but none of them helped me. 我试图找到类似的问题,但是没有一个人帮助我。

Your service is REST-based service (since you specified the webHttpBinding ). 您的服务是基于REST的服务(因为您指定了webHttpBinding )。

However, the WCF Test Client is a SOAP-based testing tool - you can test SOAP service with this - basicHttpBinding , wsHttpBinding etc. 但是,WCF测试客户端是基于SOAP的测试工具-您可以使用此工具测试SOAP服务basicHttpBindingwsHttpBinding等。

But you cannot use the SOAP-based WCF Test Client to test your REST-based WCF service... that won't work. 但是您不能使用基于SOAP的WCF测试客户端来测试基于REST的WCF服务……这是行不通的。 Use a regular web browser, potentially combined with Fiddler or something like that to test your REST services . 使用可能与Fiddler或类似工具结合使用的常规Web浏览器来测试REST服务。

Metadata endpoints expose WSDL + XSDs which describes SOAP services. 元数据端点公开了描述SOAP服务的WSDL + XSD。 There is no support for exposing metadata for REST. 不支持公开REST的元数据。 Since your are using webHttpEndpoint, you can not use WCFTestClient. 由于您使用的是webHttpEndpoint,因此无法使用WCFTestClient。 For testing a Rest Service, RestSharp or Browser can be used. 要测试Rest Service,可以使用RestSharp或Browser。

If you need to add metadata to SOAP service with simplfied configuration you need to add this behavior: 如果您需要使用简化的配置将元数据添加到SOAP服务中,则需要添加以下行为:

<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM