當(dāng)前位置:工程項(xiàng)目OA系統(tǒng) > 泛普各地 > 河北O(jiān)A系統(tǒng) > 石家莊OA系統(tǒng) > 石家莊OA信息化
Accessing Server Variables From Within Web Services
申請(qǐng)免費(fèi)試用、咨詢電話:400-8352-114
AMTeam.orgAccessing Server Variables From Within Web Services
Manohar Kamath
April 2, 2001
Level: Beginner
One of the most often asked question in newsgroups is "How do I get the IP address of the client browser within a web service?" The answer is very simple. The Context class within the system.web.services namespace represents the context of the web service. In other words, it has reference to various objects from within a running web service -- things like Response, Request and Session objects, and also such information as if the debugging is enabled on the service.
In this article, we will take a look at a very basic example that describes two things
Retrieve the IP address of the client browser
Retrieve
all the web server variables
The source code is self explanatory, and is
not supposed to be an introduction to web services (for such articles, refer to
Web Services. Part I: The Basics).
<%@ Webservice Language="C#" class="httpvars"
%>
using System;
using System.Collections;
using
System.Web.Services;
public class httpvars :
WebService
{
// This method returns the IP
address of the client
[WebMethod]
public String ipAddress
()
{
// The Context object contains reference to Request
object
return
Context.Request.ServerVariables["REMOTE_ADDR"];
}
// This method returns the all the server variables as
HTML
[WebMethod]
public
String allHttpVars ()
{
// Instantiate a collection
that will hold the
//
key-value collection of server
variables
NameValueCollection
serverVars;
String returnValue
= "";
serverVars = Context.Request.ServerVariables;
// Retrieve all the Keys from server variables
collection
// as a string
array
String[] arVars =
serverVars.AllKeys;
// Loop through the keys array and obtain
the
// values corresponding to
the individual keys
for (int x
= 0; x < arVars.Length;
x++)
{
returnValue+= "<b>" + arVars[x] + "</b>:
";
returnValue+= serverVars[arVars[x]] +
"<br>";
}
return
returnValue;
}
}
Demo Code
The second method allHttpVars() returns HTML.- 1石家莊泛普OA軟件管理門戶登錄
- 2知識(shí)經(jīng)濟(jì)時(shí)代的知識(shí)、競爭與制度演化
- 3協(xié)同之惑
- 4出版社行業(yè)如何做好信息化建設(shè)的思考
- 5用SLA保證Web服務(wù)
- 6石家莊OA信息化的基本XML和RDF技術(shù)(四):問題跟蹤程序模式
- 7泛普OA個(gè)性化門戶主要提供了基于用戶的門戶個(gè)性化流程
- 8IBM WebSphere以最快速度部署開放的Web服務(wù)
- 9石家莊OA信息化——信息化的奢侈品?<br><div align=right>——夏敬華專訪&l
- 10OA辦公系統(tǒng)可以幫助企業(yè)擺脫束縛
- 11Web服務(wù)設(shè)計(jì)師,第2部分:動(dòng)態(tài)電子商務(wù)模式
- 12包裝你知道的一切
- 13[編譯] 石家莊OA信息化測(cè)度:目標(biāo)、過程及方法(夏敬華譯)
- 14從九點(diǎn)連線談創(chuàng)新及對(duì)石家莊OA信息化的再思考(by AMT 夏敬華)
- 15[評(píng)論] 比爾.蓋茨論石家莊OA信息化
- 16如何使用Visual Studio .NET和Office XP創(chuàng)建和部署XML Web Service
- 17實(shí)用工具:IT員工的培訓(xùn)補(bǔ)償政策示例
- 18管理結(jié)構(gòu)式Web服務(wù)元數(shù)據(jù)
- 19初探石家莊OA信息化
- 20網(wǎng)絡(luò)服務(wù)熱火如潮 前景撲朔迷離
- 21Ask the DotNetJunkies: Consuming Remote Web Services in ASP.
- 22[原創(chuàng)]OA選擇首先要清晰概念
- 23兩種對(duì)立標(biāo)準(zhǔn)聯(lián)姻 微軟IBM規(guī)范Web服務(wù)
- 24BEA榮獲最佳web服務(wù)產(chǎn)品獎(jiǎng)
- 25如何利用CICADA知識(shí)搜索引擎提升知識(shí)獲取能力
- 26A Web Services Primer
- 27Sun等公布Web服務(wù)協(xié)調(diào)語言“WSCI”
- 28柴油機(jī)故障診斷專家系統(tǒng)知識(shí)庫設(shè)計(jì)
- 29泛普軟件石家莊OA信息化系統(tǒng)實(shí)施9大推進(jìn)步驟
- 30分析家:安全仍是Web服務(wù)普及最大障礙
成都公司:成都市成華區(qū)建設(shè)南路160號(hào)1層9號(hào)
重慶公司:重慶市江北區(qū)紅旗河溝華創(chuàng)商務(wù)大廈18樓
版權(quán)所有:泛普軟件 渝ICP備14008431號(hào)-2 渝公網(wǎng)安備50011202501700號(hào) 咨詢電話:400-8352-114