在WCF Restful Service中找不到端点 [英] End Point Not found in WCF Restful Service

查看:76
本文介绍了在WCF Restful Service中找不到端点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在创建一个示例wcf服务来测试我的一个客户端。

我使用SOAP获得结果,但REST无效。它显示未找到端点错误。

这是我的Web.Config for WCF服务。任何人都可以告诉我这个配置文件有什么问题。



Hi,
I am creating a sample wcf service to test with one of my client.
I am getting result using SOAP, But REST is not working. It shows "Endpoint Not Found" error.
Here is my Web.Config for WCF service. Can anybody tells me what's wrong with this config file.

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

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="web">
          <!-- 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>
    <endpointBehaviors>
      <behavior name="restbehavior">
        <webHttp/>
      </behavior>
    </endpointBehaviors>
    </behaviors>
    
    
    <services>
      <service name ="s2HCloudService.Service1"

      behaviorConfiguration="web" >
 
        <endpoint name ="SOAPEndPoint"

        contract ="s2HCloudService.IService1"

        binding ="basicHttpBinding"

        address ="soap" />
        
        <endpoint name ="RESTEndPoint"

        contract ="s2HCloudService.IService1"

        binding ="webHttpBinding"

        address ="rest"

        behaviorConfiguration ="restbehavior"/>
 
        <endpoint contract="IMetadataExchange"

        binding="mexHttpBinding"

        address="mex" />
      </service>
    </services>
      
    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
    -->
    <directoryBrowse enabled="true"/>
  </system.webServer>

</configuration>

推荐答案

通过REST协议使服务可用需要使用的绑定是webHttpBinding。此外,我们需要设置端点的行为配置并在endpointBehavior中定义webHttp参数。

关于创建WCF的初学者教程REST服务 [ ^ ]
To make the service available over REST protocol the binding that needs to be used is the webHttpBinding. Also, we need to set the endpoint's behavior configuration and define the webHttp parameter in the endpointBehavior.
A Beginner's Tutorial on Creating WCF REST Services[^]


这篇关于在WCF Restful Service中找不到端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆