使用Android中的JSON从Web服务访问值 [英] Access the value from Web services using JSON in android

查看:69
本文介绍了使用Android中的JSON从Web服务访问值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我使用返回Json值的方法创建了Web服务。

 [WebMethod] 
[ScriptMethod (ResponseFormat = ResponseFormat.Json)]
public string HelloWorld(){
员工[] e = 员工[ 2 ];
e [ 0 ] = new Employee(); $ b $是[ 0 ]。Name = Ajay辛格; $ b $是[ 0 ]。公司= Birlasoft有限公司。 $ b $是[ 0 ]。地址= LosAngeles加利福尼亚; $ b $是[ 0 ]。Phone = 1204675 ; $ b $是[ 0 ]。Country = US ;
e [ 1 ] = new Employee(); $ b $是[ 1 ]。Name = Ajay辛格; $ b $是[ 1 ]。公司= Birlasoft有限公司。 $ b $是[ 1 ]。地址= D -195 Noida; $ b $是[ 1 ]。Phone = 1204675 ; $ b $是[ 1 ]。Country = 印度;
return new JavaScriptSerializer()。Serialize(e);

}





现在我想在Android应用程序中使用HTTP和Json访问此方法。我尝试了很多不同的方法。我没弄错。请帮帮我。我需要一个代码来从这个方法中获取价值。

解决方案

查看此链接



consume-.net-webservice-in-android-using ksoap2 [ ^ ]

Hi,
I created the web services with method that return Json value.

[WebMethod]
   [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
   public string HelloWorld() {
       Employee[] e = new Employee[2];
       e[0] = new Employee();
       e[0].Name = "Ajay Singh";
       e[0].Company = "Birlasoft Ltd.";
       e[0].Address = "LosAngeles California";
       e[0].Phone = "1204675";
       e[0].Country = "US";
       e[1] = new Employee();
       e[1].Name = "Ajay Singh";
       e[1].Company = "Birlasoft Ltd.";
       e[1].Address = "D-195 Sector Noida";
       e[1].Phone = "1204675";
       e[1].Country = "India";
       return new JavaScriptSerializer().Serialize(e);

   }



Now i want to access this method in android apps using HTTP and Json. I tried many different ways. I am not getting it correctly. Please help me on this. I need a code that to get value from this method.

解决方案

check this link

consume-.net-webservice-in-android-using ksoap2[^]


这篇关于使用Android中的JSON从Web服务访问值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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