WCF service hosting with endpoint creation?

1

I noticed that when executing a project of type Rest when open the interface, open the internet browser it lists all the contents of the folder, being necessary to select the ".svc" when executed the ".svc" and open a screen of WCF Test Client, is there any configuration to open at the correct address? My "web.config" looks like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>

  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>

  <system.web>
    <compilation debug="true" targetFramework="4.5">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
    <httpRuntime targetFramework="4.5" />
  </system.web>


  <system.serviceModel>

    <!--Adicionado -->
    <services>
      <service name="WcfRest.BookService">

        <endpoint address="" binding="webHttpBinding" contract="WcfRest.IBookService"  behaviorConfiguration="restfulBehavior" >
        </endpoint>

        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:3951/WcfRest/BookService.svc" />
          </baseAddresses>
        </host>


      </service>  
    </services>

    <!--Adicionado --> 

    <behaviors>

      <endpointBehaviors>
        <behavior name="restfulBehavior">
          <webHttp/>
        </behavior>
      </endpointBehaviors>

      <!--Adicionado -->

      <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>

    <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>

  <connectionStrings>
    <add name="SERRESTEEntities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=\SQLEXPRESS;initial catalog=SERRESTE;persist security info=True;user id=sa;password=**;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>

  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>
</configuration>

    
asked by anonymous 25.05.2015 / 16:37

1 answer

0

The WCFTestClient does not work to access WCF REST services. When you point the WCFTestClient for a service, it tries to access the metadata endpoint of the service, which describes all the operations, and the binding that needs to be used to access it. The metadata formats supported by WCF (WSDL and WS-Metadata) are used to describe SOAP services, not REST, so test client will not be able to consume your REST service, since it does not know how to do it.

Note that it may even be that some operation works - if you ask a WCF service for your metadata, it will do a "best effort" to respond. But in general, operations can not be accessed by test client .

If you want to know more, the post at link describes in more detail what I mentioned above.

    
26.05.2015 / 23:53