iOS Access webserver interface

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.