Solved

Switching WCF with http binding from XML to JSON

Posted on 2013-11-20
9
525 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
9 Comments
 
LVL 25

Accepted Solution

by:
apeter earned 450 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 50 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
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

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Here I am going to explain creating proxies at runtime for WCF Service. So basically we use to generate proxies using Add Service Reference and then giving the Url of the WCF service then generate proxy files at client side. Ok, what if something ge…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

705 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