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

  • Home
  • SEARCH
  • 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 8443697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:12:28+00:00 2026-06-10T09:12:28+00:00

I have been asked to develop a WCF web service as a project for

  • 0

I have been asked to develop a WCF web service as a project for the first time. The web service is rather simple, it should just return a JSON object.
The problem is that the browser (chrome,f irefox) shows a blank page while trying to test the service using the browser. The WcfTestClient shows the JSON output correctly.

attached is my Code and the Web.config

So what am I doing wrong?
Thanks in advance.

Web.config:

<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="WcfService3.Service1" behaviorConfiguration="WcfService3.Service1Behavior">
        <!-- Service Endpoints -->
        <endpoint address="" binding="wsHttpBinding" contract="WcfService3.IService1">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WcfService3.Service1Behavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

IService1.cs:

namespace WcfService3
{
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        string GetData(string username, string password);
    }

    [DataContract]
    public class Data
    {
        [DataMember]
        public string Username { get; set; }

        [DataMember]
        public string Password { get; set; }
    }
}

Service1.svc.cs:

namespace WcfService3
{
    public class Service1 : IService1
    {
        [WebInvoke(Method = "GET", 
        RequestFormat = WebMessageFormat.Json,
        ResponseFormat = WebMessageFormat.Json,
        UriTemplate = "data/{user}/{pass}")]
        public string GetData(string user, string pass)
        {
            Data UserData = new Data()
            {
                Username = user,
                Password = pass
            };

            MemoryStream stream = new MemoryStream();
            DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Data));
            ser.WriteObject(stream, UserData);
            string json = Encoding.Default.GetString(stream.ToArray());
            return json;
        }  
    }
}
  • 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-10T09:12:29+00:00Added an answer on June 10, 2026 at 9:12 am

    To use in a webbrowser you need to implement the webHttpBinding rather than, or along with, wsHttpBinding.

    <services> 
      <service name="WcfService3.Service1" behaviorConfiguration="WcfService3.Service1Behavior"> 
        <!-- Service Endpoints --> 
        <endpoint address="" binding="webHttpBinding" behaviorConfiguration="webBehavior" contract="WcfService3.IService1"> 
          <identity> 
            <dns value="localhost"/> 
          </identity> 
        </endpoint> 
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
      </service> 
    </services> 
    

    also in Config:

      <endpointBehaviors> 
        <behavior name="webBehavior"> 
          <webHttp /> 
        </behavior> 
      </endpointBehaviors> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been asked by my supervisor to develop a web application using either
I have been asked to re-develop an old php web app which currently uses
I have been asked to look into FileMaker for creating a pretty simple database
I have been asked to implement some email address validation on a web app
I have been asked to develop a highly secure B2B File Transfer system between
I have recently been introduced to EasyMock and have been asked to develop some
I have been asked recently in a job interview to develop an algorithm that
I've been asked to develop a website for the iPad. It's going to have
I have been asked to develop an application which will use data available from
I have been asked to develop a system that collects data from a Sql

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.