急要,在线等!
jiezhi(風依舊) 于 2004-11-12 14:18:25
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/webservice/overview.asp
http://www.codeproject.com/cs/webservices/webservicecallback.asp?target=web|service
http://www.cnblogs.com/daview/archive/2004/05/06/8373.aspx
chnama(*****) 于 2004-11-12 16:06:48
http://www.tiantiansoft.com/bbs/dispbbs.asp?boardID=40&ID=62626&page=1
Jeff20040819(最爱Delphi,C#——苦练内功中) 于 2004-11-20 8:09:11
学习 接分
litp(天道酬勤) 于 2004-11-22 17:59:46
以下代码实现了在客户端用java script调用Web Service,通过对Web Service:TimeService中GetTime()方法的调用,在客户端显示服务器当前时间,并且以1秒为间隔自动刷新。
TimeService: GetTime()
//Return time on server
[WebMethod]
public string GetTime()
{
return DateTime.Now.ToString();
}
客户端显示的页面WebForm1:
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
function timer(){
service.useService("http://localhost/TimeWebService/TimeService.asmx?wsdl","TimeService");
service.TimeService.callService(callback,"GetTime");
setTimeout("timer()",1000);
}
function callback(res){
if (!res.error)
time.innerText=res.value
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout" οnlοad="timer()">
<div id="service" style="BEHAVIOR:url(webservice.htc)"></div>
<form id="Form1" method="post" runat="server">
<TABLE id="Table1" style="Z-INDEX: 101; LEFT: 8px; WIDTH: 440px; POSITION: absolute; TOP: 8px; HEIGHT: 50px"
cellSpacing="1" cellPadding="1" width="440" border="0">
<TR>
<TD style="WIDTH: 83px">
<asp:Label id="Label1" runat="server">Current time:</asp:Label></TD>
<TD><span id="time"></span></TD>
</TR>
</TABLE>
</form>
</body>
</HTML>
其中引入一个名为webservice.htc的文件,它包含了使用java script来调用Web Service的两个方法:useService和callService。wbservice.htc可以通过以下地址下载:
http://msdn.microsoft.com/workshop/author/webservice/webservice.htc
其实,web service本质上就是http,xml,所以完全可以自己来实现调用Web Service,有兴趣的话可以参考一下webservice.htc中的_invoke()函数:
var szAction = oM.soapAction;
if (szAction != null && szAction.length > 0)
oXmlHttp.xmlHttp.setRequestHeader("SOAPAction", '"' szAction '"');
oXmlHttp.xmlHttp.setRequestHeader("Content-Type", "text/xml");
var sNS = ' xmlns=""';
for (var ns in oS.ns)
{
var nsuri = oS.ns[ns];
if (ns == "" || nsuri == "")
continue;
sNS = " xmlns:" ns '="' nsuri '"';
}
var szHeader = encodeHeader(oS, oM, oCall);
var szPayload = "<?xml version='1.0'?>/n<SOAP-ENV:Envelope"
(oM.es == null ? '' : (' SOAP-ENV:encodingStyle="' oM.es '"'))
sNS ">/n"
szHeader
'<SOAP-ENV:Body>'
szParams "</SOAP-ENV:Body>/n"
"</SOAP-ENV:Envelope>/n";
if (co.async)
{
oCall.oXmlHttp = oXmlHttp;
oXmlHttp.xmlHttp.onreadystatechange = function() {getResult(oCall);};
try
{
oXmlHttp.xmlHttp.send(szPayload);
}
catch(e)
{
return postError(oCall, 5);
}
return oCall.id;
}
try
{
oXmlHttp.xmlHttp.send(szPayload);
}
catch(e)
{
return returnError(oCall, 5);
}
if (oXmlHttp.xmlHttp.responseXML.parseError.errorCode != 0)
{
_errUnknownS.raw = oXmlHttp.xmlHttp.responseText;
return returnError(oCall, 4);
}
var r;
try
{
r = processResult(oCall, oXmlHttp.xmlHttp.responseXML.documentElement);
}
catch (e)
{
return returnError(oCall, 7);
}
return r;
jiezhi(風依舊) 于 2004-11-12 14:18:25
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/webservice/overview.asp
http://www.codeproject.com/cs/webservices/webservicecallback.asp?target=web|service
http://www.cnblogs.com/daview/archive/2004/05/06/8373.aspx
chnama(*****) 于 2004-11-12 16:06:48
http://www.tiantiansoft.com/bbs/dispbbs.asp?boardID=40&ID=62626&page=1
Jeff20040819(最爱Delphi,C#——苦练内功中) 于 2004-11-20 8:09:11
学习 接分
litp(天道酬勤) 于 2004-11-22 17:59:46
以下代码实现了在客户端用java script调用Web Service,通过对Web Service:TimeService中GetTime()方法的调用,在客户端显示服务器当前时间,并且以1秒为间隔自动刷新。
TimeService: GetTime()
//Return time on server
[WebMethod]
public string GetTime()
{
return DateTime.Now.ToString();
}
客户端显示的页面WebForm1:
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
function timer(){
service.useService("http://localhost/TimeWebService/TimeService.asmx?wsdl","TimeService");
service.TimeService.callService(callback,"GetTime");
setTimeout("timer()",1000);
}
function callback(res){
if (!res.error)
time.innerText=res.value
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout" οnlοad="timer()">
<div id="service" style="BEHAVIOR:url(webservice.htc)"></div>
<form id="Form1" method="post" runat="server">
<TABLE id="Table1" style="Z-INDEX: 101; LEFT: 8px; WIDTH: 440px; POSITION: absolute; TOP: 8px; HEIGHT: 50px"
cellSpacing="1" cellPadding="1" width="440" border="0">
<TR>
<TD style="WIDTH: 83px">
<asp:Label id="Label1" runat="server">Current time:</asp:Label></TD>
<TD><span id="time"></span></TD>
</TR>
</TABLE>
</form>
</body>
</HTML>
其中引入一个名为webservice.htc的文件,它包含了使用java script来调用Web Service的两个方法:useService和callService。wbservice.htc可以通过以下地址下载:
http://msdn.microsoft.com/workshop/author/webservice/webservice.htc
其实,web service本质上就是http,xml,所以完全可以自己来实现调用Web Service,有兴趣的话可以参考一下webservice.htc中的_invoke()函数:
var szAction = oM.soapAction;
if (szAction != null && szAction.length > 0)
oXmlHttp.xmlHttp.setRequestHeader("SOAPAction", '"' szAction '"');
oXmlHttp.xmlHttp.setRequestHeader("Content-Type", "text/xml");
var sNS = ' xmlns=""';
for (var ns in oS.ns)
{
var nsuri = oS.ns[ns];
if (ns == "" || nsuri == "")
continue;
sNS = " xmlns:" ns '="' nsuri '"';
}
var szHeader = encodeHeader(oS, oM, oCall);
var szPayload = "<?xml version='1.0'?>/n<SOAP-ENV:Envelope"
(oM.es == null ? '' : (' SOAP-ENV:encodingStyle="' oM.es '"'))
sNS ">/n"
szHeader
'<SOAP-ENV:Body>'
szParams "</SOAP-ENV:Body>/n"
"</SOAP-ENV:Envelope>/n";
if (co.async)
{
oCall.oXmlHttp = oXmlHttp;
oXmlHttp.xmlHttp.onreadystatechange = function() {getResult(oCall);};
try
{
oXmlHttp.xmlHttp.send(szPayload);
}
catch(e)
{
return postError(oCall, 5);
}
return oCall.id;
}
try
{
oXmlHttp.xmlHttp.send(szPayload);
}
catch(e)
{
return returnError(oCall, 5);
}
if (oXmlHttp.xmlHttp.responseXML.parseError.errorCode != 0)
{
_errUnknownS.raw = oXmlHttp.xmlHttp.responseText;
return returnError(oCall, 4);
}
var r;
try
{
r = processResult(oCall, oXmlHttp.xmlHttp.responseXML.documentElement);
}
catch (e)
{
return returnError(oCall, 7);
}
return r;