-
大小: 3KB文件類型: .cs金幣: 1下載: 4 次發布日期: 2021-06-02
- 語言: C#
- 標簽: post??json??http??webservice??
資源簡介
C#開發webservice接口,對客戶端post服務的Json數據進行接收反饋
接收到的數據流轉換成string類型,有其他需求對json解析,自己寫個解析去查詢下. 然后反饋json發送給請求端。
代碼片段和文件信息
using?System;
using?System.Collections;
using?System.Web;
using?System.Web.Services;
using?System.Web.Services.Protocols;
using?System.IO;
using?System.Configuration;
using?System.Data;
using?System.Text;
using?System.Data.Common;
using?System.Web.Security;
using?System.Web.script.Services;
using?System.Web.script.Serialization;
using?System.Runtime.InteropServices;
using?System.Threading;
///?
///WebService?的摘要說明
///?
[WebService(Namespace?=?“http://tempuri.org/“)]
[WebServiceBinding(ConformsTo?=?WsiProfiles.BasicProfile1_1)]
[System.Web.script.Services.scriptService]//不加這句的話當.ajax()請求服務時會有異常:
public?class?WebService?:?System.Web.Services.WebService
{
????public?WebService()
????{
????????//如果使用設計的組件,請取消注釋以下行?
????????//InitializeComponent();?
????}
???
????#region?接口說明:“WebService接口“
????[WebMethod(Description?=?“WebService接口“)]
????public?void?WSInterface()
????{
????????string?jsontext?=?string.Empty;
????????string?jsonReturn?=?string.Empty;
????????try
????????{
???????????Stream?s?=?HttpContext.Current.Request.InputStream;//獲得json?字符流,????
???????????string?usr?=?HttpContext.Current.Request.Headers[“key“];//獲得header?下key的值
????????
- 上一篇:unity上傳文件7牛云存儲服務器
- 下一篇:高斯正反算程序窗體程序,附計算
評論
共有 條評論