WebService:
WebService is a program interface that provides data. It can be developed in Java, C #, and other languages. At the same time, the call can also be performed in multiple languages.
That is, C # can call the interfaces written in Java, and Java can also call the interfaces written in C #. In short, it is for division of labor, security, and convenience.
Now, we use the C # language to call a ready-made WebService.
Steps:
First, take the local WebService as an example.
Right-click the project to add a web reference, browse the local device, and find http: // localhost/englishchinese. asmx? WSDL (if it is a remote interface, you only need to change this URL)
You can find the method in it, indicating that the WebService is correct.
Remember that the reference name of WebService can be changed by yourself.
The last step is to call the method.
If the interface is called by someone else, someone else will explain the method in it and call it directly. The following webreference is the reference name and moduleservice is the method.
Using system; using system. LINQ; using system. collections. generic; using system. text; namespace test001 {class class1 {// function: Call the interface and return the XML data Public String returndata (int ss) {string data = NULL; string errmsg = NULL; try {using (webreference. moduleservice service = new test001.webreference. moduleservice () {service. questmessage ("dbts", "", SS, "", "", out data, out errmsg); return data ;}} catch {RET Urn NULL;} finally {If (Data! = NULL) Data = NULL; If (errmsg! = NULL) errmsg = NULL ;}// function: Upload data public int uploaddata (string data, string ID) {int flag = 0; string errmsg = NULL; using (webreference. moduleservice service = new test001.webreference. moduleservice () {flag = service. postmessage ("sygl", "", 0, Data, ID, out errmsg); Return flag ;}}}}