 |
 |
|
 |
02-02-2010, 09:58 AM
|
#1 (permalink)
|
|
Registered Member
Join Date: Feb 2010
Posts: 4
|
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 ?
|
|
|
02-02-2010, 10:52 AM
|
#2 (permalink)
|
|
Registered Member
Join Date: Oct 2009
Posts: 50
|
Quote:
Originally Posted by dukeatcoding
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.
|
|
|
02-02-2010, 11:02 AM
|
#3 (permalink)
|
|
Registered Member
Join Date: Feb 2010
Posts: 4
|
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...
|
|
|
02-02-2010, 11:11 AM
|
#4 (permalink)
|
|
Registered Member
Join Date: Oct 2009
Posts: 50
|
Quote:
Originally Posted by dukeatcoding
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.
|
|
|
02-02-2010, 11:13 AM
|
#5 (permalink)
|
|
Registered Member
Join Date: Feb 2010
Posts: 4
|
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
|
|
|
02-02-2010, 11:17 AM
|
#6 (permalink)
|
|
Registered Member
Join Date: Oct 2009
Posts: 50
|
Quote:
Originally Posted by dukeatcoding
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?
|
|
|
02-02-2010, 11:25 AM
|
#7 (permalink)
|
|
Registered Member
Join Date: Feb 2010
Posts: 4
|
Quote:
Originally Posted by tychop
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
|
|
|
02-18-2010, 12:19 AM
|
#8 (permalink)
|
|
Registered Member
Join Date: Jan 2009
Posts: 5
|
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
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» Advertisements |
» Online Users: 460 |
| 54 members and 406 guests |
| AlexTheMighty, alexy, aoredsson, arcturus, bbarlow641, benoitr007, BrianSlick, ChrisMayer, CunningCat, cye, davec2, davidcort, dbuddah, doblezeta, Dorald, dre, Duncan C, Ed99, elite, FerrariX, graph, HARDWARRIOR, harkonian, howcr, iisword, iminichrispy, imsatasia, itzdark, Janek2004, javaconvert, jbro, JoshuaCaputo, landingham, LemonMeringue, MiniRobinho, Mr Jack, myPhone, rarindeed, robin1508, rocketman240, Rossco, Rudy, sayer, Son of a Beach, sorghum, tateyaku, Thaurin, ToM, TunaNugget, xiko, XXX, _nivek |
| Most users ever online was 779, 05-11-2009 at 09:55 AM. |
» Stats |
Members: 24,136
Threads: 38,911
Posts: 170,717
Top Poster: smasher (2,565)
|
| Welcome to our newest member, cye |
|