I am writing an ipad app that's going to list data, including images, from a WS.
I am going to consume a web service written in .net (.asmx). I looked at 2 examples,
the seismicxml that uses NSOperation and uses an xml feed.
another awesome example from Wei-Meng Lee that does not use NSOperation but shows how to make the soap envelope and uses an asmx service.
My question: is it better to use NSOperation and threading?
Or should I just forget about it and go with the simple implementation?
Plz help me, I am confused!
Thanks,
Simone
The SeismicXML and the LazyTables are good examples that show how to load images from a web service in a UITableView using NSOperation and xmlParser. But the NSURLConnection request is called outside the NSOperation, so I had to modify it a little to suit my purposes. Another good example that I found is the LinkedImageFetcher which shows how to fetch images from a website, and includes NSURLConnection request inside an NSOperation.
Related
I am new to iPhone application development and working on a web service based application.
I am using NSXML parser in this application and all is working finr, I am able to get the data from server.
But my friend told me that I should include ASIHTTP Classes in this project that is mandatory, but I wonder as I have not used any usch classes as of now and still i am able to fetch the data successfully.
Can any body please explain me what is the purpose of ASIHTTP classes and if i don't use it then would that be a right approach?
I will also need to do Lazy loading in my project so will that be possible without ASIHTTP Classes?
Please help me to clear my doubts.
Thanks in advance.
iPhone Developer
You can obtain any information you're looking for from here, ASIHTTPRequest - How To Use
Alternatively, you can use NSURLConnection
Both routes you can use Asynchronous request to perform lazy loading.
I'm not sure this question is appropriate here but I hope I could get some help. What i'm looking to do is basically to make a server based iPhone application. I've got an ubuntu server ready to be used. I'm thinking of making a web service which my application then can use but I have virtually no experience in this field so i'm looking for some help to get pointed into the right direction, what language to write the web service in etc. It isn't required to be a web service but anything that make's the iPhone app depending on the server.
This little mission is simply for learning experience.
Probably PHP is what you will use to write the webservice. REST based services are the most popular, but it could be as simple as a form POST passing in parameters. The PHP script (no matter which way you write it), will then pass those parameters and any other needed info to a server method that either executes a SQL query (preferably using a stored procedure) or uses some other server resource. That data would then be output via the webservice as either XML or JSON (I personally like JSON better).
Check out Ray Wenderlich's tutorial on just this kind of thing:
When it comes time to handle the request in iOS, my personal choice is AFNetworking. It uses blocks instead of delegate methods and is blazing fast. I can hook you up with examples if needed.
Ok, First you need to learn how to write web services in PHP. Which will return you response in XML format. I personally prefer .PLIST format because it gets easier to parse on the iOS.
Once your web services are up and running. You need to use NSURLConnection and NSURLRequest to talk to your web services. Implementing the NSURLConnection Delegate methods correctly, you can download your XML response, maybe save it in a file on your Documents Directory.
Then once done downloading start parsing that response using NSXMLParser. implementing the delegates and what not, you can create your data structure the way you feel comfortable with manipulating it and store the parsed results in them and populate your View accordingly.
I am developing application in iPhone, Where i need to download and upload data from webservice. Please advice me which is the best class or Framework to achieve this and also please let me know which is the best xmlparser.
you can use asihttprequest and asihttpresponse for establishing connection use restful api and nxxml parser for parsing the data comes from server
thanks
NSXMLParser is a SAX parser included by default with the iPhone SDK.
TouchXML is an NSXML style DOM XML parser for the iPhone.
If your web service has the ability to return json, I would highly recommend doing so and using http://code.google.com/p/json-framework/. Especially if you have a complex XML document.
As for connecting to the service, it's pretty straightforward - all you need is a method to handle the connections. While there are 'frameworks' out there, it's as simple as creating a method such as "getDataFromService:(nsstring *)param1" and within that method issuing a request.
I think the bigger question you'll need to answer is how to authenticate with the service, if required. If the service uses OAuth, http://code.google.com/p/gtm-oauth/ is a great framework.
I have an application in which I have to hit many web services in same class and from another classes also and I have to parse the data each time.I cant write the delegate methods for webservice hit and XML Parse everytime as its not a good programming practice. So I thought of maintaining common classes for 'webserviceHandler' and 'XMLParsingHandler' in which I will write delegate methods for web service and XMLParsing respectively.
Now the problem is how to make it happen to call these delegates each and everytime I hit the webservice from another classes..??
Code for this is more appreciable..
Thanks in advance..
Cocoa Programming for Mac OS X Chapter 28. Web Services using NSXMLDocument
There is also an example from ADC SeismicXML using NSXMLParser
we were asked to develop an iphone app like the one in the figure.
The problem is: we have no experience in IOS development.
For the basic part I can handle the learning curve, but i need suggestions, best practices on the UIKit model and controls.
This is a newspaper app.
The accordion control shows/hides content based on categories retrieved by an ASP .NET CMS on which we have no control.
I can suggest to the CMS holder to develop a couple of web services (WCF) but i'm not sure how to interface iOS with MS technology.
Furthermore, i have the idea that simple aspx that returns XML/JSON data will be easier to call, and support, but slightly less secure.
So, suggestions? Tutorials?
If you like to use JSON and a very good HTTP-request-framework I have two links for you. Both sites contain various tutorials on how to use them.
json-framework
ASIHTTPRequest
Concerning the request and delegate stuff: For a start, I would skip the delegate part and use a synchronized HTTP request called in a thread (you'll see what that is on the second website). That makes the response handling a lot easier for the start. But I personally think, that using an asynchronous request is not a must. It's just nicer, if the architecture allows it. In my application, it wasn't realizable without lots of code overhead.
You want to output an XML feed in "plist" format (look it up, its simple theres lots of info on it).
Then you can do:
NSArray *plistContents = [NSArray arrayWithContentsOfURL:[NSURL URLWithString:#"http://theinternet.com/pathToMyPlist.asp"]];
That will get all the output into an array.
Some other resources you may find interesting/useful include NSURLRequest and NSURLConnection. For the latter you will have to learn about delegate methods and such - its complicated, but its incredibly useful information.
We did several applications here using XML parsing like what you're suggesting at the end of your question. If you are concerned about security, you can implement handshaking or other security measures over that.
EDIT: XML parsing done using NSURLConnection to gather the content and NSXMLParser/NSXMLParserDelegate to do the actual parsing.
EDIT2: There is an official sample, called SeismicXML from Apple. It should get you started with iPhone XML parsing and data downloading.