View Single Post
Old 05-11-2009, 03:16 PM   #461
kermitology
It's not easy being green!
 
kermitology's Avatar
 
Join Date: Oct 2001
Location: In the tubes to Vancouver Island
Exp:
Default

Quote:
Originally Posted by llama64 View Post
Once you get over it's inane syntax you mean.
Yes.. once you get over that.

Here's how you post a SOAP request.

Code:
	NSURL* exportURL = [NSURL URLWithString:[escapedUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
	NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:exportURL];
	
	[request setHTTPMethod:@"POST"];
	[request setValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
	[request setValue:@"\"http://tempuri.org/GetAvailableProducts\"" forHTTPHeaderField:@"SOAPAction"];
	
	NSMutableString* postData = [NSMutableString stringWithString:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>"];
	[postData appendString:@"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"];
	[postData appendString:@"<soap:Body>"];
	[postData appendString:@"<GetAvailableProducts xmlns=\"http://tempuri.org/\">"];
	[postData appendString:@"</GetAvailableProducts>"];
	[postData appendString:@"</soap:Body>"];
	[postData appendString:@"</soap:Envelope>"];
	
	[request setHTTPBody:[postData dataUsingEncoding:NSUTF8StringEncoding]];
	
	NSString* dataLength = [NSString stringWithFormat:@"%d", [postData length]];
	[request setValue:dataLength forHTTPHeaderField:@"Content-Length"];
	
	[request setTimeoutInterval:20.0];
	
	if( myURLConnection != nil )
	{
		[myURLConnection release];
	}
	
	// released later..
	myURLConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
__________________
Who is in charge of this product and why haven't they been fired yet?
kermitology is offline   Reply With Quote