tags:

views:

32092

answers:

10

Hi,

I'm planning to develop an app for the iPhone and that app would have to access a couple of SOAP services. While doing some basic checking in the iPhone SDK I was not able to find any support for accessing SOAP services, a bit of Googling lead to the conclusion that there is no support for SOAP in the iPhone SDK.

So if I do want to build that app I'll need to come up with a approach to access SOAP services from the iPhone. What would be the best approach? Any best practices? Did someone already write a library using the functionality that is present in the iPhone SDK to access SOAP services?

(Since the service I need to access is exposed by another party and they only expose it as SOAP, it's unfortunately not an option to switch to another type of interface (e.g. REST based API).

Gero

A: 

Have a look at www.remobjects.com and their roadmap. They have RO|C on the way, and that can connect to their web services, which probably includes SOAP (I use the VCL version which definitely includes it).

mj2008
+4  A: 

One word: Don't.

OK obviously that isn't a real answer. But still SOAP should be avoided at all costs. ;-) Is it possible to add a proxy server between the iPhone and the web service? Perhaps something that converts REST into SOAP for you?

You could try CSOAP, a SOAP library that depends on libxml2 (which is included in the iPhone SDK).

I've written my own SOAP framework for OSX. However it is not actively maintained and will require some time to port to the iPhone (you'll need to replace NSXML with TouchXML for a start)

schwa
The first thought that came to my mind when I saw the question was "Don't."So +1 to FutureSchwa for reading my mind :-)
Ramin
Can you elaborate on this statement "But still SOAP should be avoided at all costs"
WillF
If you don't mind, I'd really like an explanation to go along with this response. Also, when you say "converts REST into SOAP for you" I think you meant convert JSON into SOAP. Is this correct?
senfo
Yeah, also wanting the explanation. If you just say "Don't", I want to know if you are basing it on something specific you know about iPhone/SOAP problems. On the other hand, if it's just the normal, general reasons for avoiding SOAP, I can Google "SOAP vs REST" and get a firehose mouthful of that.
Erik Hermansen
Gonna downvote you here because you've had a full year to answer the question of why you said "don't", and you haven't. Three people have asked now.
Warren
Just cause soap is not necessarily appropriate doesnt mean its not right in his implementation, there are needs that go beyond best practive more often than not
tigermain
@schwa - Downvoted for posting a potentially useful answer with absolutely no supporting evidence or defense.
DougW
+3  A: 

I've historically rolled my own access at a low level (XML generation and parsing) to deal with the occasional need to do SOAP style requests from Objective-C. That said, there's a library available called SOAPClient (http://ditchnet.org/soapclient/) that is open source (BSD licensed) and available on Google Code (http://code.google.com/p/mac-soapclient/) that might be of interest.

I won't attest to it's abilities or effectiveness, as I've never used it or had to work with it's API's, but it is available and might provide a quick solution for you depending on your needs.

Apple had, at one time, a very broken utility called WS-MakeStubs. I don't think it's available on the iPhone, but you might also be interested in an open-source library intended to replace that - code generate out Objective-C for interacting with a SOAP client. Again, I haven't used it - but I've marked it down in my notes: http://code.google.com/p/wsdl2objc/

heckj
Thanks, I tried to use wsdl2objc. The generation of ObjectiveC code from the WSDL works, but is (as expected) does not directly compile against iPhone SDK. I tried to tweak the sources a bit, but ended up with a bunch of errors I could not resolve
Gero
+31  A: 

http://code.google.com/p/wsdl2objc/ just added iPhone SDK Compile Support!

Smallinov
+4  A: 

My solution was to have a proxy server accept REST, issue the SOAP request, and return result, using PHP.

Time to implement: 15-30 minutes.

Not most elegant, but solid.

davidjhinson
+3  A: 

here is a really great tutorial on SOAP webservices on the iPhone

Click Here For Tutorial

zPesk
A: 

Hi,

@schwa: why do you consider that SOAP shall be avoided on iPhone ?

Quentin

Quentin
Try commenting on his answer, this is not an answer to the question of OP.
lhunath
Good point. Looks like someone else has already asked. If you delete this answer, you're more likely to get to 50 and be able to comment. :-) Upvoting only to help push you closer...
Quinn Taylor
+8  A: 

http://sudzc.com/

it will convert wsdl to soap client in Obj C

Sijo
A: 

I just stumbled upon WSClient++ which supports asynchronous as well as synchronous soap client generator for iphone as well as mac os x.

Akash Kava
A: 

hi I am in big trouble now. i have to post data on a sharepoint using iphone and a webservice which is crated by .net suppose this is my webservice "http://192.168.0.58:301/_layouts/AppleIphoneService.asmx"

NSURL *url = [NSURL URLWithString:@"http://192.168.0.58:301/_layouts/AppleIphoneService.asmx"]; NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];

and what i have to do is i have to pass an url say "http://moss2010:301/Docs/Lists/WorkSheet/calendar.aspx" as string with soap msg and when i am passing it raising error of "Access denied"

because sharepoint having credential.

this is what i am doing.....

NSString *Url=@"http://192.168.0.58:301/Docs/"; NSString *list=@"WorkSheet"; NSString *tt=@"Meeting"; NSString *stdt=@"2010-08-12-14-00-00"; NSString *Endt=@"2010-08-12-15-00-00"; NSString *City=@"NY"; NSString *Des=@"This is meeting for getting final payment"; soapMessage= [NSString stringWithFormat: @"" "" "" "" "%@" "%@" "%@" "%@" "%@" "%@" "%@" "" "" "",Url,list,tt,stdt,Endt,City,Des];

NSLog(@"SOAP MESSAGE:%@",soapMessage); NSURL *url = [NSURL URLWithString:@"http://192.168.0.58:301/_layouts/AppleIphoneService.asmx"]; NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url]; NSString *msgLength = [NSString stringWithFormat:@"%d",[soapMessage length]]; [theRequest addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; [theRequest addValue:@"http://tempuri.org/AddCalendarItem" forHTTPHeaderField:@"SOAPAction"]; [theRequest addValue:msgLength forHTTPHeaderField:@"Content-Length"]; [theRequest setHTTPMethod:@"POST"]; [theRequest setHTTPBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]]; NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; if(theConnection){ webData = [[NSMutableData data] retain]; NSLog( @"connection established"); } else { NSLog(@"theConnection is NULL"); }

My Question is how to use such url having credential?

Amitesh Kumar
post it as a question. Noone will find your post here, not even speaking of trying to answer it - format your code when posting
Vladimir
wow earthquake.
aryaxt