-
大小: 3KB文件類型: .cs金幣: 1下載: 4 次發(fā)布日期: 2021-06-02
- 語言: C#
- 標(biāo)簽: post??json??http??webservice??
資源簡介
C#開發(fā)webservice接口,對(duì)客戶端post服務(wù)的Json數(shù)據(jù)進(jìn)行接收反饋
接收到的數(shù)據(jù)流轉(zhuǎn)換成string類型,有其他需求對(duì)json解析,自己寫個(gè)解析去查詢下. 然后反饋json發(fā)送給請(qǐng)求端。
代碼片段和文件信息
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]//不加這句的話當(dāng).ajax()請(qǐng)求服務(wù)時(shí)會(huì)有異常:
public?class?WebService?:?System.Web.Services.WebService
{
????public?WebService()
????{
????????//如果使用設(shè)計(jì)的組件,請(qǐng)取消注釋以下行?
????????//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的值
????????
評(píng)論
共有 條評(píng)論