首页 > Web开发 > 详细

Web service交互

时间:2015-11-10 20:46:05      阅读:137      评论:0      收藏: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];

 

Web service交互

原文:http://www.cnblogs.com/NFli/p/4953988.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!