我想我的代碼轉換爲AFNetworking 2.0分分級AFHTTPRequestOperationManager這裏是我的代碼AFNetworking 2.0域名= AFNetworkingErrorDomain代碼= -1011「請求失敗:內部服務器錯誤(500)
+ (NSAFNetwokingRequestManager *)sharedClient {
static NSAFNetwokingRequestManager *_sharedClient = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedClient = [[self alloc] initWithBaseURL:[NSURL URLWithString:GET_CAR_BRAND]];
});
return _sharedClient;
}
- (instancetype)initWithBaseURL:(NSURL *)url
{
self = [super initWithBaseURL:url];
if (self) {
self.responseSerializer = [AFXMLParserResponseSerializer serializer];
self.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"application/soap+xml"];
self.requestSerializer = [AFHTTPRequestSerializer serializer];
[self.requestSerializer setValue:@"application/soap+xml" forHTTPHeaderField:@"Content-type"];
}
return self;
}
- (void)requestBrandcompletion:(NSAFNetwokingRequestManagerCompletionBlock)completion {
NSString *[email protected]"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<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/\">\n"
"<soap:Body>\n"
" <CarBrandExt xmlns=\"http://www.nohausystems.nl/\" />\n"
"</soap:Body>\n"
"</soap:Envelope>\n";
NSString *msgLength = [NSString stringWithFormat:@"%i",[soapRequest length]];
[self POST:GET_CAR_BRAND parameters:Nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithHeaders:[NSDictionary dictionaryWithObjectsAndKeys:@"text/xml; charset=utf-8", @"Content-Type", msgLength, @"Content-Length", nil] body:[soapRequest dataUsingEncoding:NSUTF8StringEncoding]];
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
if (completion) {
completion(YES, responseObject);
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
if (completion) {
completion(NO, nil);
NSLog(@"Unable to fetch record error %@ with user info %@.", error, error.userInfo);
}
}];
}
我獲取此錯誤域= AFNetworkingErrorDomain代碼= -1011「請求失敗:內部服務器錯誤(500)。任何人都可以告訴我我在這裏做錯了什麼? 聞聽此事的迴應:
{ status code: 500, headers {
"Cache-Control" = private;
"Content-Length" = 509;
"Content-Type" = "application/soap+xml; charset=utf-8";
Date = "Thu, 13 Mar 2014 12:59:45 GMT";
Server = "Microsoft-IIS/7.5";
"X-AspNet-Version" = "2.0.50727";
"X-Powered-By" = "ASP.NET";
} }
不看你的代碼,錯誤500服務器錯誤,你看看你的服務器的日誌? –
相同的Web服務工作正常與舊版AFNetworking –
所以我想我的實現有一些問題。 –