Web service交互
2015-11-10 18:57 南峰_ldl 阅读(185) 评论(0) 编辑 收藏 举报一、iOS与Web service交互
NSString *soapMessage = [NSString stringWithFormat: @"<?xml version=\"1.0\" encoding=\"utf-8\"?>" "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://" "www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" "<soap:Body>" "<Login xmlns=\"http://IVU/\">" "<userid>%d</userid>" "<pwd>%@</pwd>" "</Login>" "</soap:Body>" "</soap:Envelope>",_passwordTextField.text.intValue,_passwordTextField.text]; NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]]; NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",wsURL]]; NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url]; [urlRequest setValue:@"text/xml" forHTTPHeaderField:@"Accept"]; [urlRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [urlRequest addValue: @"http://IVU/Login" forHTTPHeaderField:@"SOAPAction"]; [urlRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"]; [urlRequest setHTTPMethod:@"POST"]; [urlRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]]; [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES]; [NSURLConnection sendAsynchronousRequest:urlRequest queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) { if (error) { } else { [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO]; NSString * xmlString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; [self xmlParser:xmlString]; } }];
二、UIView的渐变效果
CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.frame = self.view.bounds; gradient.colors = [NSArray arrayWithObjects: (id)[UIColor colorWithRed:245/255.0 green:245/255.0 blue:245/255.0 alpha:1].CGColor, (id)[UIColor colorWithRed:230/255.0 green:230/255.0 blue:230/255.0 alpha:1].CGColor, nil]; [self.view.layer insertSublayer:gradient atIndex:0];
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
· 现代计算机视觉入门之:什么是图片特征编码
· .NET 9 new features-C#13新的锁类型和语义
· Linux系统下SQL Server数据库镜像配置全流程详解
· Sdcb Chats 技术博客:数据库 ID 选型的曲折之路 - 从 Guid 到自增 ID,再到
· 语音处理 开源项目 EchoSharp
· 《HelloGitHub》第 106 期
· Huawei LiteOS基于Cortex-M4 GD32F4平台移植
· mysql8.0无备份通过idb文件恢复数据过程、idb文件修复和tablespace id不一致处