在向POST请求添加xml正文时,我收到以下异常.在使用GET执行相同操作时,我得到了相同的异常.任何帮助,将不胜感激.
- (IBAction)buttonTapped:(id)sender {
NSLog(@"buttonTapped");
//Creating the request
NSMutableURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://192.168.0.1:9081/Transport/services/DriverService"] cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval: 30.0];
[ request setHTTPMethod: @"POST"];
//creating connection and sending it
NSURLConnection *connection = [ [NSURLConnection alloc] initWithRequest:request delegate:self];
NSString *xmlString = @"<Driver type=\"GetName\"><DriverID>1</DriverID></Driver>";
[request setHTTPBody:[xmlString
dataUsingEncoding:NSUTF8StringEncoding]];
//checking if connection is good
if (connection){
NSLog (@"Connection successfull!");
self.responseData = [NSMutableData data];
}
else
{
NSLog (@"Connection failed");
}
}
Run Code Online (Sandbox Code Playgroud)
Exception:
2011-03-02 09:22:12.055 XML[1125:207] buttonTapped
2011-03-02 09:22:12.056 XML[1125:207] -[NSURLRequest setHTTPMethod:]: unrecognized selector sent to …Run Code Online (Sandbox Code Playgroud)