File: TimeService.asmx
<%@ WebService Language="C#" Class="TimeService" %>
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
[WebService(Namespace = "http://www.java2java.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class TimeService : System.Web.Services.WebService {
[WebMethod]
public DateTime GetServerTime() {
return DateTime.Now;
}
}
File: Default.aspx
<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<form id="form1" runat="server">
<div>
<asp:FormView
id="frmServerTime"
DataSourceID="srcServerTime"
CssClass="serverTime"
Runat="server">
<ItemTemplate>
The remote server date and time is: <%# Container.DataItem %>
</ItemTemplate>
</asp:FormView>
<asp:ObjectDataSource
id="srcServerTime"
TypeName="TimeService"
SelectMethod="GetServerTime"
Runat="server" />
</div>
</form>
</body>
</html>
|