locked
Calling WCF REST JSON service from Javascript RRS feed

  • Question

  • User-1129879462 posted
    You cannot vote on your own post
    0

    http://localhost/WCFJSONService/Contact.svc/GetAll
    http://localhost/WCFJSONService/Contact.svc/GetContact/100

    These methods when used with web browser works as expected

    var serviceUrl = "http://10.33.17.17/WCFJSONService/Contact/GetAll"; $.ajax( { Type: 'GET', url: serviceUrl, dataType: 'json', contentType: 'application/json; charset=utf-8', success: function (data) { ServiceSucceeded(data); }, error: ServiceFailed } );

    Web.config:

    <?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>
        <services>
          <service name="WCFJSONService2.Contact">
            <!--<endpoint address="" behaviorConfiguration="WCFJSONService2.ContactAspNetAjaxBehavior" binding="webHttpBinding" contract="WCFJSONService2.IContacts" />-->
       <endpoint address="" behaviorConfiguration="REST" binding="webHttpBinding" contract="WCFJSONService2.IContacts" />
          </service>
        </services>
        <behaviors>
          <endpointBehaviors>
            <behavior name="REST">
     <enableWebScript/>
     <webHttp/>
      </behavior>
          </endpointBehaviors>
          <serviceBehaviors>
            <behavior name="">
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
              <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>
     
    </configuration>
    

    I get the error message:

    HTTP Error 404.0 - Not Found

    The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

    Any help would be appreciated.

    Tuesday, November 26, 2013 4:54 AM

Answers

All replies