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];
  • 相关阅读:
    C#反射的使用
    Swagger实例分享(VS+WebApi+Swashbuckle)
    WCF全双工通信实例分享(wsDualHttpBinding、netTcpBinding两种实现方式)
    WCF通信简单学习实例
    netcore 实现跨应用的分布式session
    netcore mvc 的简单实现
    netcore 基于 DispatchProxy 实现一个简单Rpc远程调用
    一步步到IOC
    《JavaScript设计模式与开发实践》读书笔记-基础知识
    windows下docker与.net core 的简单示例
  • 原文地址:https://www.cnblogs.com/n1ckyxu/p/5095964.html
Copyright © 2011-2022 走看看