Access WebService on Windows Mobile

Source: Internet
Author: User

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 ;}}}}

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.