接口调用参数只能是字符串格式,返回格式支持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接口的更多相关文章

  1. WebService---Android中访问WebService接口的方法

     最近公司有个项目需要从Android平台访问WebService接口,实现向发布的函数传递对象.在网上找了一些资料,发现使用ksoap2可以调用WebService传递对象.   需要引入ksoap ...

  2. jquery ajax 访问webServer的xml文件

    最近项目中要使用到通过ajax访问webServer的xml文件,通过下面的方式可以直接访问webServer的xml文件,不需要在web.xml中进行任何配置.它的返回参数就是服务器上的xml文件. ...

  3. ue4访问php接口

    继上一篇介绍ue4打开web url窗口,这篇就来介绍下怎么访问php接口. 要做的两步: 1.c++自己写个接受请求的方法 f Post lhc-URL Request就是自定义的c++方法, /* ...

  4. ios访问web页面<div>点击事件不起效果,以及alert()显示url的解决办法

    ios访问web页面<div>点击不起效果,在其div上添加style=”cursor:pointer:“ jquery web页面动态append()事件调用方法:$(document) ...

  5. LR访问Https接口

    实操篇 第一步:需要跟开发或者运维要到要访问的https接口的证书(有关证书的问题我们在原理中有解释). 第二步:确定要来的证书的格式是否为pem格式的.首先,LR只能够识别pem格式的证书而且是DE ...

  6. 记一次sql server 2005访问http接口,并解析json的过程

    记一次sql server 2005访问http接口,并解析json的过程  JSON解析官方网站:https://www.red-gate.com/simple-talk/sql/t-sql-pro ...

  7. Spring Boot的数据访问:CrudRepository接口的使用

    示例 使用CrudRepository接口访问数据 创建一个新的Maven项目,命名为crudrepositorytest.按照Maven项目的规范,在src/main/下新建一个名为resource ...

  8. ios 开源免费接口

    ios 开源免费接口 国家气象局提供的天气预报接口 接口地址: http://www.weather.com.cn/data/sk/101010100.html http://www.weather. ...

  9. “全栈2019”Java第八十一章:外部类能否访问嵌套接口里的成员?

    难度 初级 学习时间 10分钟 适合人群 零基础 开发语言 Java 开发环境 JDK v11 IntelliJ IDEA v2018.3 文章原文链接 "全栈2019"Java第 ...

随机推荐

  1. futimens函数的使用【学习笔记】

    #include "apue.h" #include <fcntl.h> int main(int argc,char *argv[]) { int i,fd; str ...

  2. 类、对象(java基础知识六)

    1.Java约定俗成 java约定俗成 1,类名接口名 一个单词首字母大写,多个单词每个单词首字母都大写 2,方法名和变量名 一个单词全部小写,多个单词从第二个单词首字母大写 建议:如果能用英语尽量用 ...

  3. 安全性测试--CSRF攻击

    一.CSRF是什么? CSRF(Cross-site request forgery),中文名称:跨站请求伪造,也被称为:one click attack/session riding,缩写为:CSR ...

  4. hdu 1963 Investment 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1963 题目意思:有 本金 money,还有一些股票的种类,第 i 种股票买入需要 value[i] 这 ...

  5. 一个点亮屏幕的service

    这个版本是只能点亮不能解锁的版本(注意很多句子都被注释掉了,那部分是用来实现解锁屏幕的),达到了预期的效果,特此纪念. 把代码贴出来: package com.larry.msglighter; im ...

  6. BZOJ_2186_[Sdoi2008]沙拉公主的困惑_欧拉函数

    BZOJ_2186_[Sdoi2008]沙拉公主的困惑_欧拉函数 Description 大富翁国因为通货膨胀,以及假钞泛滥,政府决定推出一项新的政策:现有钞票编号范围为1到N的阶乘,但是,政府只发行 ...

  7. AndroidStudio修改主题外观和字体大小

    修改主题外观 File --> Settings --> Appearance & Behavior --> Appearance 右边 Theme 修改编辑器的字体大小 F ...

  8. 初学者遇到的PostgreSQL字符集问题的解决

    当初学者在使用PostgreSQL数据库,输入中文时,会遇到“ERROR:  invalid byte sequence for encoding "UTF8": 0xd6d0”的 ...

  9. 【转】Intellij idea 的maven项目如何通过maven自动下载jar包

    原文地址: https://blog.csdn.net/machao0903/article/details/73368909 maven项目自动加载jar包 所需工具如下: Intellij IDE ...

  10. Cmake生成Makefile

    cmake 相比automake 最大的区别是: 步骤没有automake那么多 main.cpp #include<iostream> #include"student.h&q ...