zoukankan      html  css  js  c++  java
  • Web service交互

    一、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];
  • 相关阅读:
    计算机网络中的码元的理解
    屏幕扩展,屏幕相对位置的设置
    wireshark使用入门
    Http下载文件的登录验证
    正则-连续相同的单词
    文件系统和数据库索引用B树而不是红黑树的原因
    红黑树的突破点
    Win 10 Revit 2019 安装过程,亲自踩的一遍坑,有你想要的细节
    Java拦截器的实现原理
    根据进程数,资源数判断是否发生死锁
  • 原文地址:https://www.cnblogs.com/NFli/p/4953988.html
Copyright © 2011-2022 走看看