IOS访问webserver接口
接口调用参数只能是字符串格式,返回格式支持3种(字符串,数组,DataSet)
需要引用第三方库,包含(DataSet,PlatServinceDataParser,WebserviceCommon,WebServiceHelper,XMLArrayParser,XMLDataSetParser,XMLResultParser)
程序中引用2个即可
#import "WebServiceCommon.h"
#import"DataSet.h"
- (void)getwebserver
{
WebServiceCommon *webService=[[WebServiceCommonalloc] init];
//方法一,取返回字符串
NSString *result= [webServicegetResultWithURL:@"http://116.6.52.27:91/webservice/caskaforescService.asmx"xmlNS:nilmethod:@"GetCarTypeTree"pars:nil];
NSLog(@"%@",result);
[result release];
//带参数传值调用方法
NSMutableDictionary *dic=[[NSMutableDictionaryalloc]initWithObjectsAndKeys:@"test2",@"username",@"820826",@"passWord",@"1EB2D9848C5545E6BAEAA10B01222800",@"clubUserid",@"西南大区",@"BigArea",@"",@"province",@"",@"city",nil];
NSString *result2= [webServicegetResultWithURL:@"http://116.6.52.27:91/webservice/caskaforescService.asmx"xmlNS:nilmethod:@"GetClub"pars:dic];
NSLog(@"%@",result2);
[dic release];
[result2 release];
//方法二,取返回数据组
NSArray *array=nil;
NSMutableDictionary *dic2=[[NSMutableDictionaryalloc]initWithObjectsAndKeys:@"...",@"VerifyCode", @"",@"objParams",@"20120615170225282486",@"sAccountBookID", @"XYTY124",@"productModel", @"馨原奕绒",@"brandName", nil];
array=[webServicegetArrayWithURL:@"http://resourceservice.41go.cn/systemupdate.asmx"xmlNS:nilmethod:@"GetProductPriceInfoExt"pars:dic2];
NSLog(@"productmodel=%@;name=%@,key=%@",[arrayobjectAtIndex:2],[arrayobjectAtIndex:3],[arrayobjectAtIndex:10]);
//判断数据中的空值(NSArray,NSMutableDictionary等)
if ([array objectAtIndex:10]==[NSNullnull]) {
NSLog(@"空值!");
}
[dic2 release];
//方法三,取返回DataSet
[webServiceinitDataSetWithURL:@"http://resourceservice.41go.cn/systemupdate.asmx"xmlNS:nilmethod:@"GetYarnList"pars:nil];
NSMutableDictionary *wb=[webService.myDataset.TablesobjectForKey:@"YarnList"];//YarnList表名,如果没有命名则为Table
NSInteger count=[[webService.myDataset.TablesobjectForKey:@"YarnList"]count];
for (int ii=0; ii<count; ii++) {
NSMutableDictionary *dictemp=[wb objectForKey:[NSStringstringWithFormat:@"%d",ii]];
NSLog(@"col1=%@;col2=%@;col3=%@",[dictempobjectForKey:@"C_AccountBookID"],[dictempobjectForKey:@"C_Name"],[dictempobjectForKey:@"C_YarnID"]);
}
[webService release];
}
IOS访问webserver接口的更多相关文章
- WebService---Android中访问WebService接口的方法
最近公司有个项目需要从Android平台访问WebService接口,实现向发布的函数传递对象.在网上找了一些资料,发现使用ksoap2可以调用WebService传递对象. 需要引入ksoap ...
- jquery ajax 访问webServer的xml文件
最近项目中要使用到通过ajax访问webServer的xml文件,通过下面的方式可以直接访问webServer的xml文件,不需要在web.xml中进行任何配置.它的返回参数就是服务器上的xml文件. ...
- ue4访问php接口
继上一篇介绍ue4打开web url窗口,这篇就来介绍下怎么访问php接口. 要做的两步: 1.c++自己写个接受请求的方法 f Post lhc-URL Request就是自定义的c++方法, /* ...
- ios访问web页面<div>点击事件不起效果,以及alert()显示url的解决办法
ios访问web页面<div>点击不起效果,在其div上添加style=”cursor:pointer:“ jquery web页面动态append()事件调用方法:$(document) ...
- LR访问Https接口
实操篇 第一步:需要跟开发或者运维要到要访问的https接口的证书(有关证书的问题我们在原理中有解释). 第二步:确定要来的证书的格式是否为pem格式的.首先,LR只能够识别pem格式的证书而且是DE ...
- 记一次sql server 2005访问http接口,并解析json的过程
记一次sql server 2005访问http接口,并解析json的过程 JSON解析官方网站:https://www.red-gate.com/simple-talk/sql/t-sql-pro ...
- Spring Boot的数据访问:CrudRepository接口的使用
示例 使用CrudRepository接口访问数据 创建一个新的Maven项目,命名为crudrepositorytest.按照Maven项目的规范,在src/main/下新建一个名为resource ...
- ios 开源免费接口
ios 开源免费接口 国家气象局提供的天气预报接口 接口地址: http://www.weather.com.cn/data/sk/101010100.html http://www.weather. ...
- “全栈2019”Java第八十一章:外部类能否访问嵌套接口里的成员?
难度 初级 学习时间 10分钟 适合人群 零基础 开发语言 Java 开发环境 JDK v11 IntelliJ IDEA v2018.3 文章原文链接 "全栈2019"Java第 ...
随机推荐
- express 中文文档
express() 创建一个express应用程序 var express = require('express'); var app = express(); app.get('/', functi ...
- String bulit-in function
tip: 和tuple一样,字符串也是不可变的类型,字符串的内建函数有非常多,我们一一举例来看看他们的作用 下面是用dir(str) 输出的内容: ['__add__', '__class__', ' ...
- ES6 解构赋值的常见用途,很强大
字符串 var [a,b,c,d,e] = "hello"; console.log(a); // h console.log(b); // e console.log(c); / ...
- poj 1469 COURSES 解题报告
题目链接:http://poj.org/problem?id=1469 题目意思:有 N 个人,P个课程,每一个课程有一些学生参加(0个.1个或多个参加).问 能否使得 P 个课程 恰好与 P 个学生 ...
- html5--6-13 CSS3中的颜色表示方式
html5--6-13 CSS3中的颜色表示方式 学习要点 掌握选择器的优先级问题 掌握CSS3中新增的颜色表示方式 选择器的优先级问题 原则上:元素选择器<类选择器< ID选择器< ...
- 一步一步学Silverlight 2系列(30):使用Transform实现更炫的效果(下)
概述 Silverlight 2 Beta 1版本发布了,无论从Runtime还是Tools都给我们带来了很多的惊喜,如支持框架语言Visual Basic, Visual C#, IronRuby, ...
- codevs矩阵乘法系列
T1:矩阵乘法板子题,练手. #include <map> #include <set> #include <cmath> #include <ctime&g ...
- 任务26:dotnet watch run 和attach到进程调试
任务26:dotnet watch run 和attach到进程调试 dotnet watch run 的一种调试方法 打开VSCode,先关闭当前的文件夹 Ctrl+~快捷键 打开窗体. ls应该是 ...
- E20170404-gg
margin 外边,外埔 padding 内铺 inherit v 继承
- HDOJ5020【几何】
题意: 给你n个点,问有几对三个点在一条直线上 思路: 目前为止很少写的几何题- 一开始两层for没有判断重复. 然后看了一些题解说排序一下,然后枚举每个点,求一个同一斜率的个数k,ans+=(k-1 ...