0

I am consuming a web service from a native app for ios, above the address of the web service was http , and I had to connect to a vpn to consume , to go public we changed the web service server and we have added a protocol security (https ), but now I try to query the web service and the native app returns me null and testing it in the browser if the web Service is consumed and I returned values.

this is the code that i use to consume the web service from objective- c:

 _urlConDatos = [NSString stringWithFormat:@"https://mhwfmobt.aeroman.com.sv:7003/AEPublicWS/webresources/login/%@/%@", _usuarioProp.text, _passProp.text];


jsonURL = [NSURL URLWithString: _urlConDatos];
NSLog(@"%@", jsonURL);
NSError *error;
jsonData = [[NSString alloc] initWithContentsOfURL:jsonURL encoding:NSUTF8StringEncoding error: &error];
NSLog(@"%@", jsonData);
if(jsonData != nil){

NSLog(@"%@", jsonData);
NSData *array = [jsonData dataUsingEncoding: NSUTF8StringEncoding];
NSError *e;
jsonArray = [NSJSONSerialization JSONObjectWithData: array options: 0 error:&e];

_nombreProp = jsonArray[1];
_cod86 = jsonArray[0];
_ISSS = jsonArray[3];
//_permisos = jsonArray[4];

NSLog(@"%@", _permisos);
NSLog(@"%@", jsonArray);

the variable " jsonData " returns me null.

  • For one thing, if your web server is using HTTPS, you need to use that in the URL string. You have http in the _urlConDatos string (if that's not a typo). – Jordan Feb 26 '15 at 17:29
  • Sorry i was wrong, but yes, I had tried with https. for the moment I put http to me the code to work, but I need to also work with https , and I 've tried to address https. Now I modified the URL. – Guillermo Alexander alexvazdro Feb 26 '15 at 17:52
  • Another thing I notice is that there is a `login` path in the URL. Does the web service require authentication? If so, you'll need to build a NSURLConnection and set a delegate to respond to the authentication challenge. – Jordan Feb 26 '15 at 17:57
  • The most obvious question: okay, so "jsonData" is null... but has your "error" variable been set to an error message / any kind of HTTP response code...? When I get these type of problems, I reach for Fiddler, and try to call the web service from there using the same parameters as my iPhone app. – Mike Gledhill Feb 26 '15 at 18:47
  • Check my answer on http://stackoverflow.com/a/32435477/1307433 – cjd Sep 07 '15 at 10:12
  • Possible duplicate of [How to proceed with a service URL which is untrusted?](http://stackoverflow.com/questions/11672541/how-to-proceed-with-a-service-url-which-is-untrusted) – Paul Sweatte Oct 20 '16 at 23:04

0 Answers0