send POST request with xml body and recieve xml response with AFNetworking 3.x

我是研究僧i 提交于 2019-12-12 03:35:00

问题


Hi I'm trying to write AFNetworking 3.x post request with xml body and receive xml from server (because server accept xml input and out put xml). I've done successful with JSON but have problem with xml.

How to modify these template to send xml body and receive xml response. and what library should we use to parse the xml response? Any help is much appreciate. Thanks

NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];

NSURL *URL = [NSURL URLWithString:@"http://httpbin.org/get"];
NSURLRequest *request = [NSURLRequest requestWithURL:URL];

NSURLSessionDataTask *dataTask = [manager dataTaskWithRequest:request completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {     
    if (error) {  
        NSLog(@"Error: %@", error);
    } else {     
        NSLog(@"%@ %@", response, responseObject);  
    }   
}];
[dataTask resume];

回答1:


this is a link with the answer that you are looking for .

Try this

H@ppy c0de !!



来源:https://stackoverflow.com/questions/38596162/send-post-request-with-xml-body-and-recieve-xml-response-with-afnetworking-3-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!