windows mobile 訪問webservice

來源:互聯網
上載者:User

webservice:

webservice是一種程式介面,提供資料。可以用java,c#等語言開發。同時調用也可以用多種語言。

即C#可以調用java 寫的介面,java也可以調用C#寫的介面,總之就是為了分工,安全,方便。

現在使用C#語言調用一個現成的寫好的webservice。

步驟:

首先,以本地 webservice為例

項目右鍵 添加web引用,瀏覽本地,找到如同http://localhost/EnglishChinese.asmx?wsdl (若是遠程介面,只需要更改此URL即可)

找到後 可以查看裡面的方法,說明webservice沒有問題

然後 記得webservice的 引用名稱 自己可以更改的

最後 就是調用裡面的方法就可以了。

如果是調用別人的介面,人家會將裡面的方法做個說明的,直接調用即可,如下WebReference是引用名,ModuleService是方法。


using System;using System.Linq;using System.Collections.Generic;using System.Text;namespace test001{    class Class1    {        //函數:調用介面,返回xml資料        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            {                return null;            }            finally {               if(data!=null) data = null;               if (errmsg != null) errmsg = null;                            }        }        //函數:上傳資料        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;                                    }                                         }    }}
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.