Quote:
Originally Posted by pritamsaha
How do we make synchronous connection?
|
NSMutableString *sRequest = [[NSMutableString string] retain];
NSMutableString *stringPost=[[NSMutableString string] retain];
[stringPost appendString:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<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/\">"
"<soap:Body>"
"<Signin xmlns=\"http://tempuri.org/\">"
"<card_number>"];
[stringPost appendString:txtfCardNo.text];
[stringPost appendString:@"</card_number>"
"<dob>"];
[stringPost appendString:txtfPrepaidCardId.text];
[stringPost appendString:@"</dob>"
"</Signin>"
"</soap:Body>"
"</soap:Envelope>"];
//NSLog(@"stringPost=%@",stringPost);
[sRequest appendString:stringPost];
//NSLog(@"sRequest=%@",sRequest);
NSURL *myWebserverURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@",@"http://174.136.1.645/dev/testatmsearch/login.php"]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:myWebserverURL];
// Add the Required values in the header.
[request addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[request addValue:@"http://tempuri.org/UploadPhoto" forHTTPHeaderField:@"SOAPAction"];
[request addValue:[NSString stringWithFormat:@"%d", [sRequest length]] forHTTPHeaderField:@"Content-Length"];
// Set the action to Post
[request setHTTPMethod:@"POST"];
// Set the body
[request setHTTPBody:[sRequest dataUsingEncoding:NSUTF8StringEncoding]];
// Create the connection
[self performSelector:@selector(showMessage) withObject:nil afterDelay:30.0];
conn=[[[NSURLConnection alloc] initWithRequest:request delegate:self] autorelease];
if(conn)
NSLog(@"Connected");
else
NSLog(@"Not Connected");