Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8897373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:19:31+00:00 2026-06-15T00:19:31+00:00

I am writing a WCF service, (json REST) and I have it working fine

  • 0

I am writing a WCF service, (json REST) and I have it working fine when using the wcftestclient.exe

When I run that test tool it triggers my break points while debugging and everything works as expected.

but, when using a browser to navigate to the the service and method, no break point is triggered. it seems as though the request isnt even getting to the code.

I receieve no errors on when navigating with web browser to the service, it just doesn’t get any data, or trigger the break points.

Apologies if this is a duplicate, I have read and tried many many different configurations found in answers to similar questions, but nothing seems to work.

Many thanks for any help, I’ve posted my code below.

Martyn

I have setup:
ServiceContract

[OperationContract]
[WebGet(BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
List<Country> GetAllCountries();

The Service CLass:

    public List<Country> GetAllCountries()
    {
        ControlServiceRepository rep = new ControlServiceRepository();
        return rep.GetAllCountries().ToList() ;
    }

and my web config

<system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="OmniData" behaviorConfiguration="ServiceConfig">
        <!-- Service Endpoints -->
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:55641/"/>
          </baseAddresses>
        </host>
        <endpoint address="" binding="webHttpBinding" contract="ControlService.IOmniData" behaviorConfiguration="rest" />
      </service>
    </services>
      <behaviors>
        <endpointBehaviors>
          <behavior name="rest">
            <webHttp helpEnabled="true"/>
          </behavior>
        </endpointBehaviors>
        <serviceBehaviors>
          <behavior name="ServiceConfig">
            <serviceMetadata httpGetEnabled="true"/>
            <serviceDebug includeExceptionDetailInFaults="false"/>
          </behavior>
        <behavior>
          <!-- 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>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <standardEndpoints>
      <webHttpEndpoint>
        <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="false" defaultOutgoingResponseFormat="Json"/>
      </webHttpEndpoint>
    </standardEndpoints>
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:19:33+00:00Added an answer on June 15, 2026 at 12:19 am

    I got this working in the end by deleting all the end points in the config and using

    RouteTable.Routes.Add(new ServiceRoute("", new WebServiceHostFactory(), typeof(OmniData)));
    

    if anyone else has issues, this is even easier than setting up end points because you can just specify the type of responses and end points within the classes themselves.

    so:

    Add a global.asax if one does exist and include this:

    protected void Application_Start(object sender, EventArgs e)
            {
                RouteTable.Routes.Add(new ServiceRoute("", new WebServiceHostFactory(), typeof(OmniData)));
            }
    

    decorate your Service class with

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    

    here is mine:

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class OmniData : IOmniData
    {
      public Country[] GetAllCountries()
      {
        ControlServiceRepository rep = new ControlServiceRepository();
        return rep.GetAllCountries().ToArray() ;
      }
    }
    

    then the interface you setup your endpoing and types using WebGet or WebInvoke

    public interface IOmniData
        {
            [OperationContract]
            [WebGet(UriTemplate = "OmniData/GetAllCountries", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
            Country[] GetAllCountries();
        }
    

    the UriTemplate is the end point, so to access the method you would use: http://MyService.com/OmniData/GetAllCountries

    and finally, web config

    <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
        <standardEndpoints>
          <webHttpEndpoint>
            <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="false"/>
          </webHttpEndpoint>
        </standardEndpoints>
        <services>
          <service name="OmniData">
            <!-- Service Endpoints -->
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost:55641"/>
              </baseAddresses>
            </host>
            <endpoint address="" binding="webHttpBinding" contract="ControlService.IOmniData" behaviorConfiguration="rest" />
          </service>
        </services>
        <behaviors>
          <endpointBehaviors>
            <behavior name="rest">
              <webHttp />
            </behavior>
          </endpointBehaviors>
          <serviceBehaviors>
            <behavior name="Default">
              <serviceMetadata httpGetEnabled="true"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    

    Alot of help from here

    but, importantly for what I wanted, json results, you need to make sure:
    automaticFormatSelectionEnabled=”false” is in there so it will use the response format specified in the interface. Otherwise you end up with XML instead.

    hopefully this helps someone else

    And thanks again for fiddler!

    Martyn

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a REST WCF Service, and have it working for connections from
I have the following data model: I am writing a WCF service that needs
I have a WCF service that is responsible for writing a log file. I
I’m writing a WCF service that returns data in JSON format to clients. I
I have a WCF web service that used to work fine. Somewhere down the
I writing a WCF Service that need transfer large files, so i using streaming,
I'm writing a WCF Service to Upload file using REST. But my probleme come
I'm writing a WCF REST Service that has a mobile client. The mobile client
I am writing WCF service that uses wsHttpBinding binding, which is not hosted in
I am writing a WCF REST service, and I am needing to generate my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.