例子比较简单 记录下思路

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的更多相关文章

  1. iPhone中调用WCF服务

    本文介绍的是跨平台iPhone中调用WCF服务,WCF是由微软发展的一组数据通信的应用程序开发接口,它是.NET框架的一部分,由 .NET Framework 3.0+开始引入 iPhone中调用WC ...

  2. IOS中调用系统的电话、短信、邮件、浏览功能

    iOS开发系列--通讯录.蓝牙.内购.GameCenter.iCloud.Passbook系统服务开发汇总 2015-01-13 09:16 by KenshinCui, 26990 阅读, 35 评 ...

  3. 不要在using语句中调用WCF服务

    如果你调用WCF服务时,像下面的代码这样在using语句中进行调用,需要注意一个问题. using (CnblogsWcfClient client = new CnblogsWcfClient()) ...

  4. Silverlight应用程序中调用WCF Ria Services访问数据库图片

    WCF Ria Services(通常称为RIA服务),专门设计让Silverlight应用程序访问数据库,网上有关其示例应用都是基于简单的数据显示,其中MSDN网站上有详细的解决方案介绍,地址htt ...

  5. iOS中调用系统录音功能及其播放

    最近做的项目中,用到了录音的功能,简单记录一下. 我的想法是:通过重写button的点击事件,来达到录音的目的. /*----------------------------------[录音]--- ...

  6. IOS中调用系统拨打电话发送短信

    一.调用打电话界面 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat ...

  7. ios中调用友盟分享时qq可以分享但是微信失败,只显示文字,网页链接没有出现

    问题如下,最后在老大各种替换的情况下,找到了原因,是因为图片失效了,友盟分享微信时必须需要图片才可以,如果服务器图片失效,则会失败: 注意下面的图片是否能够获取???????????????????? ...

  8. 解决C#中调用WCF方法报错:远程服务器返回错误 (404) 未找到

    IIS配置问题,解决方法: 1. 首先添加MIME类型 扩展名“.svc”,MIME类型 “application/octet-stream” 2.处理程序映射--添加托管处理程序 请求路径 “.sv ...

  9. ios中调用摄像头

    @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDi ...

随机推荐

  1. UVa 1326 - Jurassic Remains(枚举子集+中途相遇法)

    训练指南p.59 #include <cstdio> #include <cstring> #include <cstdlib> #include <map& ...

  2. 根文件系统制作、NFS配置与安装及利用NFS挂载根文件系统

    最近打算从头开始制作根文件系统,下面是开发过程. 一.根文件系统的制作 0.FHS(Filesystem Hierarchy Standard)标准介绍 该标准规定了根目录下各个子目录的名称及其存放的 ...

  3. ACM-The Coco-Cola Store

    题目: Once upon a time, there is a special coco-cola store. If you return three empty bottles to the s ...

  4. Windows Server 创建环回网卡

    1.以管理员身份运行cmd后,在cmd命令窗口中执行:hdwwiz 启动硬件添加向导. 2.在添加硬件向导中选择手动安装或自动搜索都可以.然后选择网络适配器. 3.选择网络适配器:厂商选择Micros ...

  5. display 垂直居中

    /* Center slide text vertically */ display: -webkit-box; display: -ms-flexbox; display: -webkit-flex ...

  6. ajax知识点补充

    读取服务器上的数据: HTML: <!DOCTYPE HTML><html><head><meta charset="utf-8"> ...

  7. uoj Goodbye Dingyou Round 题解

    2.14 晚上的比赛, 现在改好了四题, 还差提答. 在这补个题解 新年的xor Description 给你 \(n\) , 然后要你构造 \([L, R], L<R\) 使得区间异或和为 \ ...

  8. HDU5974 A Simple Math Problem---数论--转化解方程

    感谢:http://blog.csdn.net/mirror58229/article/details/63685884 题意:x+y=a lcm(x,y)=b  求x,y 12WCases +  b ...

  9. POJ3207 Ikki's Story IV – Panda's Trick

    Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 9426   Accepted: 3465 Description liym ...

  10. wxpython demo

    #!/usr/bin/python # encoding: utf-8 '''Spare.py is a starting point for a wxPython program.''' impor ...