Swift call WebService Method demo

Dear Moderators, in this chapter, the remote data is just a static json data, but i have a C# webservice, and i want call the methods in the webservice, would you please show us a demo about that, thank you very much :slight_smile:

The details of how this will work depend on the “API” of your C# web service. For many they will require using a different HTTP method/verb, such as PUT or POST or DELETE. Check out NSMutableURLRequest, which allows you to change the HTTPMethod property. You’ll also need to either set the query parameters (part of the NSURL), or the HTTP body (again with NSMutableURLRequest).

Another approach is to use an open source framework. NSURLSession and NSURLConnection are great, but their interface is very close to the HTTP protocol. It can be nice to use a framework that is at a little higher level, such as https://github.com/Alamofire/Alamofire. These frameworks make common tasks, such as working with a JSON web service, much simpler than using NSURLSession directly.