我正在尝试使用子类AFHTTPRequestOperationManager将我的代码转换为AFNetworking 2.0.这是我的代码
+ (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 *soapRequest=@"<?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]]; …Run Code Online (Sandbox Code Playgroud)