Config file error when using Wcf service with Ajax request

I have a problem consuming a WCF service using jquery. I got the error "Could not find configuration binding extension" system.serviceModel / bindings / webHttpbinding. Make sure this binding extension is registered correctly in system.serviceModel / extensions / bindingExtensions and that it is spelled correctly. "

Here is my Web.Config file:

<system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <webHttpBinding>
        <binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true" />
      </webHttpBinding>
    </bindings>
    <behaviors>
      <endpointBehaviors>
        <behavior name="RestfulServiceBehavior">
          <webHttp helpEnabled="true"/>
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="WebServiceBehavior">

          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="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>
    <services>
      <service name="WcfService1.RestfulServiceImp" behaviorConfiguration="WebServiceBehavior">
        <endpoint address="" behaviorConfiguration="RestfulServiceBehavior" 
             bindingConfiguration="webHttpBindingWithJsonP" binding="webHttpbinding" contract="WcfService1.IRestfulServiceImp"/>
        <!--<endpoint address="mex" binding="mexHttpBinding" contract="WcfService1.IRestfulServiceImp"/>-->
        <endpoint address="soap" binding="basicHttpBinding" contract="WcfService1.IRestfulServiceImp"/>
      </service>
    </services> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"  aspNetCompatibilityEnabled="false"/>

  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
        <add name="Access-Control-Allow-Headers" value="Content-Type" />
      </customHeaders>
    </httpProtocol>
  </system.webServer>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel"
          switchValue="Information, ActivityTracing"
          propagateActivity="true">
        <listeners>
          <add name="xml"
   type="System.Diagnostics.XmlWriterTraceListener"
   initializeData="c:\log\Traces.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>

      

This is my service name RestfulServiceImp and my contract is IRestfulServiceImp Please take a look at your valuable suggestions.

Thanks in advance.

+3


source to share


2 answers


There is a case mismatch in your configuration,

<bindings>
      <webHttpBinding>
        <binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true" />
      </webHttpBinding>
    </bindings>

      

and



<endpoint address="" behaviorConfiguration="RestfulServiceBehavior" 
             bindingConfiguration="webHttpBindingWithJsonP" binding="webHttpbinding" contract="WcfService1.IRestfulServiceImp"/>
        <!--<endpoint address="mex" binding="mexHttpBinding" contract="WcfService1.IRestfulServiceImp"/>-->
        <endpoint address="soap" binding="basicHttpBinding" contract="WcfService1.IRestfulServiceImp"/>

      

Check out the difference in case in webHttpBinding .. you used webHttpbinding instead of webHttpBinding.

+1


source


I don't have VS open at the moment to look at, but make sure it doesn't matter.

'system.serviceModel/bindings/webHttpbinding

      

vs



<webHttpBinding>

      

EDIT: So I opened VS and changed the binding name to lowercase and got the same error. Try to fix the difference in your case.

enter image description here

0


source







All Articles