星空网 > 软件开发 > 操作系统

IOS访问webserver接口

   

接口调用参数只能是字符串格式,返回格式支持3种(字符串,数组,DataSet)

需要引用第三方库,包含(DataSet,PlatServinceDataParser,WebserviceCommon,WebServiceHelper,

程序中引用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"

    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"

    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"

   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"

    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接口

关键词:IOS

IOS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

香港注册离岸公司的步骤与注意事项 :https://www.xlkjsw.com/news/84113.html
如何查询香港离岸公司的税号 :https://www.kjdsnews.com/a/1838607.html
如何查询香港离岸公司的税号 :https://www.xlkjsw.com/news/84114.html
在北京开设离岸银行账户:全面解析步骤、优势与注意事项 :https://www.kjdsnews.com/a/1838608.html
在北京开设离岸银行账户:全面解析步骤、优势与注意事项 :https://www.xlkjsw.com/news/84115.html
开设越南银行账户指南:海外投资者的完整指南 :https://www.kjdsnews.com/a/1838609.html
澳洲的物价什么样?跟团去澳大利亚旅游,如果:https://www.vstour.cn/a/403242.html
北京市公园年票包括哪些景点:https://www.vstour.cn/a/403243.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流