ios中调用WCF
例子比较简单 记录下思路
1、接口中定义 实体和方法声明
//登录信息
[OperationContract]
[WebInvoke(UriTemplate = "LogInf/{name}/{pwd}", Method = "POST", ResponseFormat = WebMessageFormat.Json)]
LogInf GetLogInf(string name, string pwd);
2 //数据交换实体类
[DataContract]
public class LogInf
{
[DataMember]
public string UserId { get; set; }
[DataMember]
public bool LogTag { get; set; }
[DataMember]
public string errMsg { get; set; }
}
3服务实现
//简单测试
public LogInf GetLogInf(string name, string pwd)
{
LogInf loginf = new LogInf();
if (name == "111" && pwd == "111")
{
loginf.UserId = "100";
loginf.LogTag = true;
loginf.errMsg = "成功";
}
else
{
loginf.UserId = "0";
loginf.LogTag = false;
loginf.errMsg = "验证失败";
}
return loginf;
}
4在web.config中将绑定方式改成webHttpBinding
binding="webHttpBinding"
5 调用
NSURL *url = [NSURL URLWithString:@http://192.268.0.11:9422/Service1.svc/LogInf/111/111];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setRequestMethod:@"POST"];
[request startSynchronous];
NSError *error = [request error];
if (!error) {
NSString *response = [request responseString];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"测试"
message:response
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
[alertView release];
}
6返回
{"LogTag":true,"UserId":"100","errMsg":"成功"}
ios中调用WCF的更多相关文章
- iPhone中调用WCF服务
本文介绍的是跨平台iPhone中调用WCF服务,WCF是由微软发展的一组数据通信的应用程序开发接口,它是.NET框架的一部分,由 .NET Framework 3.0+开始引入 iPhone中调用WC ...
- IOS中调用系统的电话、短信、邮件、浏览功能
iOS开发系列--通讯录.蓝牙.内购.GameCenter.iCloud.Passbook系统服务开发汇总 2015-01-13 09:16 by KenshinCui, 26990 阅读, 35 评 ...
- 不要在using语句中调用WCF服务
如果你调用WCF服务时,像下面的代码这样在using语句中进行调用,需要注意一个问题. using (CnblogsWcfClient client = new CnblogsWcfClient()) ...
- Silverlight应用程序中调用WCF Ria Services访问数据库图片
WCF Ria Services(通常称为RIA服务),专门设计让Silverlight应用程序访问数据库,网上有关其示例应用都是基于简单的数据显示,其中MSDN网站上有详细的解决方案介绍,地址htt ...
- iOS中调用系统录音功能及其播放
最近做的项目中,用到了录音的功能,简单记录一下. 我的想法是:通过重写button的点击事件,来达到录音的目的. /*----------------------------------[录音]--- ...
- IOS中调用系统拨打电话发送短信
一.调用打电话界面 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat ...
- ios中调用友盟分享时qq可以分享但是微信失败,只显示文字,网页链接没有出现
问题如下,最后在老大各种替换的情况下,找到了原因,是因为图片失效了,友盟分享微信时必须需要图片才可以,如果服务器图片失效,则会失败: 注意下面的图片是否能够获取???????????????????? ...
- 解决C#中调用WCF方法报错:远程服务器返回错误 (404) 未找到
IIS配置问题,解决方法: 1. 首先添加MIME类型 扩展名“.svc”,MIME类型 “application/octet-stream” 2.处理程序映射--添加托管处理程序 请求路径 “.sv ...
- ios中调用摄像头
@interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDi ...
随机推荐
- NVIDIA/DIGITS:Building DIGITS
在 Prerequisites中的 sudo apt-get update命令发生错误: W: GPG 错误:http://developer.download.nvidia.com/compute/ ...
- POJ 3180 The cow Prom Tarjan基础题
题目用google翻译实在看不懂 其实题目意思如下 给一个有向图,求点个数大于1的强联通分量个数 #include<cstdio> #include<algorithm> #i ...
- spring in action 学习笔记九:如何证明在scope为prototype时每次创建的对象不同。
spring 中scope的值有四个:分别是:singleton.prototype.session.request.其中session和request是在web应用中的. 下面证明当scope为pr ...
- java.security.InvalidKeyException: IOException : Short read of DER length
今天支付服务器测试退款的时候爆了异常:Caused by: java.security.InvalidKeyException: IOException : Short read of DER len ...
- 用MysQL语句怎么进行远程连接数据库
一.连接远程数据库: 1.显示密码如:MySQL 连接远程数据库(192.168.2.115),端口“3306”,用户名为“root”,密码“root” C: -u root -proot (注意第一 ...
- LINK : fatal error LNK1104: 无法打开文件“mfc71.lib”(转)
原文转自 http://blog.csdn.net/mxclxp/article/details/8196142 [环境] Windows XP OS: Visual Studio 2008: ...
- [MySQL] 锁/死锁问题一例
MySQL锁/死锁问题 在MySQL中, 不同事务隔离级别下, 锁的情况表现是不同的, 另外表的设计上有无索引也是一个因素. 做一个小的实验测试InnoDB锁表现 -:) 说明 事务隔离级别 READ ...
- TOTP:Time-based One-time Password Algorithm
转自: http://www.cnblogs.com/dyingbleed/archive/2012/12/05/2803782.html http://en.wikipedia.org/wiki/T ...
- Android屏幕元素层次结构
转自:http://blog.csdn.net/hpoi/article/details/4629717 Android屏幕元素层次结构 android.app.Activity 对于一个Andr ...
- linux硬盘分区表为gpt
由于mbr最大支持2T不够用,给5T的新硬盘弄成GPT的 yum install -y parted#指定硬盘parted /dev/#p 查看分区#rm 1p 删除指定分区#改成gptmklabel ...