/////Web-Services......
-(void) fetchFeatured {
[appDelegate showLoadingView];
NSLog(@">>>>>>> Fetch Featured called");
NSString *webService = [NSString stringWithFormat:soapAction];
NSString *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"
"<GetTodaysDeal xmlns=\"%@\" >\n"
"<blank></blank>\n"
"</GetTodaysDeal>\n"
"</soap:Body>\n"
"</soap:Envelope>\n",xmlnsLogin
];
NSLog(@"soap msg : %@", soapMessage);
NSURL *url = [NSURL URLWithString:webService];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60.0];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: [webService stringByAppendingString:@"/GetTodaysDeal"] 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] retain];
}else {
NSLog(@"The Connection is NULL");
}
}
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
webData = [[NSMutableData data] retain];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[webData appendData:data];
//NSLog(@">>>>>>>>>>>>>>>>>>>>>>>>");
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
// [[ActivityIndicator sharedActivityIndicator]hide];
NSLog(@"ERROR with theConenction %@",error);
UIAlertView *connectionAlert = [[UIAlertView alloc] initWithTitle:@"Information !" message:@"Internet / Service Connection Error" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
lblname.text = @"Internet Not Available";
[connectionAlert show];
[connectionAlert release];
[appDelegate hideLoadingView];
[connection release];
[webData release];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *theXML = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding];
theXML = [theXML stringByReplacingOccurrencesOfString:@">" withString:@">"];
theXML = [theXML stringByReplacingOccurrencesOfString:@"<" withString:@"<"];
NSLog(@"Received data :%@",theXML);
NSData *data = [theXML dataUsingEncoding:NSUTF8StringEncoding];
CXMLDocument *doc = [[[CXMLDocument alloc] initWithData:data options:0 error:nil] autorelease];
NSArray *nodes1 = [doc nodesForXPath:@"//Details" error:nil];
if (!nodes1 || !nodes1.count) {
lblname.text = @"Not Any Deal Today.";
UIAlertView *alert= [[UIAlertView alloc]initWithTitle:@"Empty Today Deal" message:@"Not Any Deal Today ...." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
[alert release];
}
else{
NSLog(@"node counts feedbackofAttendee: %@", nodes1);
if (arrData == nil)
arrData = [[NSMutableArray alloc] init];
arrimgurl = [[NSMutableArray alloc]init];
if ([arrData count] > 0) {
[arrData removeAllObjects];
[arrimgurl removeAllObjects];
}
for (CXMLElement *node in nodes1) {
PastAuctionBean *objBean = [[PastAuctionBean alloc]init];
for(int counter = 0; counter < [node childCount]; counter++) {
//NSLog(@"child node :%@", [[node childAtIndex:counter] name]);
if ([[[node childAtIndex:counter] name] isEqualToString:@"id"]) {
NSString *str = [[node childAtIndex:counter] stringValue];
NSLog(@"=====================>>string for id : %@\n", str);
objBean.detailId = str;
}
if ([[[node childAtIndex:counter] name] isEqualToString:@"itemName"]) {
NSString *str = [[node childAtIndex:counter] stringValue];
objBean.itemName = str;
NSLog(@"=====================>>string for itemName : %@\n", str);
}
if ([[[node childAtIndex:counter] name] isEqualToString:@"description"]) {
NSString *str = [[node childAtIndex:counter] stringValue];
objBean.description = str;
NSLog(@"=====================>>string for Desc : %@\n", str);
}
if ([[[node childAtIndex:counter] name] isEqualToString:@"itemdate"]) {
NSString *str = [[node childAtIndex:counter] stringValue];
objBean.itemdate = str;
NSLog(@"=====================>>string for itemdate : %@\n", str);
}
if ([[[node childAtIndex:counter] name] isEqualToString:@"startprice"]) {
NSString *str = [[node childAtIndex:counter] stringValue];
objBean.startprice = str;
NSLog(@"=====================>>string for startprice : %@\n", str);
}
if ([[[node childAtIndex:counter] name] isEqualToString:@"timeinterval"]) {
NSString *str = [[node childAtIndex:counter] stringValue];
objBean.timeinterval = str;
NSLog(@"=====================>>string for timeinterval : %@\n", str);
}
if ([[[node childAtIndex:counter] name] isEqualToString:@"intervalprice"]) {
NSString *str = [[node childAtIndex:counter] stringValue];
objBean.intervalprice = str;
NSLog(@"=====================>>string for intervalprice : %@\n", str);
}
if ([[[node childAtIndex:counter] name] isEqualToString:@"lastprice"]) {
NSString *str = [[node childAtIndex:counter] stringValue];
objBean.lastprice = str;
NSLog(@"=====================>>string for lastprice : %@\n", str);
}
if ([[[node childAtIndex:counter] name] isEqualToString:@"images"]) {
NSArray *nodes2 = [node nodesForXPath:@"//images" error:nil];
for (CXMLElement *node3 in nodes2 ) {
for(int counter = 0; counter < [node3 childCount]; counter++) {
// NSLog(@"child node :%@", [[node3 childAtIndex:counter] name]);
if ([[[node3 childAtIndex:counter] name] isEqualToString:@"imageid"]) {
NSString *str = [[node3 childAtIndex:counter] stringValue];
NSLog(@"=====================>>string Image id : %@\n", str);
//[objBean.imageid addObject:str];
}
if ([[[node3 childAtIndex:counter] name] isEqualToString:@"imageurl"]) {
NSString *str = [[node3 childAtIndex:counter] stringValue];
NSLog(@"=====================>>string Image Url : %@\n", str);
[arrimgurl addObject:str];
}
}
}
}
}
[arrData addObject:objBean];
}
[arrData retain];
[arrimgurl retain];
[self Print];
}
// NSSortDescriptor *aSortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES];
// [arrData sortUsingDescriptors:[NSArray arrayWithObject:aSortDescriptor]];
// [aSortDescriptor release];
// [myTableView reloadData];
//[self loadContentForVisibleCells];
[appDelegate hideLoadingView];
[connection release];
[webData release];
}