I've tried to connect to a SOAP API from a iOS application in objective c, xcode. First, i used a wsdl2objc to produce endpoint stubs for the access, but i got response status code 500 like this:
{ URL: http://api.tradera.com/v3/PublicService.asmx } { status code: 500, headers { "Cache-Control" = private; "Content-Length" = 509; "Content-Type" = "application/soap+xml; charset=utf-8"; Date = "Thu, 24 Mar 2016 17:36:24 GMT"; Server = "Microsoft-IIS/7.5"; "X-AspNet-Version" = "4.0.30319"; "X-Powered-By" = "ASP.NET"; } }
Now i have written my own SOAP request and that gives the same response. Is it the server's or my fault?
THIS is how i do it:
NSURL* url = [NSURL URLWithString:@"http://api.tradera.com/v3/PublicService.asmx"];
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url];
NSString* messageLength = [NSString stringWithFormat:@"%d",soapMessage.length];
[request addValue:@"api.tradera.com" forHTTPHeaderField:@"Host"];
[request addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[request addValue:messageLength forHTTPHeaderField:@"Content-Length"];
[request addValue:@"http://api.tradera.com/GetSearchResultAdvanced" forHTTPHeaderField:@"SOAPAction"];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSURLResponse* response;
NSError* error;
NSData* data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
if ([((NSHTTPURLResponse*)response) statusCode] != 200) {
[ErrorService alertResponseFault:((NSHTTPURLResponse*)response)];
}