RESTful windows phone - wcf

How do I transfer an object in RESTful web service? it seems like RESTful only supports string to exchange data between client and service. thanks

All web services only support the transfer of a representation of objects. Given the right client, you can easily generate objects with the information passed. For example, using JSON and a javascript client with jQuery, you can easily call jQuery.parseJSON(stringFromRESTServer); (or any number of methods in other good js libraries) to get a js object.

Related

Architectural Advice on designing a WCF contract to expose a desktop app functionality

We're currently working on exposing the functionality of a Windows Forms application via WCF services.
As an example, there is a form with multiple dropdowns in the desktop app. We would like to design a service that will allow a client to submit a request with all required values as if that client filled the info in the desktop app.
My question is:
What is the best way to expose allowable values for the dropdowns in the WCF service contract?
Enums in contract (Enumerations in DataCountract)
Shared assembly
Accept strings from client, on the server find the id or return an error
Note that some fields have a lot of allowable values (desktop app uses type ahead search).
How did you handle issues like this in your projects?
Thanks in advance
IMO, the best way is to use an enumeration in the DataContract (first option you listed).
It's much more interoperable than a .Net assembly (if you expose a SOAP webservice through WCF, you'll be able to consume it from other technologies).
And you won't need to manually parse a string, an exception will automatically be sent if the client tries to use an invalid value.

WCF to consume other REST Services?

I'm trying to figure out if the best way to consume and use a 3rd party API that is REST is to use WCF or just use System.Runtime.Serialization.Json Namespace or the WebClient object in .NET and create my own methods to send and receive json objects to and from the REST service I'm consuming.
So far I've only seen consuming REST json of an existing WCF service. Can you use WCF to consume and work with (request/response) any json based REST service outside of .NET?
Yes, you can consume Flickr services using WCF as described here. You just need to change the ResponseFormat in the WebGet (and WebInvoke) attributes to be Json.
However, my experience is that it is rather painful when you deal with stuff like error handling or complex authentication schemes. I found it simpler to manually write the client using the WebRequest class.

Can I use Json serialization in WCF service?

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?
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

Client Side Binding using by Converting the WCF Services to JSON

We have a Requirement of Consuming the WCf Services which is hosted in IIS like http://localhost/someservice.svc.
We would like to consume that Service via java script and bind my sample data controls called grid view on client side itself.
I think this can be done by Serializing and deserialzing to JSON and consume the data source and bind the grid controls.
Pls Refer the below link
http://forums.infragistics.com/forums/p/48035/258346.aspx
I would like to Achieve my func like the above link.
Can you pls guide me to achieve this Tasks.
Thanks
Regards
N.Balaji
Balaji,
Yes, you can definitely enable your WCF service (whether within IIS or not) to use JSON.
You do need to make one choice: do you want to use that service from the ASP .NET AJAX framework, or do you want to create a more general solution that is not tied down to that framework's usage within the browser?
If it's the former, use WebScriptEnablingBehavior. If it's the latter, use WebHttpBehavior.
For either scenario, detailed instructions are available in the following two MSDN sections:
AJAX Integration and JSON Support
WCF Web Http Programming Model

How to Consume JSON Web Services from a Windows Client

Is it possible to consume a JSON enabled WCF Web Service from a standard Proxy Client (i.e. not JavaScript)?
Basically I want to minimize the payload size between 2 web services.
Yes, it is, if the service interface definition on the client side is setup correctly (i.e. the RequestFormat/ResponseFormat properties of the WebGet/WebInvoke attribute on the operation contracts are set to Json. Also remember you'll need to use the WebHttp or WebScriptEnabled behaviors on your client.
Notice that JSon won't necessarily be most efficient given the current implementation in WCF; there are definite trade offs you'll be making. There's a good overview of it on this article.