日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

WCF 第十三章 可编程站点 使用WebGet和WebInvoke

發布時間:2024/10/8 编程问答 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 WCF 第十三章 可编程站点 使用WebGet和WebInvoke 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

服務可以使用WebHttpBinding以及WebGet或者WebInvoke屬性來暴露。這些屬性每一個都確定HTTP動作、消息格式以及需要暴露給一個操作的消息體形式。我們將檢查這些屬性的每一個并給出使用每個的原因。

WebGet

WebGet屬性使用GET動詞暴露操作。GET相對于其他HTTP動作有重要的優勢。首先,通過在一個瀏覽器地址欄中輸入服務URI可以直接地訪問終結點。參數可以作為查詢字符串或者編碼字符串在URI中發送。其次,客戶端以及其他下游系統比如代理服務器可以很容易地基于緩存策略來為服務緩存資源。由于緩存能力,WebGet屬性應該只用來做收集用。

? 列表13.6 顯示了使用WebGet和WebInvoke屬性定義的一個服務。WebGet屬性用來收集客戶信息。WebInvoke屬性被用于那些修改數據的添加或者刪除客戶信息的操作。最后,在WebGet和WebInvoke屬性上定義UriTemplate屬性來使用URI定義一個自定義資源。

列表13.6 CustomerService

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ServiceModel; using System.ServiceModel.Web;namespace EssentialWCF {[ServiceContract]public class CustomerService{[OperationContract][WebGet(UriTemplate = "/customer/{id}")]public Customer GetCustomer(int id){Customer customer = null;//Get customer from databasereturn customer;}[OperationContract][WebInvoke(Method="PUT", UriTemplate="/customer/{id}")]public void PutCustomer(int id, Customer customer){//Put customer in database}[OperationContract][WebInvoke(Method="Delete", UriTemplate="/customer/{id}")]public void DeleteCustomer(int id){//Put customer in database}} }

轉載于:https://www.cnblogs.com/danielWise/archive/2011/06/07/2073999.html

總結

以上是生活随笔為你收集整理的WCF 第十三章 可编程站点 使用WebGet和WebInvoke的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。