[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Switching WCF with http binding from XML to JSON

Posted on 2013-11-20
9
Medium Priority
?
530 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
8 Comments
 
LVL 25

Accepted Solution

by:
apeter earned 1800 total points
ID: 39665518
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
ID: 39669066
Where would I add this exactly?  In the contract on the server side?
0
 
LVL 9

Assisted Solution

by:Grant Spiteri
Grant Spiteri earned 200 total points
ID: 39684224
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
2017 Webroot Threat Report

MSPs: Get the facts you need to protect your clients.
The 2017 Webroot Threat Report provides a uniquely insightful global view into the analysis and discoveries made by the Webroot® Threat Intelligence Platform to provide insights on key trends and risks as seen by our users.

 
LVL 25

Expert Comment

by:apeter
ID: 39757544
Not fair....
0
 

Author Comment

by:axnst2
ID: 39759341
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
ID: 39759358
I have contected the Moderator...we'll see what happens.  Again, I appologise!
0
 
LVL 25

Expert Comment

by:apeter
ID: 39770181
Thanks a lot axnst2 :)
0
 

Author Comment

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

Featured Post

When ransomware hits your clients, what do you do?

MSPs: Endpoint security isn’t enough to prevent ransomware.
As the impact and severity of crypto ransomware attacks has grown, Webroot has fought back, not just by building a next-gen endpoint solution capable of preventing ransomware attacks but also by being a thought leader.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
To properly understand GitHub, let’s divide it into two words ‘Git’ and ‘Hub’. Git is basically a ‘Distribution Version Control’ (DVC) and ‘Source Code Management’ (SCM) system widely used by software programmers while Hub means the efficient centre…
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…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

834 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