Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning iPad Application Development
This is the forum to discuss the Wrox book Beginning iPad Application Development by Wei-Meng Lee; ISBN: 9780470641651
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning iPad Application Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old December 29th, 2010, 07:13 PM
Registered User
 
Join Date: Dec 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with web service example chapter 14

Hello

I'm having a problem with the web service example. The spinner just spins and doesn't receive the information. I don't think the connection is being called. Does any one have a sollution for this.

Thanks

John
  #2 (permalink)  
Old January 1st, 2011, 03:53 PM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

The site that is called is no longer active. (Enter the URL manually in your browser and also checkout the Console log)
There is an earlier posting regarding this that the author responded to.
CH.14 - Web Services Example Site Down

Unfortunately this response is no longer valid. The query page no longer exists. The example was recycled for a subsequent book published in October, and readers of that book are having the same problem, and no response has been made from the author.
Chapter 16 - Dead link

Obviously when something like this breaks it is beyond the author's control, but considering that the example was reused, and the problem known before the latter book was published, it would make sense to prepare an online alternative for users of both books.

I had not done this chapter previously since I had no immediate need for Web Services. Now that my interest has been piqued, if I find an alternative source for the service I will let you know. Hopefully, the author will also provide an alternative.
  #3 (permalink)  
Old January 9th, 2011, 03:04 PM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

For those interested an alternate site for the IPAddress is
http://www.webservicex.net/geoipservice.asmx
This page supports supports all 4 request formats, SOAP 1.1 and 1.2, HTTP GET and HTTP POST. The project can be built and run as intended after making the necessary changes.
Bob
  #4 (permalink)  
Old January 19th, 2011, 01:18 PM
Registered User
 
Join Date: Jan 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi... I've tried updating / making the changes using GeoIPService - but something is failing - it says bad request... My interest is also piqued because of a project I'm working on.

Are you still working on this project? I would love to talk about this off-line...
Let me know...
  #5 (permalink)  
Old January 19th, 2011, 02:08 PM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

I just tested and the update that I did still works.
Since the book project did not work, I looked for some alternatives. I found and experimented with a couple of options: a GeoIP locater and a Temperature Converter. I also implemented the parser for the return from all 4 calls, and set it to display the result in the view as text rather than in an alertView.

These are the implementations of the various calls with the new address for the GeoIP:


Code:
-(void)soap1_1Request
{
	NSString *soapMsg = 
	[NSString stringWithFormat:
	 @"<?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>"
	 "<GetGeoIP xmlns=\"http://www.webservicex.net/\">"
	 "<IPAddress>%@</IPAddress>"
	 "</GetGeoIP>"
	 "</soap:Body>"
	 "</soap:Envelope>",ipAddress.text];
	
	NSLog(@"%@",soapMsg);
	
	NSURL *url = [NSURL URLWithString:@"http://www.webservicex.net/geoipservice.asmx"];
	NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
	
	NSString *msgLength = [NSString stringWithFormat:@"%d",[soapMsg length]];
	[req addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
	[req addValue:@"http://www.webservicex.net/GetGeoIP" forHTTPHeaderField:@"SOAPAction"];
	[req addValue:msgLength forHTTPHeaderField:@"Content-Length"];
	
	[req setHTTPMethod:@"POST"];
	[req setHTTPBody:[soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
	
	[activityIndicator startAnimating];
	
	[self connect:req];
}
	 
	 
	 
-(void)soap1_2Request
{
	NSString *soapMsg = 
	[NSString stringWithFormat:
	 @"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
	 "<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">"
	 "<soap12:Body>"
	 "<GetGeoIP xmlns=\"http://www.webservicex.net/\">"
	 "<IPAddress>%@</IPAddress>"
	 "</GetGeoIP>"
	 "</soap12:Body>"
	 "</soap12:Envelope>",ipAddress.text];
	
	NSLog(@"%@",soapMsg);
	
	NSURL *url = [NSURL URLWithString:@"http://www.webservicex.net/geoipservice.asmx"];
	NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
	
	NSString *msgLength = [NSString stringWithFormat:@"%d",[soapMsg length]];
	[req addValue:@"application/soap+xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
	[req addValue:msgLength forHTTPHeaderField:@"Content-Length"];
	
	[req setHTTPMethod:@"POST"];
	[req setHTTPBody:[soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
	
	[activityIndicator startAnimating];
	
	[self connect:req];
}

-(void)httpGETRequest
{
	NSString *queryString = [NSString stringWithFormat:@"http://www.webservicex.net/geoipservice.asmx/GetGeoIP?IPAddress=%@",ipAddress.text];
	
	NSURL *url = [NSURL URLWithString:queryString];
	NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
	[req addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
	[req addValue:0 forHTTPHeaderField:@"Content-Length"];
	
	[req setHTTPMethod:@"GET"];
	[activityIndicator startAnimating];
	
	[self connect:req];
}

-(void)httpPOSTRequest
{
	NSString *postString = [NSString stringWithFormat:@"IPAddress=%@", ipAddress.text];
	NSLog(@"%@",postString);
	NSURL *url = [NSURL URLWithString:@"http://www.webservicex.net/geoipservice.asmx/GetGeoIP"];
	NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
	NSString *msgLength = [NSString stringWithFormat:@"%d",[postString length]];
	
	[req addValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
	[req addValue:msgLength forHTTPHeaderField:@"Content-Length"];
	
	[req setHTTPMethod:@"POST"];
	[req setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];

	[activityIndicator startAnimating];
	
	[self connect:req];
}
To test calling with the different options I set up a UISegmentedControl with the 4 options as part of the interface and rewrote the -buttonClicked method as follows
Code:
-(IBAction)buttonClicked:(id)sender;
{	
	[ipAddress resignFirstResponder];

	switch ([reqFormat selectedSegmentIndex]) {
		case SOAP1_1:
			[self soap1_1Request];
			break;
		case SOAP1_2:
			[self soap1_2Request];
			break;
		case HTTPGET:
			[self httpGETRequest];
			break;
		case HTTPPOST:
			[self httpPOSTRequest];
			break;
		default:
			break;
	}
}
If you are interested, I can make my amended project and the TemperatureConversion available to download. After checking those out, if there are questions, I can try to clarify anything that is unclear.
Bob
  #6 (permalink)  
Old January 19th, 2011, 02:23 PM
Registered User
 
Join Date: Jan 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Bob - that's great... I inserted the 1st routine and it worked fine.

If you could post all of the code for download, that would be great. I'm interested in seeing the temp example as well.
  #7 (permalink)  
Old January 19th, 2011, 03:34 PM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

I will post links to the project files late tonight or early tomorrow morning, since I am away from my computer right now.
Bob
  #8 (permalink)  
Old January 19th, 2011, 03:40 PM
Registered User
 
Join Date: Jan 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Bob... By the way, I'd love to chat more about what you are doing and also a project I am working on.... Any way we can talk about this off-line?
  #9 (permalink)  
Old January 20th, 2011, 10:44 AM
Registered User
Points: 34, Level: 1
Points: 34, Level: 1 Points: 34, Level: 1 Points: 34, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2010
Location: Fairfax, VA
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
Default Link to Working Code?

Have you posted a link to the working code?

Thanks.
  #10 (permalink)  
Old January 20th, 2011, 11:56 AM
Friend of Wrox
Points: 1,671, Level: 16
Points: 1,671, Level: 16 Points: 1,671, Level: 16 Points: 1,671, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

For those interested, a working example of the iptocountry project. All 4 request types are implemented, and a few interface and other tweaks have been made.
A second project demonstrating a temperature converter is also in the .zip.
https://files.me.com/thepianoguy88/q3k7xc
The file should automatically download to your default downloads location.
The link will expire in 30 days.
Questions/feedback/improvements are welcome, either in the forum or via email @
ipadhelper@me.com
Bob

Last edited by thepianoguy; January 20th, 2011 at 12:56 PM..




Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 14: Caching problem dbcook8 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 4 October 19th, 2008 10:46 AM
Problem : Sketcher in chapter 14 chang82 BOOK: Ivor Horton's Beginning Visual C++ 2005 1 September 8th, 2008 02:29 AM
Chapter 14 - use of CObject problem jabuck BOOK: Ivor Horton's Beginning Visual C++ 2005 0 February 15th, 2007 02:25 PM
Problem with code on Chapter 14 aargyri BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 3 June 6th, 2006 03:37 PM
chapter 14 Try It Out problem - update Jams30 BOOK: Beginning ASP 3.0 1 March 22nd, 2004 12:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.