0
NSString *urlString = [NSString 

    stringWithFormat:@"http://192.168.1.15/abc/service.asmx?op=GetCenter"];

        NSURL *url = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

        NSData *data = [[NSData alloc] initWithContentsOfURL:url];

        NSError *error;

        NSMutableArray *json =[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];



        NSLog(@"%@",[json description]);

I have try this but it returns null value insted of call function.

Program ended with exit code: 9(lldb) 

How to recognized if webserive is called or not or how call that function?

6
  • Is the app automatically dying, or you're killing it? What is the error returned to you? Commented Feb 23, 2016 at 12:51
  • exit code suggests that your application is killed Commented Feb 23, 2016 at 12:52
  • @SmitSaraiya you had not request the data of that url. You need to Use NSURLRequest Commented Feb 23, 2016 at 13:17
  • stackoverflow.com/questions/9966614/… Commented Feb 23, 2016 at 13:42
  • or if you want to make third party AFNetworking Library then stackoverflow.com/questions/22851646/… Commented Feb 23, 2016 at 13:43

1 Answer 1

1

If you could provide a bit more information as to what you mean by the function is not called, that would be very helpful, is there any stack trace or other information shown when it crashes?

I would troubleshoot this by stepping through each line of code in the debugger to make sure you are getting data back and then as suggested to print out the error from the serialization function.

It also might be worth using these methods:

NSString* newStr = [NSString stringWithContentsOfURL:url encoding: NSUTF8StringEncoding error:&error];

or

NSString* newStr = [[NSString alloc] initWithData:theData encoding:NSUTF8StringEncoding];

to get a string from your URL or data once you have downloaded it and then print out or view the contents.

Longer term you might want to think about using something like AFNetworking to do your networking calls as what you have is synchronous and ideally, you should be doing all networking asynchronously.

Sign up to request clarification or add additional context in comments.

2 Comments

First way you have suggested is works but i am not able to call specific function of web service, I can successfully call webservice but not its function.
I am just trying to call function which is contain simple select statement, means no parameter passing but i can't.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.