Этот кусок кода работает для меня:
- (IBAction)startSOAP:(id)sender
{
NSLog(@"\n{AppDelegate} startSOAP start");
// create the request
NSError **myError;
NSHTTPURLResponse **serverResponse;
NSData *serverData;
NSDictionary *headerFieldsDict = [NSDictionary
dictionaryWithObjectsAndKeys:@"Apple iPhone",@"User- Agent",
@"text/xml; charset=utf-8", @"Content-Type",
@"soapAction",@"SOAP_ACTION",nil];
@try {
// 1) The Request String.
// Note: smsXMLString contains the entire SMS SOAP envelope, without the <? XML declaration command >.
NSString *smsXMLPath = [[NSBundle mainBundle] pathForResource:@"sms" ofType:@"xml"];
self.smsXMLString = [NSString stringWithContentsOfFile:smsXMLPath encoding:NSUTF8StringEncoding error:myError];
// -----------------------
// 2) Create the request.
NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:theServerURL]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
// -----------------------
// 2a) Modify the Request from default 'GET' to 'POST':
[theRequest setHTTPMethod:@"POST"];
// 2b) Modify the Headers:
[theRequest setAllHTTPHeaderFields:headerFieldsDict];
// 2c) Sent the Contents of the Body to the SOAP/XML data:
[theRequest setHTTPBody:[self.smsXMLString dataUsingEncoding:NSUTF8StringEncoding]];
// -----------------------
// 3) Get Synchronous Data:
serverData = [NSURLConnection sendSynchronousRequest:theRequest
returningResponse:serverResponse
error:myError];
// -----------------------
// 4) Convert Synchronous Data into Human-Readable String (Unicode 8) format:
NSString *serverDataString = [[[NSString alloc] initWithData:serverData encoding:NSUTF8StringEncoding] retain];
[[soapResponse layoutManager]replaceTextStorage:[[NSTextStorage alloc] initWithString:serverDataString]];
[serverDataString release];
}
@catch (id e) {
NSLog(@"\n**** {startSOAP} EXCEPTION: %@ ****\n",e);
self.statusLine.stringValue = [NSString stringWithFormat:@"*** Exception flagged: %@ ***",e];
}
@finally {
NSLog(@"\n{startSoap} end.");
}
}