C# .NET - Restful service Setup - Asked By A S on 30-Jan-14 10:59 AM

Hi,

I am trying to create Restful service and I am getting following errors and how :


Configurations:-------------------------------------

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

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
       <service name="MyNameSpace.Services.Service1" behaviorConfiguration="ServiceBehaviour">
     
      <endpoint address="http://localhost:13158/service1"

          binding="webHttpBinding"

          contract="MyNameSpace.Services.IService1"
          
          behaviorConfiguration="rest" />

       </service>
   
    </services>
 
    <behaviors>

    <serviceBehaviors>
      <behavior name="ServiceBehaviour">

      <serviceMetadata httpGetBinding="true"/>
      <serviceDebug includeExceptionDetailInFaults="true" />
      
      </behavior>
      
    </serviceBehaviors>
    
    <endpointBehaviors>
     
      <behavior name="rest">
      
      <webHttp />
    
      </behavior>
    
    </endpointBehaviors>
 
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
 
</configuration>





ERROR:---------------------------------------------------------------------



Server Error in '/' Application.
Configuration binding extension 'system.serviceModel/bindings/true' could not be found. Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Configuration.ConfigurationErrorsException: Configuration binding extension 'system.serviceModel/bindings/true' could not be found. Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[ConfigurationErrorsException: Configuration binding extension 'system.serviceModel/bindings/true' could not be found. Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly.]
   System.ServiceModel.Configuration.ConfigurationHelpers.UnsafeGetAssociatedBindingCollectionElement(ContextInformation evaluationContext, String bindingCollectionName) +385
   System.ServiceModel.Description.ConfigLoader.GetBindingCollectionElement(String bindingSectionName, ContextInformation context) +12429959
   System.ServiceModel.Description.ConfigLoader.LookupBinding(String bindingSectionName, String configurationName, ContextInformation context) +22
   System.ServiceModel.Configuration.ServiceMetadataPublishingElement.CreateBehavior() +210
   System.ServiceModel.Description.ConfigLoader.LoadBehaviors(ServiceModelExtensionCollectionElement`1 behaviorElement, KeyedByTypeCollection`1 behaviors, Boolean commonBehaviors) +12326672
   System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress) +12392138
   System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, ServiceElement serviceSection) +67
   System.ServiceModel.ServiceHostBase.ApplyConfiguration() +108
   System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses) +192
   System.ServiceModel.ServiceHost.InitializeDescription(Type serviceType, UriSchemeKeyedCollection baseAddresses) +49
   System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses) +151
   System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses) +30
   System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +422
   System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1461
   System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +44
   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +651

[ServiceActivationException: The service '/Service1.svc' cannot be activated due to an exception during compilation.  The exception message is: Configuration binding extension 'system.serviceModel/bindings/true' could not be found. Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly..]
   System.Runtime.AsyncResult.End(IAsyncResult result) +688702
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +190
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, String routeServiceVirtualPath, Boolean flowContext, Boolean ensureWFService) +234
   System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +359
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75