• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 535
  • 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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
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

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

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