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...
axnst2Asked:
Who is Participating?
 
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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.

All Courses

From novice to tech pro — start learning today.