1

Our new iPhone project consists of a native app and a server it needs to communicate with. I'd like the server to be written in Python/Django.

The last time we created something similar, the server was in written in asp.net and it exposed relevant methods as a SOAP-based web service. This was very convenient, since we were able to generate almost all server communication code from the WSDL using http://sudzc.com/. Now I basically want to do the same, but with Django instead of asp.net. More specifically, I want to expose methods and objects over an API and I'd really like to have some automatic Objective-C code generation at the other end.

I've looked at a few libraries for Django that are supposed to expose RESTful APIs, and most people seem to recommend django-piston or django-rest-framework. Will either of them have a WSDL-style description that I can use to auto-generate ObjC-code, though? Is there another set of tools for achieving what I'm after that I should be investigating?

winsmith
  • 20,791
  • 9
  • 39
  • 49
  • Since this is getting a considerable amount of views but no answers, I have to ask: Is this question inherently stupid or unanswerable? If yes, what should I change? – winsmith Feb 10 '12 at 13:57
  • 1
    I think the question is fine, I just don't know of a framework. I've rolled my own REST client code, basically using a facade I created to generate JSON from an NSDictionary, convert to the JSON to NSData and sending the calls using NSURL/NSMutableURLRequest. Short answer is, I don't know of one. – rooftop Feb 10 '12 at 15:23
  • Thanks. If I find something, I'll obviously post it here. First revelation today: SOAP and REST are *very* different animals. – winsmith Feb 10 '12 at 15:45
  • Also, django-rest-framework plus restkit (http://restkit.org) seem like a good combination. – winsmith Feb 10 '12 at 15:50

1 Answers1

3

In my personal experience I don't know of anything that exists to generate client-side stubs in Objective-C for a REST service. However, there's a very good library called RESTKit that features a JSON or XML to object mapping layer, and nice features like CoreData integration and local caching. There are number of useful Stackoverflow questions on it.

So that can get you part of the way, since it will handle communication and object mapping. If you need to build code-generation, it could output code that sets up RESTKit's mapping structures.

Another REST client lib for iOS that I like a lot is LRResty, for its clean API, but it's lower level than RESTKit in that it doesn't have any built-in parsing/object mapping features.

In this similar stackoverflow question there's a link to something called wsdl2objc which sounds like it's in line with what you need on the iOS side (I've no personal experience with it, so ymmv, etc...)

Community
  • 1
  • 1
aalpern
  • 652
  • 4
  • 8
  • wsdl2objc is actually not very good in my experience. For others who read this question, I'd recommend http://sudzc.com instead. Both are only able to generate code from wsdl web services though, and not from REST resources. – winsmith Feb 10 '12 at 16:31
  • Yeah, I think one of the problems is that there's no standard descriptor format for REST APIs yet (although there are a few attempts). At least when you control both sides you still have the possibility of leveraging metadata in your server side implementation to help generate the client. – aalpern Feb 10 '12 at 16:55