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 7617265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:06:20+00:00 2026-05-31T03:06:20+00:00

I’m trying to implement a very simple WCF service that returns JSON. I’m trying

  • 0

I’m trying to implement a very simple WCF service that returns JSON. I’m trying for 6 hours now and it still doesn’t work. I hope you can help me out with this.

Person

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace Tcf.AtX.Services
{
    [DataContract]
    public class Person
    {
        [DataMember]
        public string Name { get; set; }
    }
}

Service Contract

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Web;

namespace Tcf.AtX.Services
{
    [ServiceContract]
    public interface IBroadcastService
    {
        /// <summary>
        /// Broadcasts the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <returns></returns>
        [OperationContract]
        [WebInvoke(Method="GET", ResponseFormat= WebMessageFormat.Json)]
        Person Broadcast(string message);
    }
}

Service Implementation

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tcf.AtX.Broadcasting;

namespace Tcf.AtX.Services
{
    public class BroadcastService : IBroadcastService
    {
        /// <summary>
        /// Broadcasts the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <returns></returns>
        public Person Broadcast(string message)
        {
            return new Person() { Name = message };
        }
    }
}

Configuration

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

  <system.web>
    <compilation debug="true"/>
  </system.web>
  <system.serviceModel>
    <services>
      <service name="Tcf.AtX.Services.BroadcastService">
        <endpoint address="" binding="webHttpBinding" contract="Tcf.AtX.Services.IBroadcastService" behaviorConfiguration="json"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8732/Design_Time_Addresses/Tcf.AtX.Services/BroadcastService/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="json">
          <webHttp />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

The problem is that i don’t see the service inside the test client, so i can’t test my method.
I also wrote a test client myself, but i can’t create an instance of my service when i reference it to my project.

Can someone please explain to me what i’m doing wrong?

Best regards,

Rob

  • 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-05-31T03:06:21+00:00Added an answer on May 31, 2026 at 3:06 am

    The test client doesn’t work for non-SOAP endpoints (i.e., the one you have, which uses the WebHttpBinding). Try simply creating a program that tries to call the operation you have, something like the code below

    WebClient c = new WebClient();
    Console.WriteLine(
        c.DownloadString(
            "http://localhost:8732/Design_Time_Addresses/Tcf.AtX.Services/Broadcast?message=MyMessage"));
    

    One more thing, you’ll need to change the [WebInvoke(Method="GET")] attribute to [WebGet].

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

Sidebar

Related Questions

I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,

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.