Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-02-2010, 09:58 AM   #1 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 4
Default Connection to a Webservice via Soap

Hello everybody,

Currently I am working on the problem to communicate with a WebService using Soap.

There seems to be no really stable framework coded in objective-c. So I thought about using some C++. But I wonder if its really possible to work with C++ on the Iphone because of the need C++ libs.

Has anyone other ideas for connection to a Web Service or experience in using C++ on Iphone ?
dukeatcoding is offline   Reply With Quote
Old 02-02-2010, 10:52 AM   #2 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 50
Default

Quote:
Originally Posted by dukeatcoding View Post
Hello everybody,

Currently I am working on the problem to communicate with a WebService using Soap.

There seems to be no really stable framework coded in objective-c. So I thought about using some C++. But I wonder if its really possible to work with C++ on the Iphone because of the need C++ libs.

Has anyone other ideas for connection to a Web Service or experience in using C++ on Iphone ?
I use the iPhone SDK for webservices. I create a request like the next code fragment shows, and use NSXMLParser for parsing the response. (use NSXMLParser delegates for nested XML tags).

Code:
	NSString *path = [NSString stringWithFormat:@"*****.xml", [[NSBundle mainBundle] bundlePath]];
	NSString *nakedRequest = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
	NSString *soapMessage = [NSString stringWithFormat:nakedRequest,
							 @"user",	
							 @"pass",							
							 @"id",							
							 returnType,							
							 origin,								
							 destination,							
							 originDateString,							
							 destinationDateString,						
							 @"Timetable",							
							 @"1",									
							 @"0"									
							 ];
	
	NSURL *url = [NSURL URLWithString:@"https://services.*****.com/*****/*****.asmx"];
	NSString *messageLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
	NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];	
	[theRequest addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
	[theRequest addValue:@"http://www.*****.com/*****:*****" forHTTPHeaderField:@"SOAPAction"];	
	[theRequest addValue:messageLength forHTTPHeaderField:@"Content-Length"];
	[theRequest setHTTPMethod:@"POST"];
	[theRequest setHTTPBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
	theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
	if (theConnection) {
		soapResponseData = [[NSMutableData data] retain];
	}
Works like a charm.
You could even opt to start parsing while the response is still loading.

Last edited by tychop; 02-02-2010 at 11:13 AM.
tychop is offline   Reply With Quote
Old 02-02-2010, 11:02 AM   #3 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 4
Default

Thx for your answer

Yes shure it works for small things like communication with a Hello World passing a string an receiving somehting.

The webservice i have to connect to offers several services with a lot of objects to serialize and pass through. So my favorite way would be a good wsdl2obejctive-c with a soap framework...

My last option would be to write all the objects by hand and setup all the needed soap messages by hand...
dukeatcoding is offline   Reply With Quote
Old 02-02-2010, 11:11 AM   #4 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 50
Default

Quote:
Originally Posted by dukeatcoding View Post
Thx for your answer

Yes shure it works for small things like communication with a Hello World passing a string an receiving somehting.

The webservice i have to connect to offers several services with a lot of objects to serialize and pass through. So my favorite way would be a good wsdl2obejctive-c with a soap framework...

My last option would be to write all the objects by hand and setup all the needed soap messages by hand...
FYI (& others): I use it to parse xml responses 5 to 8 levels deep.
It's usable for more complex stuff than just 'Hello World'.
But hey, If you do find an easy shortcut, please share.
tychop is offline   Reply With Quote
Old 02-02-2010, 11:13 AM   #5 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 4
Default

Shure but a lot of handwork to do

I have do send an object action package, which has action objects... which have objects... and then receive something similar
dukeatcoding is offline   Reply With Quote
Old 02-02-2010, 11:17 AM   #6 (permalink)
Registered Member
 
Join Date: Oct 2009
Posts: 50
Default

Quote:
Originally Posted by dukeatcoding View Post
Shure but a lot of handwork to do

I have do send an object action package, which has action objects... which have objects... and then receive something similar
Yeah, I know. It's a real pain to get it done.
Has anybody else been able to use a wsdl to generate objects & messages for use on an iPhone?
tychop is offline   Reply With Quote
Old 02-02-2010, 11:25 AM   #7 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 4
Default

Quote:
Originally Posted by tychop View Post
Yeah, I know. It's a real pain to get it done.
Has anybody else been able to use a wsdl to generate objects & messages for use on an iPhone?
There are two intersting Projects out there one I am helping a little bit but which is in kinda alpha

drekka's dXml at master - GitHub

And one which seems to be dead
wsdl2objc - Project Hosting on Google Code

Both of them are a pain in the *** because they are not really document
dukeatcoding is offline   Reply With Quote
Old 02-18-2010, 12:19 AM   #8 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 5
Default

Hi guys,

I'm the author of dXml. I'm fairly new to Mac stuff so theres been a delay whilst I've figured out howto document stuff. I just recently found the GitHub Pages and worked out how to use it. It's quite a learning curve with Objective C iphone SDK, markdown, textile, jekyll and liquid all in the mix

So I'm now pouring documentation into drekka.github.com/dXml site for dXml.

BTW< I've just uploaded v0.1.1 which now includes basic XPath.

Have a look, suggestions welcome.

Derek

Last edited by drekka; 02-18-2010 at 06:04 AM. Reason: updated site
drekka is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 24,136
Threads: 38,911
Posts: 170,717
Top Poster: smasher (2,565)
Welcome to our newest member, cye
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:15 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0