Can I use Json serialization in WCF service?
Asked Answered
G

1

1

I am going develop a WPF windows based application. I want to work with Entity Framework Self Tracking Entities and WCF. I was wondering if using Json is possible/recommended? If yes, please assist me; is there any tutorial that can help?

Guitarist answered 10/7, 2011 at 18:18 Comment(0)
A
4

You can use the DataContractJsonSerializer to serialize the messages. You will have to use a REST based service (WebHttpBinding) as SOAP mandates XML as the message payload.

You can tell WCF to use the DatcontractJsonSerializer on the service side by settings in the WebGet and WebInvoke attributes but on the client side you will have to manually use this serializer as REST doesn;t have a metadata standard and therefore you have to create the requests and manage responses in a more manual fashion

Here is a reasonable guide to using Json and REST support in WCF

However, what is your driver to using Json? WCF is much more geared to SOAP based interaction currently (although the WCF 4.5 WebApi is going to address that to quite a degree). As your client is WPF you don't seem to gain alot from using Json

Anisometric answered 10/7, 2011 at 18:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.