Solved

Switching WCF with http binding from XML to JSON

Posted on 2013-11-20
9
517 Views
Last Modified: 2014-01-10
Hi Experts,

     I have a WCF service hosted in a windows service with http binding using XML format for the messaging.  How do I change it from XML to JSON?

Thanks in advance...
0
Comment
Question by:axnst2
  • 4
  • 3
9 Comments
 
LVL 25

Accepted Solution

by:
apeter earned 450 total points
Comment Utility
Decorate your wcf method with this

[WebInvoke(Method = "GET",
           RequestFormat = WebMessageFormat.Json,
           ResponseFormat = WebMessageFormat.Json,
           UriTemplate = "<method name>")]


Also you to have add in your config is "<webHttp/>" if it is not there .This should part of "behaviorConfiguration" value.
0
 

Author Comment

by:axnst2
Comment Utility
Where would I add this exactly?  In the contract on the server side?
0
 
LVL 9

Assisted Solution

by:Grant Spiteri
Grant Spiteri earned 50 total points
Comment Utility
Yes thats correct the attribute needs to be above your method, this can be either on the proxy implementation or on the method directly
0
 
LVL 25

Expert Comment

by:apeter
Comment Utility
Not fair....
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:axnst2
Comment Utility
I'm so sorry apeter, I didn't even look...I just assumed the second respons was yours too!  I will see what I can do to correct my mistake!
0
 

Author Comment

by:axnst2
Comment Utility
I have contected the Moderator...we'll see what happens.  Again, I appologise!
0
 
LVL 25

Expert Comment

by:apeter
Comment Utility
Thanks a lot axnst2 :)
0
 

Author Comment

by:axnst2
Comment Utility
No, thank you for the help!  I love this site!  You Experts save me so much time!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now