Reputation: 2375
I have implemented following code and got the following error. I am unable to solve my problem :
[manager.requestSerializer setValue:@"application/soap+xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
error:
{ status code: 500, headers {
"Cache-Control" = private;
"Content-Length" = 1666;
"Content-Type" = "application/soap+xml; charset=utf-8";
Date = "Fri, 12 Jun 2015 04:33:18 GMT";
Server = "Microsoft-IIS/8.0";
"X-AspNet-Version" = "4.0.30319";
"X-Powered-By" = "ASP.NET";
} }, NSUnderlyingError=0x7fa4404463e0 "Request failed: unacceptable content-type: application/soap+xml"}
Upvotes: 1
Views: 181
Reputation: 1262
You can find a more detailed answer here.
I extracted this interesting part :
The "Request failed: unacceptable content-type: application/soap+xml" error is generated by
- (BOOL)validateResponse:(NSHTTPURLResponse *)response
data:(NSData *)data
error:(NSError * __autoreleasing *)error
method of AFHTTPResponseSerializer in case of unexpectable MIME type of response.
You can fix it with following code
self.responseSerializer = [AFXMLParserResponseSerializer serializer];
NSSet *set = self.responseSerializer.acceptableContentTypes;
self.responseSerializer.acceptableContentTypes = [set setByAddingObject:@"application/soap+xml"];
or modifying AFXMLDocumentResponseSerializer - add "application/soap+xml" to acceptable content types:
- (instancetype)init {
self = [super init];
if (!self) {
return nil;
}
self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", @"application/soap+xml", nil];
return self;
Upvotes: 0
Reputation: 104
You have to add application/soap+xml as an acceptable content type in your responseSerializer.
@property (nonatomic, strong) NSSet *acceptableContentTypes
e.g.
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/soap+xml", @"application/json", nil];
Upvotes: 1