Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 07-30-2010, 10:04 AM   #9 (permalink)
rmlopes
Registered Member
 
Join Date: Jul 2010
Posts: 1
rmlopes is on a distinguished road
Default help - soap response

Hi,

I have a problem: when i receive the response from the webservice, i receive a xml file, but it contains a header (soap header).
When I use the NSXMLParser, is recognizes 4 elements (soap header) and the other elements (the ones i'm interested in), it recognizes as string.
How can i not receive the soap header?

thanks

iChat: Rui.Lopes@me.com


Quote:
Originally Posted by tychop View Post
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.
rmlopes is offline   Reply With Quote
 

» Advertisements
» Online Users: 357
11 members and 346 guests
AyClass, Domele, esoteric, HemiMG, ipodphone, jakedukes3003, Newbie123, online-loans70, PavelSea, thephotographer, TomTool
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,568
Threads: 94,081
Posts: 402,751
Top Poster: BrianSlick (7,990)
Welcome to our newest member, online-loans70
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:34 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.