Please see Validation before implement this code
if (_txt_id
.text && _txt_pass
.text.length > 0)
{
//Check Email
if (regExMatches == 1)
{
NSLog(@"%@",_txt_id.text);
str1=@"";
str2=_txt_id.text;
str3=_txt_pass.text;
NSLog(@"%@",_txt_id.text);
}
//Check if number
else if(range_number.location != NSNotFound)
{
str1=_txt_id.text;
str2=@"";
str3=_txt_pass.text;
}
else
{
NSLog(@"Enter Number or Email");
}
}
else
{
NSLog(@"Write Something");
}
soapMessage = [NSString stringWithFormat:
@"<?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"
"<CheckLogin xmlns=\"http://tempuri.org/\">\n"
"<name1>%@</name1>\n"
"<name2>%@</name2>\n"
"<name3>%@</name3>\n"
"</CheckLogin>\n"
"</soap:Body>\n"
"</soap:Envelope>\n",str1,str2,str3
];
NSLog(soapMessage);
NSURL *url = [NSURL URLWithString:@"http://192.168.1.17/abc/service.asmx"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"http://tempuri.org/CheckLogin" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if( theConnection )
{
webData = [NSMutableData data];
}
else
{
NSLog(@"theConnection is NULL");
}
}
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
[webData setLength: 0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[webData appendData:data];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
xmlParser = [[NSXMLParser alloc] initWithData: webData];
[xmlParser setDelegate:self];
[xmlParser setShouldResolveExternalEntities: YES];
[xmlParser parse];
[self someMethod];
}
#pragma mark NSXMLParserDelegate methods
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
NSLog(@"%@",string);
string = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
count1++;
}
- (void)someMethod
{
//This method use for navigation if login sucessfull
if (count1>0)
{
Admin_Home *fac1=[self.storyboard instantiateViewControllerWithIdentifier:@"admin_home"];
[self.navigationController pushViewController:fac1 animated:YES];
}
}