开发者

What is the best method to call an arbitrary JSON server from .NET (Specifically Windows Phone 7)

开发者 https://www.devze.com 2022-12-26 19:38 出处:网络
I have a server that I have开发者_如何学编程 no control over, it\'s JSON based and I\'ve put together a simple proof of concept that calls the server using HTTPWebRequest etc and it works fine (if a l

I have a server that I have开发者_如何学编程 no control over, it's JSON based and I've put together a simple proof of concept that calls the server using HTTPWebRequest etc and it works fine (if a little wordy since MS have removed all Synchronous I/O calls).

Is there a better way of doing this? I've been looking at WCF as an option but any stable and reasonably performant library should do the job. This is a new area for me so I'm a little unsure what the best practice is (or where to find it out)

Thanks in advance

Dave


Not sure whether it's the best method, but HttpWebRequest plus DataContractJsonSerializer are probably the best approach using classes from the Windows Phone library only -- plus HttpWebRequest's asynchronous methods ensure that your code won't block the UI thread when performing network requests.


Once you've written the http request code once, you can easily abstract it away for reuse. You've already done the hard part :-)

0

精彩评论

暂无评论...
验证码 换一张
取 消