views:

164

answers:

1

I am trying to make a server client app for iphone and I am using json. I want to load and store some text and some images to my sql server. I was able to get the text from my server but not the images and I have not figured out how to post things to my server.Am I in the right track here or should I start using xml. Can anybody help me?

+1  A: 

If you are using MSSQLServer then writing sever side web services is pretty trivial. With those you should be able to use JSON or XML without too much trouble (but for JSON you need to set the request types)

[[self theRequest] addValue:@"application/json; charset=utf-8" forHTTPHeaderField:@"Content-type"];
[[self theRequest] setValue:@"json" forHTTPHeaderField:@"dataType"];

Posting text is easy (just use a post request) but to post images you need to simulate multipart forms.

Although there is plenty of code samples around to demonstrate that, I found the ASIHTTP library http://allseeing-i.com/ASIHTTPRequest/ made it all so easy I gave up with my own web service libraries and used that instead.

Andiih
will i be able to connect to my server directly whith this?
alecnash
define directly ? You will be able to call RESTful web services. But it's not offering a full SOAP layer where the .NET class methods are available to your iPhone code.
Andiih