Interface call parameters can only be string format, return format support 3 kinds (string, array, DataSet)
You need to refer to a third-party library that contains (Dataset,platservincedataparser,webservicecommon,webservicehelper,xmlarrayparser,xmldatasetparser, Xmlresultparser)
2 References in the program
#import "WebServiceCommon.h"
#import "DataSet.h"
-(void) getwebserver
{
Webservicecommon *webservice=[[webservicecommonalloc] init];
Method One, take the return string
NSString *result= [webservicegetresultwithurl:@ "Http://116.6.52.27:91/webservice/caskaforescService.asmx" XmlNS: nilmethod:@ "Getcartypetree" pars:nil];
NSLog (@ "%@", result);
[Result release];
Call method with parameter transfer value
Nsmutabledictionary *dic=[[nsmutabledictionaryalloc]initwithobjectsandkeys:@ "Test2", @ "username", @ "820826", @ " PassWord ", @" 1eb2d9848c5545e6baeaa10b01222800 ", @" Clubuserid ", @" Southwest Region ", @" 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];
Method Two, take the returned data group
Nsarray *array=nil;
Nsmutabledictionary *dic2=[[nsmutabledictionaryalloc]initwithobjectsandkeys:@ "...", @ "VerifyCode", @ "", @ " Objparams ", @" 20120615170225282486 ", @" Saccountbookid ", @" XYTY124 ", @" ProductModel ", @" xin Yuan Yi Velvet ", @" 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]) ;
Determine null values in the data (nsarray,nsmutabledictionary, etc.)
if ([array objectatindex:10]==[nsnullnull]) {
NSLog (@ "null value!) ");
}
[Dic2 release];
Method Three, take the returned dataset
[webserviceinitdatasetwithurl:@ "Http://resourceservice.41go.cn/systemupdate.asmx" xmlns:nilmethod:@ "getyarnlist [Pars:nil];
Nsmutabledictionary *wb=[webservice.mydataset.tablesobjectforkey:@ "yarnlist"];//yarnlist table name, if not named 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 Access webserver interface