I am using the following code to invoke the http://www.highoncoding.com/Customers.asmx web service.
UPDATE 1:
Now, I have the following code:
-(NSMutableArray *) getAll
{
NSURL *baseURL = [NSURL URLWithString:@"http://highoncoding.com/Customers.asmx?op=GetAll"];
NSString *soapBody = @"<?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> <GetAll xmlns=\"http://tempuri.org/\" /></soap:Body></soap:Envelope>";
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:baseURL];
[request setHTTPBody:[soapBody dataUsingEncoding:NSUTF8StringEncoding]];
[request addValue:@"http://tempuri.org/GetAll" forHTTPHeaderField:@"SOAPAction"];
[request addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[operation start];
But instead of returning XML it returns HTML/CSS.
UPDATE 2:
I was missing the httpMethod line:
[request setHTTPMethod:@"POST"];
You need to set
Content-TypeandSOAPActionas headers. Your SOAP XML string needs to be the post body of the request.I’d recommend constructing this request using SOAPClient, HTTPClient or just raw curl before taking random stabs using AFNetworking.
Compare this raw request to the request being generated by AFNetworking to see where the differences lie using a proxy like Charles.
Update: Here is an example of a raw request that works
And the response: