最近2018中文字幕在日韩欧美国产成人片_国产日韩精品一区二区在线_在线观看成年美女黄网色视频_国产精品一区三区五区_国产精彩刺激乱对白_看黄色黄大色黄片免费_人人超碰自拍cao_国产高清av在线_亚洲精品电影av_日韩美女尤物视频网站

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
如何獲取WebService的請求信息-創(chuàng)新互聯(lián)

本篇文章為大家展示了如何獲取WebService的請求信息,內(nèi)容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。

創(chuàng)新互聯(lián)成立與2013年,先為硯山等服務(wù)建站,硯山等地企業(yè),進行企業(yè)商務(wù)咨詢服務(wù)。為硯山企業(yè)網(wǎng)站制作PC+手機+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。

首先想到的是在每一個帶有WebMethod特性的方法里調(diào)用記錄請求信息的方法,這樣可以記錄信息,但是太多帶WebMethod特性的方法了,于是想在全局中攔截并捕獲,于是想到了Global.asax


public class Global : System.Web.HttpApplication
 {

  protected void Application_Start(object sender, EventArgs e)
  {

  }

  protected void Session_Start(object sender, EventArgs e)
  {

  }

  protected void Application_BeginRequest(object sender, EventArgs e)
  {
   if (Request != null)
   {
    try
    {
     if (".asmx".Equals(Request.CurrentExecutionFilePathExtension,StringComparison.OrdinalIgnoreCase) && Request.ContentLength > 0)
     {
      using (MemoryStream ms = new MemoryStream())
      {
       Request.InputStream.CopyTo(ms);
       ms.Position = 0;
       using (StreamReader reader = new StreamReader(ms))
       {
        LogHelper.Info(reader.ReadToEnd());
       }
      }
      
     }
     
    }
    catch (Exception)
    {
    }
    finally
    {
     Request.InputStream.Position = 0;
    }
   }
  }

  protected void Application_AuthenticateRequest(object sender, EventArgs e)
  {

  }

  protected void Application_Error(object sender, EventArgs e)
  {

  }

  protected void Session_End(object sender, EventArgs e)
  {

  }

  protected void Application_End(object sender, EventArgs e)
  {

  }
 }
[WebMethod]
public string HelloWorld()
{
 return "Hello World";
}
[WebMethod]
public string QueryBalance(string username,string password)
{
 if (username == "test" && password == "abcd")
 {
  return "1000000";
 }
 else
 {
  return "用戶名或密碼錯誤";
 }
}

這里使用了Log4Net將請求信息記錄起來

如何獲取WebService的請求信息

如何獲取WebService的請求信息

如何獲取WebService的請求信息

如何獲取WebService的請求信息

另一種調(diào)用方式是在另一個項目中添加了WerService的引用,

public partial class WebForm1 : System.Web.UI.Page
 {
  protected void Page_Load(object sender, EventArgs e)
  {
   TestWebServiceSoapClient client = new TestWebServiceSoapClient();
   Response.Write(client.QueryBalance("test","abcd"));
  }
 }

上述內(nèi)容就是如何獲取WebService的請求信息,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。


文章名稱:如何獲取WebService的請求信息-創(chuàng)新互聯(lián)
分享地址:http://fisionsoft.com.cn/article/hisis.html