适用于Android的Json WebService [英] Json WebService for Android

查看:55
本文介绍了适用于Android的Json WebService的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建在Json中提供响应的Android WebService.
像这样的示例响应:

{"StatusInfo":{"Status":"FAILED","StatusDescription":发生错误","ErrorCode":","ErrorMessage":","Validation":null},"DataSet":[名称:" Will," SanName:" Simth],[" Name:" Jony," SanName:" Dep]}


给我示例代码,因为我是asp.net的新手.

How to create WebService For Android that give Response in Json.
Example Response like That:

{"StatusInfo":{"Status":"FAILED","StatusDescription":"Error Occurred","ErrorCode":"","ErrorMessage":"","Validation":null},"DataSet":["Name":"Will","SanName":"Simth"],["Name":"Jony","SanName":"Dep"]}


give me Example code for that , because i am new in asp.net.

推荐答案

如前所述,我会再说一遍.我们不是在这里为您提供代码,因为我们不是在为您做您的工作.首先请先问问两个常见问题解答人员,然后再发布问题: CP Q&常见问题解答 [ ^ ]和 Pete O''Hanlon's [ ^ ]常见问题解答.我们想提供帮助,但首先希望您能付出至少一点努力.

对于您的问题,您可以像通常创建一个WebService一样创建一个WebService,然后像通常调用URL一样从Android调用它,并使用响应.一旦您投入使用,这并不难.
As said before, I''ll say again. We are not here to provide you with code, as we are not here to do your work for you. Refer first to the two FAQ''s people should read first before posting questions: CP Q&A FAQ[^] and Pete O''Hanlon''s[^] FAQ. We like to help, but we want to see at least a bit of effort on your part first.

As for your question, you create a WebService as you would normally create one, then you call it from Android as you normally call an URL, and consume the response. It''s not that hard, once you put yourself to it.


您可以在Google上找到几篇有关如何创建Web服务的文章.
现在针对您的问题,您的输出应返回JSON

要返回JSON字符串,您需要在网络方法中使用属性
ResponseFormat = System.Web.Script.Services.ResponseFormat.Json

这将返回JSON字符串.

希望对您有所帮助.
You can google to find out several articles,on how to create web service.
Now specific to your question, your output should return JSON

To return a JSON string, you need to use in web method attribute
ResponseFormat = System.Web.Script.Services.ResponseFormat.Json

This will return JSON string.

Hope this helps.


^ ]
http://www.skill-guru.com/blog/2011 /01/26/using-json-in-android/ [在ASP中创建JSON WebService带有jQuery客户端的.NET 2.0 [
http://stackoverflow.com/questions/10433551/problems-sending-and-receiving-json-between-asp-net-web-service-and-asp-net-web[^]
http://www.skill-guru.com/blog/2011/01/26/using-json-in-android/[^]
Create a JSON WebService in ASP.NET 2.0 with a jQuery Client[^]


这篇关于适用于Android的Json WebService的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆