HttpLib - 簡化C#調用Web Service的類庫
HttpLib使得更容易地異步使用C#Web服務的數據。該類庫包含了上傳文件到服務器,得到網頁的方法。
該項目是設計專為調用現有的Web服務。如果你打算寫一個新的HTTP客戶端/服務器應用程序,我們建議您使用WCF。
支持的方法
- GET
- POST
- Form Encoded
- Multipart File Upload </ul> </li>
- PUT
- HEAD
- DELETE </ul>
從web service獲取數據
Request.get("http://google.com/", (result)=> { Console.Write(result); });
Post 數據至web service
Request.post("http://testing.local/post.php", new {name="james",username="Redslide"}, (result)=> { Console.Write(result); });
Post 數據至web service 并 catch error
Request.post("http://testing.local/post.php", new { name = "value"}, (result)=> { Console.Write(result); }, (e)=> { Console.Write(e.ToString()); });
上傳文件至服務器
Request.upload("http://testing.local/post.php", new {name = "value"}, new NamedFileStream[] { new NamedFileStream("file", "photo.jpg", "image/jpeg", @"C:\photo.jpg") }, (result)=> { Console.Write(result); });
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!