Как вы можете использовать AFNetworking или STHTTPRequest для запроса веб-службы SOAP?

Я могу использоватьNSMutableURLRequest сNSURLConnection подключиться к веб-службе SOAP следующим образом:

NSString *soapMessage = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
                         "<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/\">"
                         "<soap:Body>"
                         "<CelsiusToFahrenheit xmlns=\"http://www.w3schools.com/webservices/\">"
                         "<Celsius>140.0</Celsius>"
                         "</CelsiusToFahrenheit>"
                         "</soap:Body>"
                         "</soap:Envelope>"];

NSData *soapData = [soapMessage dataUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString:@"http://w3schools.com/webservices/tempconvert.asmx"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%lu", (unsigned long)[soapMessage length]];

[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"http://www.w3schools.com/webservices/CelsiusToFahrenheit" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue:@"www.w3schools.com" forHTTPHeaderField:@"Host"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:soapData];

Как я мог сделать то же самое, используяAFNetworking или жеSTHTTPRequest?

Ответы на вопрос(1)

Ваш ответ на вопрос