Does not return in a json format but instead in a xml format

I got issue in my wcf service library because I already set the webMessegeFormat to JSON format, but instead it returns the XML format. How can I fix this issue? Am i missing something?

Thank you so much in advance for those who will help :)

Here is my code:

public class Service : iService
{
    [WebInvoke(Method="GET",
        RequestFormat = WebMessageFormat.Json,
        UriTemplate="{id}/{name}/{age}/{sex}/{address}")]
    public Response Transaction(string id, string name, string age, string sex, string address)
    {
        return new Response()
        {
            ID = id,
            Name = name,
            Age = age,
            Sex = sex,
            Address = address
        };
    }
}

public class Response
{
    public string ID { get; set; }
    public string Name { get; set; }
    public string Age { get; set; }
    public string Sex { get; set; }
    public string Address { get; set; }
}

Here is my app config

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

  <system.serviceModel>
    <services>
      <service name="WcfEServiceLibrary.Service">
        <endpoint address="http://phws13:8732/WcfServiceLibrary/" 
                  binding="webHttpBinding" 
                  contract="WcfServiceLibrary.iService">
        </endpoint>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior>
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>

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

Answers


do you need to set the ResponseFormat to WebMessageFormat.Json

 [WebInvoke(Method = "GET", 
        ResponseFormat = WebMessageFormat.Json, 
        BodyStyle = WebMessageBodyStyle.Wrapped, 
        UriTemplate = "{id}/{name}/{age}/{sex}/{address}")]

Need Your Help

AudioQueue Bytes send to server

ios cocoa-touch core-audio audioqueue

i am using AudioQueues to get Chunks of audio samples.

Key Value in combobox lwuit?

java-me lwuit lwuit-list lwuit-combobox

I want to store and retrieve a key value associated with the comboBox. I have used only

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.