-(void)ClientDashboard
{
//first create the soap envelope
soapMessage = [NSString stringWithFormat:@"",companyName,userName,password];
//Now create a request to the URL
NSURL *url = [NSURL URLWithString:@"http://example.com/MOBILEAPPAPI.ASMX"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%lu", (unsigned long)[soapMessage length]];
//ad required headers to the request
[theRequest addValue:@"example.com" forHTTPHeaderField:@"Host"];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"http://tempuri.org/example" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSURLSession *session = [NSURLSession sessionWithConfiguration: [NSURLSessionConfiguration defaultSessionConfiguration] delegate:self delegateQueue:[NSOperationQueue mainQueue]];
NSURLSessionDataTask *task = [session dataTaskWithRequest:theRequest completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
if (error == nil)
{
NSXMLParser *xmlparser = [[NSXMLParser alloc]initWithData:data];
xmlparser.delegate = self;
[xmlparser parse];
[webResponseData appendData:data];
}
}];
[task resume];
}
//Implement the NSXmlParserDelegate methods
-(void) parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:
(NSString *)qName attributes:(NSDictionary *)attributeDict
{
if([elementName isEqualToString:@"exampleResult"])
{
storeValue=elementName;
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
if ([storeValue isEqualToString:@"exampleResult"]) {
[userArray addObject:string];
otpResult=[NSMutableString stringWithString:string];
id data = [NSJSONSerialization JSONObjectWithData:[string dataUsingEncoding:NSASCIIStringEncoding] options:0 error:nil];
NSArray *ary=[data valueForKey:@"Example NUMBER"];
[Array removeAllObjects];
[Array addObjectsFromArray:ary];
}
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
}
Sign up here with your email
ConversionConversion EmoticonEmoticon