android--asp.net webservice 返回json
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
using System.Web.Script.Serialization; [WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService] public class Service : System.Web.Services.WebService
{
public Service () {} [WebMethod]
[ScriptMethod(ResponseFormat=ResponseFormat.Json)]
public string Authenticate(string UserId, string UserPwd)
{
bool result = true;
return new JavaScriptSerializer().Serialize(result);
} [WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string GetUser()
{
User user = new User();
user.UserId = "jake";
user.UserPwd = "";
return new JavaScriptSerializer().Serialize(user);
} [WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string GetUsers()
{
List<User> list = new List<User>();
User user = new User();
user.UserId = "jake";
user.UserPwd = "";
list.Add(user);
user.UserId = "nola";
user.UserPwd = "";
list.Add(user);
return new JavaScriptSerializer().Serialize(list);
}
} public class User
{
public string UserId { get; set; }
public string UserPwd { get; set; }
}
android--asp.net webservice 返回json的更多相关文章
- asp.net webservice返回json问题
使用jQuery $.ajax方法请求webservice 一.方法返回值为string,将json格式的字符串返回 设置contentType为"application/json;char ...
- asp.net webservice 返回json数据乱码解决方法
[WebMethod] public void QueryRiskNotice(string phone) { try { var data = _riskNoticeDal.QueryRiskNot ...
- WebService返回json格式数据供苹果或者安卓程序调用
1.新建一个WebService. 2. /// <summary> /// DemoToJson 的摘要说明 /// </summary> [WebService(Names ...
- ASP.NET Core 返回 Json DateTime 格式
ASP.NET Core 返回 Json 格式的时候,如果返回数据中有DateTime类型,如何自定义其格式呢?配置如下: services.AddMvc().AddJsonOptions(opt = ...
- ASP.net jQuery调用webservice返回json数据的一些问题
之前寒假时,试着使用jQuery写了几个异步请求demo, 但是那样是使用的webform普通页面,一般应该是用 webservice 居多. 最近写后台管理时,想用异步来实现一些信息的展示和修改, ...
- jQuery调用WebService返回JSON数据
相信大家都比较了解JSON格式的数据对于ajax的方便,不了解的可以从网上找一下这方面的资料来看一下,这里就不多说了,不清楚的可以在网上查一下,这里只说一下因为参数设置不当引起的取不到返回值的问题. ...
- javaweb Servlet接收Android请求,并返回json数据
1.实现功能 (1)接收http请求 (2)获取Android客户端发送的参数对应的内容 (3)hibernate查询数据库 (4)返回json数据 2.java代码 import EntityCla ...
- asp.net webapi 返回json结果的方法
第一种: public static void Register(HttpConfiguration config) { //1.将默认的xml格式化程序清除 GlobalConfiguration. ...
- 亲测 asp.net 调用 webservice返回json
前端脚本 $("#sure").click(function () { var tbody = $("#putsigal tbody"); var trs = ...
- Asp.Net_Ajax调用WebService返回Json前台获取循环解析
利用JQuery的$.ajax()可以很方便的调用 asp.net的后台方法.但往往从后台返回的json字符串不能够正确解析,究其原因,是因为没有对返回的json数据做进一步的加工.其实,这里只需 要 ...
随机推荐
- centos6.7设置非root帐户自动登录
1.在/etc/gdm/custom.conf文件中修改并加入以下这段 [daemon]AutomaticLogin=你的用户名AutomaticLoginEnable=True 2.重启 reboo ...
- 【转】段错误调试神器 - Core Dump详解
from:http://www.embeddedlinux.org.cn/html/jishuzixun/201307/08-2594.html 段错误调试神器 - Core Dump详解 来源:互联 ...
- css动画 animation
今天用css做了一个简单的三角上下移动的一个小动画,说白了就是在改变该物体的height值.除了这个方法,还可以用js. 一.在用css写动画时,一定要记住兼容性问题.如何解决该兼容性?在前面加内核前 ...
- Servlet 之 ServletContext
package cn.jiemoxiaodi.servlet_servletcontext; import java.io.IOException; import java.io.PrintWrite ...
- Spring的jdbcTemplate查询执行原生sql
在spring与hibernate整合时进行数据库检索,执行原生sql: public AppointmentEvaluateVo searchMyfeedbackDetail(String acco ...
- iOS 归档archive使用方法
归档是一种很常用的文件储存方法,几乎任何类型的对象都能够被归档储存,文件将被保存成自定 义类型的文件,相对于NSUserDefault具有更好的保密性. 1.使用archiveRootObject ...
- c#中取整,向上取,向下取
Math.Ceiling()向上取整, Math.Floor()向下取整 示例: d = 4.56789 Math.Ceiling(Convert.ToDecimal(d)).ToString();M ...
- 【转】如何使用VS 2013发布一个可以在Windows XP中独立运行的可执行文件
问题描述: 用VS2013写好一个程序,在本机上运行一切正常.但是如果直接把exe文件放到另一台机器上用,则会出现: Windows XP:不是一个正常的win32程序 Window 7:缺少msvc ...
- (转)Java中使用Jedis操作Redis
转自http://www.cnblogs.com/liuling/p/2014-4-19-04.html 使用Java操作Redis需要jedis-2.1.0.jar,下载地址:http://file ...
- 【控制iOS7兼容iOS6 状态栏的显示不完全 简单缩写】
#if ios7 self.automaticallyAdjustsScrollViewInsets = YES; self.edgesForExtendedLayout = UIRectEdgeNo ...