Wednesday, August 14, 2013

Calling .NET REST web service from iOS using AFNetworking. – Part 1


Today I’m going to talk about how to call a .NET REST web service. Actually, when I stared to develop iphone applications, I had to work with .NET REST web services. At that time I had to face lot of difficulties when calling web services. It was very hard to find a better solution by searching the web at that time. So I thought to tell you how your .Net web service should be and how to call it from iOS. In my next post I’m going to talk about how to upload an image from iOS to .NET REST web service.

Here I’m using AFNetworking to call web service. You can download it from here.

In this example I’m calling a GET method in .NET web service, which returns a string as a result. This method accept the user name, and it returns “#VALID#” if the user is in the main database, if not service will return “#INVALID#”.

This is how your service interface class should look like.



This is how your service.svc file should look like.



In the iOS this is how you should call it. Here I have written my method using blocks so after calling the web service it will notify the caller. 

No comments:

Post a Comment