The previous article introduced some basic features of webservice and the structure of our example. This article will begin with the specific coding work.
This topic focuses on webservice. Therefore, our code here focuses on Webservice, while other projects, such as ServiceGatherSite and WebSiteA, will only be briefly introduced.
It is not difficult to develop a webservice in VS2003. First, create a webservice project (File-> New-> project-> C #-> Web service application)
After this project is created, we will see a file named Service1.asmx, which is the standard file of webservice. It also has the UI concept, but we generally do not pay attention to it. Therefore, we can view its cs code file. if you haven't done anything yet, you will see a commented-out helloworld WebMethod, remove the annotation, and run it to get the simplest webservice running instance. click "helloworld" to execute the method. obviously, this function only means to understand the web service writing method at a macro level.
Next, we will introduce the webservice method in detail. in the code file, if we want this function to become an externally callable interface function after writing a function, we must add a line of code [WebMethod (Description = "function Description")] to the function. If your function does not have this declaration, it cannot be referenced by users. for example:
[WebMethod (Description = "Simplest method")]
Public string HelloWorld ()
{
Return "Hello World ";
}
This function is an externally callable interface function, which is equivalent to an API for users. if a user calls the HelloWorld () method after referencing this service, he will get the return value "HelloWorld.
We can see whether we have found that webservice is not so mysterious. It is just an interface. For us, the focus is on writing interface functions. below, I will provide the interface functions required for our example.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service