zoukankan      html  css  js  c++  java
  • soap request by afnetworking2.X/3.X

    for 2.X 参考 http://jiapumin.iteye.com/blog/2109378

     1 AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
     2 manager.responseSerializer = [[AFHTTPResponseSerializer alloc] init];
     3 [manager.requestSerializer setValue:@"application/soap+xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
     4 [manager.requestSerializer setValue:soapLength forHTTPHeaderField:@"Content-Length"];
     5 NSMutableURLRequest *request = [manager.requestSerializer requestWithMethod:@"POST" URLString:@"http://www.webxml.com.cn/WebServices/WeatherWebService.asmx" parameters:nil];
     6 [request setHTTPBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
     7 AFHTTPRequestOperation *operation = [manager HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) {
     8     NSString *response = [[NSString alloc] initWithData:(NSData *)responseObject encoding:NSUTF8StringEncoding];
     9     NSLog(@"%@, %@", operation, response);
    10 } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    11     NSString *response = [[NSString alloc] initWithData:(NSData *)[operation responseObject] encoding:NSUTF8StringEncoding];
    12     NSLog(@"%@, %@", operation, error);
    13 }];
    14 [manager.operationQueue addOperation:operation];
    15 }

    for 3.X (未验证)

    1     AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    2     NSMutableURLRequest *request = [manager.requestSerializer requestWithMethod:@"post" URLString:@"" parameters:nil error:nil];
    3     [request setHTTPBody:nil];
    4     NSURLSessionTask *task = [manager dataTaskWithRequest:request completionHandler:^(NSURLResponse * _Nonnull response, id  _Nullable responseObject, NSError * _Nullable error) {
    5         
    6     }];
    7     [task resume];
  • 相关阅读:
    Leetcode 16.25 LRU缓存 哈希表与双向链表的组合
    Leetcode437 路径总和 III 双递归与前缀和
    leetcode 0404 二叉树检查平衡性 DFS
    Leetcode 1219 黄金矿工 暴力回溯
    Leetcode1218 最长定差子序列 哈希表优化DP
    Leetcode 91 解码方法
    Leetcode 129 求根到叶子节点数字之和 DFS优化
    Leetcode 125 验证回文串 双指针
    Docker安装Mysql记录
    vmware虚拟机---Liunx配置静态IP
  • 原文地址:https://www.cnblogs.com/n1ckyxu/p/5095964.html
Copyright © 2011-2022 走看看