I am doing Objective C programming and I want send and receive requests(Login/data fetching) over the client/server.
Now the problem is Should I do it using XML or any other Method.
Also I know nothing how to write XML for any particular website.
I am hassling for many days.Can anybody help?
XML particularly SOAP is very bloated and the support in Objective-C is severely lacking. I would recommend JSON for lightweight use and in fact Apple use it for their Push Notification server.
If you DO want SOAP then check sudzc.com for an online objective-c generator from a WSDL.
There's no such animal as "any particular website." Some return data in HTML, RSS, ATOM, or JSON format, others may use a custom XML schema all their own. Likewise with the data you send; they may expect requests via SOAP or HTTP, with any type and number of inputs the creators chose.
In short, you need to find out exactly what is expected by the one particular site with which you're trying to communicate, and give it what it wants. That's why programmers get paid the big bucks, because there's no easy "do what I mean" button. :-)
Your question is whether you should use xml or any other method of communication.
XML has been designed to standardize communication, which is especially handy for communicating between several parties, as the structure of the document can be formally written down in a document and can be validated, so there is no discussion afterwards about the syntax of the document.
Although that is a noble idea, XML is relatively complex and not as light weight as, for example, json.
As long as you are writing your own client that communicates to your own server, the protocol used between those 2 can be anything, and do not need to be XML.
Therefore I would suggest using a lightweight and easy to understand protocol. Json is gaining popularity due to its simplicity.
If you have control over the output of the data on your server, I'd suggest you output the data directly as a plist. Plists are native dictionary objects that can be directly instantiated with [NSDictionary dictionaryWithContentsofURL:].
Take a look at the PList programming guide for proper formatting.
Related
I'm developing small application for iOs, and I have got a problem.
My application uses restful API, using post requests and as response it receives XML.
API has about 40 different methods, and problem is that I need to parse them all into objects. But, I want to implement all of the parsing in one class. I'm using NSXMLParser, and as far as I understand I must use different classes to use as a delegate for NSXMLParser.
Is there a way to do it one class?
If you are developing a small project and you want to avoid headaches, the best way to parse XML files is using ElementParser, simple and easy to use parser with examples in its webpage. With it, you can set different callbacks for different elements in the XML, so you can do all the parsing work in one class.
Also note that is free of charge only for personal use, and you have to pay a license if you plan to use it with commercial purposes.
I'm looking for the algorithm that Google's Web Toolkit uses to serialize data posted to the server during an AJAX request. I'm looking to duplicate it in another language so that I can tie in another of my projects with a GWT project.
Any help is much appreciated!
The GWT-RPC serialization is heavily tied to Java. It even sends Java class names over the wire.
I suggest you use something like JSON to communicate with the server. This way, you can use any programming language with the GWT server.
Update: There are no definitive references to the GWT-RPC format, and a mailing list post explains that decision:
The GWT RPC format is intentionally opaque JSON. This makes it
somewhere between difficult and impossible to add a non-GWT agent to
the RPC discussion. There isn't really a nice work-around for
creating a non-Java server-side implementation but, because your
RemoteServiceServlet implementation just has to implement your
synchronous RPC interface, it's quite possible for non-GWT clients to
talk to the same server-side business logic, just without using the
RPC protocol.
and the little detail which surfaced was
The wire format is plain text. It's actually JSON. It's just
unreadable JSON because the assumption is that both the producing and
consuming code is auto-generated and can make all kinds of assumptions
about the structure of the text.
I've written a design document explaining the GWT-RPC wire format. Hopefully you'll find it useful.
We're deciding between using JSON vs. Property List (binary) for our API, which will be accessed by iPhone/iPad/iPod Touch.
Are there any speed advantages?
The server guys are going to understand JSON better.
Plists work really well and have much, much better type safety. The real issue you'll run into with JSON is someone server side adds a few quotes around a number and suddenly your app is crashing.
But, JSON is compact, easy to read (unlike binary plists), and as noted is really well understood. So just be very careful in the parsing code, and try out JSON.
According to Sam Soffes, JSON.
edit: he talks about xml-based plists, not binary plists. Either way, json will typically be easier to generate from web based api's.
I've got an Objective-C/cocoa based application that I'm working on. This app is client<->server. Currently, the communcation protocol is based upon some fairly simple XML. While XML works for this task, it is not ideal in any aspect. It's a pain to serialize data to XML, it's not particularly light-weight, and difficult to incorporate non-data information (such as: 'do this next') in.
I'm looking for suggestions to an alternative.
I've considered some of the ones listed here, but haven't decided on any. Suggestions?
If you are talking to a Objective-C server you can look into encoding and decoding with the preferred serialization methods available in Objective-C.
NSKeyedArchiver and NSKeyedUnarchiver
Basically you will get an NSData from the NSKeyedArchiver that you will send (bytes/length) to the other part and there place it back into an NSData and use NSKeyedUnarchiver to unpack it into objects again.
I'm using JSON for an iphone application - I typically would prefer XML, but we needed it very lightweight, so we decided on JSON.
If your working with XML, you should take a look at XPath if you've not already - it will give you tremendous power for extracting values from a XML data structure.
What kind of server do you have? If the server is java based I'd recommend looking at HessianKit by Fredrik Olsson. Encode/Decode to ordinary Objective-C types and put in NSArrays and NSDictionaries will make the experience smoother.
What's wrong with (Portable) Distributed Objects?
I'm going to use gSOAP to interact with a WCF webservice in my Mac project. It does pretty much exactly what I need and it does it well (pretty much the exact opposite of WSMakeStubs;)). The only downside is that it's C/C++ only, meaning I either need to convert all my types into C types on the fly or write a complete wrappering solution to do it for me.
I'd rather not reinvent the wheel here, and I'm obviously not the only one who has wanted to do this, but so far I haven't been able to find anybody who has actually posted any code to this effect.
Does anybody know of any code available that would save me from having to write the whole thing myself?
(It doesn't quite answer your question, but) I've used the techniques used in Cocoa SOAP Client (open source) to connect to a server and send/receive SOAP requests. It works really well, unless you are connecting to a server with a self-signed SSL certificate.
(This basically translates XML structures into native Cocoa structures, and back the other way on sending).
We use gSOAP at work, and it does the job, but makes lots of generated code, and limits you to working in particular ways with the data.
I'm working on a wrapper generator (or possibly modifications to gSOAP itself to contribute back); I'm not done and won't be for a little while.
Note: I'm one of the folks you linked to.
I'd say the current answer is "No".
I ended up creating an Objective-C wrapper mostly by hand for my web service (including category methods for NSArray to translate an NSArray of X into a soap array of X and vica versa, etc) since it was a one-off and I did not expect it to change particularly often. I'm happy with it, but I do need to modify it by hand whenever a signature is changed or a method is added.