libz.dylib
MobileCoreServices.framework
libxml2.dylib
CFNetwork.framework
SystemConfiguration.framework
(1)Project->build Setting
(2)查找到Search paths中的Header Search Paths 点击它添加${SDKROOT}/usr/include/libxml2
如果添加了${SDKROOT}/usr/include/libxml2还是会报libxml/tree.h的错则把它修改成/usr/include/libxml2
在项目中找到ServiceArgs类,把defaultWebSerivceUrl与defaultWebServiceNameSpace的值修改成自已的内容
(1)defaultWebSerivceUrl为webservice url地址
(2)defaultWebServiceNameSpace为webservice命名空间地址
4.使用说明
a.无参数的同步请求
ServiceResult *result=[ServiceHelper syncMethodName:@"getForexRmbRate"];
NSLog(@"同步请求xml=%@\n",result.xmlString);
NSArray *arr=[result.xmlParse soapXmlSelectNodes:@"//ForexRmbRate"];
NSLog(@"解析xml结果=%@\n",arr);
b.有参数的同步请求
//参数
NSMutableArray *params=[NSMutableArray array];
[params addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"queryBFlist",@"tradeCode", nil]];
[params addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"123",@"account", nil]];
[params addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"123",@"password", nil]];
[params addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"01",@"accountType", nil]];
//设置传递对象
ServiceArgs *args=[[[ServiceArgs alloc] init] autorelease];
args.methodName=@"AddMethod";//webservice方法名
args.soapParams=params;//方法参数
//调用
ServiceResult *result=[ServiceHelper syncService:args];
NSLog(@"同步请求xml=%@\n",result.xmlString);
//查询节点
NSArray *arr=[result.xmlParse soapXmlSelectNodes:@"//ForexRmbRate"];
NSLog(@"解析xml结果=%@\n",arr);
a.无参数的异步请求
[ServiceHelper asynMethodName:@"getForexRmbRate" success:^(ServiceResult *result) {
//查询xml节点
NSArray *arr=[result.xmlParse soapXmlSelectNodes:@"//ForexRmbRate"];
NSLog(@"解析xml结果=%@\n",arr);
} failed:^(NSError *error, NSDictionary *userInfo) {
NSLog(@"error=%@\n",[error description]);
}];
b.有参数的异步请求
//参数
NSMutableArray *params=[NSMutableArray array];
[params addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"queryBFlist",@"tradeCode", nil]];
[params addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"123",@"account", nil]];
[params addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"123",@"password", nil]];
[params addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"01",@"accountType", nil]];
//设置传递对象
ServiceArgs *args=[[[ServiceArgs alloc] init] autorelease];
args.methodName=@"AddMethod";//webservice方法名
args.soapParams=params;//方法参数
//调用
[ServiceHelper asynService:args success:^(ServiceResult *result) {
NSArray *arr=[result.xmlParse soapXmlSelectNodes:@"//ForexRmbRate"];
NSLog(@"解析xml结果=%@\n",arr);
} failed:^(NSError *error, NSDictionary *userInfo) {
NSLog(@"error=%@\n",[error description]);
}];
ServiceHelper *helper=[ServiceHelper sharedInstance];
//添加队列1
ASIHTTPRequest *request1=[ServiceHelper commonSharedRequest:[ServiceArgs serviceMethodName:@"getForexRmbRate"]];
[request1 setUserInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"request1",@"name", nil]];
[helper addQueue:request1];
//添加队列2
ServiceArgs *args1=[[[ServiceArgs alloc] init] autorelease];
args1.serviceURL=@"http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx";
args1.serviceNameSpace=@"http://WebXml.com.cn/";
args1.methodName=@"getDatabaseInfo";
ASIHTTPRequest *request2=[ServiceHelper commonSharedRequest:args1];
[request1 setUserInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"request2",@"name", nil]];
[helper addQueue:request2];
//执行队列
[helper startQueue:^(ServiceResult *result) {
NSString *name=[result.userInfo objectForKey:@"name"];
NSLog(@"%@请求成功,xml=%@",name,result.xmlString);
} failed:^(NSError *error, NSDictionary *userInfo) {
NSString *name=[userInfo objectForKey:@"name"];
NSLog(@"%@请求失败,失败原因:%@",name,[error description]);
} complete:^{
NSLog(@"排队列请求完成!\n");
}];
ServiceArgs *args1=[[[ServiceArgs alloc] init] autorelease];
args1.serviceURL=@"http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx";//webservice地址
args1.serviceNameSpace=@"http://WebXml.com.cn/";//webservice命名空间
args1.methodName=@"getDatabaseInfo";
//调用
[ServiceHelper asynService:args1 success:^(ServiceResult *result) {
NSLog(@"xml结果=%@\n",result.XMLString);
}
failed:^(NSError *error, NSDictionary *userInfo) {
NSLog(@"error=%@\n",[error description]);
}];