• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 537
  • Last Modified:

Switching WCF with http binding from XML to JSON

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
axnst2
Asked:
axnst2
  • 4
  • 3
2 Solutions
 
apeterCommented:
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
 
axnst2Author Commented:
Where would I add this exactly?  In the contract on the server side?
0
 
Grant SpiteriSenior consultantCommented:
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
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
apeterCommented:
Not fair....
0
 
axnst2Author Commented:
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
 
axnst2Author Commented:
I have contected the Moderator...we'll see what happens.  Again, I appologise!
0
 
apeterCommented:
Thanks a lot axnst2 :)
0
 
axnst2Author Commented:
No, thank you for the help!  I love this site!  You Experts save me so much time!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now