登入

平台服務資訊

服務註冊數:80
服務引用數:288

服務狀態

上線服務:66
離線服務:14

服務開發範例

說明

範例程式下載

服務開發範例提供水利署內部同仁及委辦計畫廠商能夠進一步瞭解如何撰寫符合WRISP平台規範的服務, 為了加速服務開發,針對比較複雜的訊息交換處理單元,已封裝成為元件提供給開發人員來使用, 開發人員僅需要專注在資料處理及演算法的程式撰寫, 大幅降低開發 WRISP 服務的門檻


開發環境

目前提供的開發元件,必需在以下的開發環境下使用:

  • Microsoft Visual Sutdio 2005/2008
  • WSE 3.0

  • 元件引用

    開發人員可以由 WRISP 平台上下載 [WRISP服務開發套件],在套件中包含了 GISFCU.WRISP.WebService.DLL 及 GISFCU.RD.Cool.SystemInfoLib, 在服務開發過程中必需將此元件引用到專案當中


    Namespace命名

    WRISP服務的Namesapce必需命名為:http://wrisp.wra.gov.tw


    服務政策

    WRISP 2.0平台支援WS-Secuirty及WS-Trust安全協定,如果服務需要套用安全協定時,必需在 Policy 中做定義

  • NoSecurityServerPolicy:不加入安全協定
  • ServerPolicy:加入安全協定(使用UsernameToken)
  • CertPolicy:加入安全協定(使用憑證)

  • 範例程式

    1 2 using System; 3 using System.Text; 4 using System.Web; 5 6 //****必要引用**** 7 using System.Web.Services; 8 using System.Web.Services.Protocols; 9 using Microsoft.Web.Services3; 10 using GISFCU.WRISP.WebService; 11 using GISFCU.WRISP.WebService.SecurityAssertion; 12 using GISFCU.RD.Cool.SystemInfoLib; 13 14 15 [WebService(Namespace = "http://wrisp.wra.gov.tw/")] 16 [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 17 [Policy(typeof(NoSecurityServerPolicy))] 18 public class Service : System.Web.Services.WebService 19 { 20 public Service () { 21 } 22 23 [WebMethod(Description = "服務自我測試函式")] 24 public string requestTest(string requestXml) 25 { 26 //服務提供主機負荷資訊,使平台掌握服務主機的運作狀況 27 string sTotalphysicalmemory = SystemInfo.GetTotalPhsicalMemory().ToString(); 28 string sProcessoTime = SystemInfo.GetProcessoTime().ToString(); 29 string sAvaiableRam = SystemInfo.GetAvailableMemory().ToString(); 30 31 StringBuilder sb = new StringBuilder(); 32 sb.Append("<ISP>"); 33 sb.Append(string.Format("<TotalPhysicalMemory>{0}</TotalPhysicalMemory>",sTotalphysicalmemory)); 34 sb.Append(string.Format("<AvaiableMemory>{0}</AvaiableMemory>", sAvaiableRam)); 35 sb.Append(string.Format("<ProcessorTime>{0}</ProcessorTime>", sProcessoTime)); 36 sb.Append("</ISP>"); 37 38 return sb.ToString(); 39 } 40 41 [WebMethod(Description = "服務詮釋資料函式")] 42 public string requestMetadata() 43 { 44 //服務提供自我描述資料,讓平台及開發人員可以瞭解更多的服務資訊 45 StringBuilder sb = new StringBuilder(); 46 sb.Append("<Metadata>"); 47 sb.Append(string.Format("<Provider>{0}</Provider>", "水利署資訊室")); 48 sb.Append(string.Format("<PublishDate>{0}</PublishDate>", "2008/9/17")); 49 sb.Append(string.Format("<ServiceName>{0}</ServiceName>", "服務名稱")); 50 sb.Append("</Metadata>"); 51 52 return sb.ToString(); 53 } 54 55 [WebMethod(Description = "服務RequestSchema")] 56 public string requestSchema() 57 { 58 //定義服務的輸入及輸出的Schema,提供平台及開發人員瞭解服務呼介面 59 60 StringBuilder sb = new StringBuilder(); 61 sb.Append("<WRISPInterface>"); 62 63 sb.Append("<WebMethod>"); 64 sb.Append("<Name>QueryByName</Name>"); 65 sb.Append("<Description>利用姓名查詢</Description>"); 66 67 sb.Append("<Request>"); 68 sb.Append("<Condition name='Org' alais='單位' type='string' />"); 69 sb.Append("<Condition name='Name' alais='姓名' type='string' />"); 70 sb.Append("</Request>"); 71 72 sb.Append("<Response>"); 73 sb.Append("<Fields>"); 74 sb.Append("<Field name='Org' alais='單位' type='string' />"); 75 sb.Append("<Field name='Name' alais='姓名' type='string' />"); 76 sb.Append("</Fields>"); 77 sb.Append("</Response>"); 78 sb.Append("</WebMethod>"); 79 80 sb.Append("</WRISPInterface>"); 81 return sb.ToString(); 82 } 83 84 85 [WebMethod(Description ="服務呼叫函式")] 86 public string requestService(string strI3RequestXML) 87 { 88 //這裡要處理 Reqeust 指定的動作 89 return strI3RequestXML; 90 } 91 92 } 93 94