Quote:
Originally Posted by llama64
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];