Ruby On rails In iPhone - iphone

I am trying to create a app which uses a webservice to store and to retrieve data. We are using a Ruby On Rails webservice. We're not able to use post Method to store data on Ruby On rails Webservice. Does anybody have an idea on how to send request to save data to the server. How to access ruby on rails web service????? Any help will be appreciated!!!!!!

You can choose either rc-tool or RestClient

Since RoR is Rest conform you can use RestKit to get/post your data.
RestKit is a Cocoa framework for interacting with RESTful web services in Objective C on iOS and Mac OS X. It provides a set of primitives for interacting with web services wrapping GET, POST, PUT and DELETE HTTP verbs behind a clean, simple interface. RestKit also provides a system for modeling remote resources by mapping them from JSON (or XML) payloads back into local domain objects. Object mapping functions with normal NSObject derived classes with properties. There is also an object mapping implementation included that provides a Core Data backed store for persisting objects loaded from the web.

Related

Reusing server code in a GWT+phonegap app avoiding RPC

We are about to create a mobile version of our web page. In that page we have used RPC services in a service way, not totally entity oriented. So we are going to have two clients (web and mobile) calling one server.
Now we want to reuse all that server code supporting several client versions and avoiding all the "dto version hell" that the RPC calls have.
I have seen that we need to create a wrapper, another layer in the server, for exposing methods to the mobile versions (GWT+phonegap and in the future: IOS, Android...). Later this layer would reuse all the server code (model, repositories... etc), in the server the access to BigTable is done through Objectify.
Which technology would you use for this new layer?
For mobile apps I like to use AutoBeans + RequestBuilder on the Client and AutoBeans and Restful API which (also) produces JSON on the server side.
With AutoBeans you define the structure of your data with Java interfaces. (Which gives you something to program against) and AutoBeans handles the conversion from Object to JSON and from JSON to Object for you on the server and on the client as well.
In combination you can build a very fast and good architectured RPC. AutoBeans is used by RequestFactory as a default mechanism for serialization.
If you ever decide to support other platforms you can still use the JSON and parse it there. If you decide to support a native android application the AutoBean mechanism should just run fine on the android vm.
A good example for AutoBeans can be found here: http://code.google.com/p/google-web-toolkit/wiki/AutoBean

RESTful web server library for iOS

I am trying to create a Rest web service running on iPhone; I've done my initial research and found
CocoaHttpServer and TouchCode json parser, is there any library / sample code which binds these together into a Rest endpoint?
If it does not exist, how do I go about writing one? Any reference to some kind of design document etc. will really help.
I'm using CocoaHTTPServer and the iOS builtin JSON libraray to have a RESTful service in iVocabulary. First I wrote a lengthy Connection class (the core for handling requests in CocoaHTTPServer) myself. But parsing the URL was kind of complicated.
So I wrote a more generic Connection class that routes HTTP requests to different blocks for different URLs and different HTTP methods. The URL can contain parameters (with : as prefix), that get parsed. That's not a generic REST service per se, but I added (for example) a block for the url "/rest/:entityname" that fetches all Core Data objects of the given entity.
You can find that router implementation in my fork of CocoaHTTPServer on github: https://github.com/chbeer/CocoaHTTPServer
Another router implementation: https://github.com/mattstevens/RoutingHTTPServer
Check RestKit for working with Restful web services.
http://restkit.org/
I recommend RestKit, I have used for over a year now and love it. However I recently learned about AFNetworking from some colleagues that claim it's very lightweight and thus prefer it as an alternative to RestKit, so I am giving it a try soon.

Cocoa library to interact with any web service API

Is there a general Cocoa or Cocoa Touch library for interacting with any web service API, or one which can be used as a basis for creating my own library for a web service? For example, I could add some details about how to interact with the Vimeo API (how to verify user details, what URLs to call). I'm not sure how this would work in reality.
If not, can anyone suggest an web service library which I could alter to change the API calls? It would need to be fairly simple (a small API) and easy to adapt. An example is this Cocoa library for Twitter (although it would probably be too complicated to adapt). Would it be easier just to code it up from scratch?
I don't think there is a library that will automagically work with any web API. In fact I don't even think it's possible to write such a library, since you can define your web API any way you want to. That library would have to be pretty smart in order to figure out how to use an arbitrary API.
I think the closest you'll get is something like ASIHTTPRequest, which is a great library for interacting with web services. If you add a JSON and/or XML parser you'll have everything you need to interact with almost any web API.
Found another library for interacting with RESTful web services. It's called RestKit. From their description:
RestKit is a Cocoa framework for interacting with RESTful web services in Objective C on iOS and Mac OS X. It provides a set of primitives for interacting with web services wrapping GET, POST, PUT and DELETE HTTP verbs behind a clean, simple interface. RestKit also provides a system for modeling remote resources by mapping them from JSON (or XML) payloads back into local domain objects. Object mapping functions with normal NSObject derived classes with properties. There is also an object mapping implementation included that provides a Core Data backed store for persisting objects loaded from the web.

CoreData web service using MySQL

I currently have a MySQL database that I wish to create a web service for.
One of the main purposes of this web service is to be used in an iPhone app. Because of this I would like to used CoreData, as it will make parsing on the iPhone side so much easier. How would I use CoreData to get the data from my MySQL database? Are there any good tutorials around?
To get the data from the server to the iPhone I would recommend JSON.
Then you need to write some code that will turn that JSON into an object that you can put into the CoreData database. You have a couple choices there, but I would recommend providing your own implementations of the NSCoding protocol. The great part about the NSCoding approach is that the object itself defines what it needs to save/restore one time, then you simply do additional implementations one time to support other formats (e.g. XML, JSON, simple serialization).
Here is the tutorial to sbjson, a JSON parser on Objective-C: sbjson project

What common backend can be accessed securely from an iPhone and Android application?

I'm thinking about creating an application for the iPhone and Android that will need to access a common backend to retrieve account information. Can both access a web service over https? What other way would allow me to have one interface to the backend that is accessible by both?
They both work over http and https which is a common enough protocol. I would suggest you go with a RESTful web service so you expose your service via URI's like http://www.myservice.com/weather/zip/98007 which would return an XML blob that can be parsed by the client.
if you are starting from nothing, i'd definitely go with RESTful service that returns/accepts JSON... there are plenty of libraries for both platforms that will accept JSON and turn it into arrays and dictionaries.
I'd recommend using a RESTful web service backend, which is all standard HTTP and/or HTTPS. If you can use Ruby on Rails, its default scaffolding will get you about 99% of the way there and for the iPhone there is an open source project called ObjectiveResource that will automate your communication with this Rails backend. I haven't investigated yet what options are available on Android but since it is all simple HTTP it should be straightforward. I am not the maintainer of ObjectiveResource but I have contributed some code. You can check it out here:
http://iphoneonrails.com
One good approach I have seen used with other services is to write the backend in such a way that it can feed data back in different types - for Android an XML response is best, but for the iPhone sending back plist data is preferred (though it can also work with XML if required). In both cases it's easier to simply POST updates back to the server than to wrap an update in XML.
Both platforms should be able to use whatever form of authentication you wish to use, the iPhone I know supports all methods of HTTP authentication.