<%@ Page Language="VB" AutoEventWireup="false" CodeFile="CustomerWebServiceTest.aspx.vb" Inherits="CustomerWebServiceTest" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Test ASMX Web Service</title>
</head>
< <body>
<h2>Test Customer ASMX Web Service</h2>
<form id="frmCustServer" runat="server">
<div>
<table>
<tr>
<td colspan="2"><b>Through Server Side Web Service Reference</b></td>
</tr>
<tr>
<td >Customer ID :</td>
<td><asp:TextBox ID="txtCustID" runat="server" Text="12345"></asp:TextBox></td>
</tr>
<tr>
<td>Customer Name :</td>
<td>
<asp:TextBox ID="txtCustName" runat="server" Text="Joe Smith"></asp:TextBox>
</td>
</tr>
<tr>
<td>Customer DOB (yyyy-mm-dd):</td>
<td><asp:TextBox ID="txtCustDOB" runat="server" Text="1980-08-08"></asp:TextBox></td>
</tr>
<tr>
<td>Customer Address:</td>
<td><asp:TextBox ID="txtCustAddress" runat="server" Text="unknown"></asp:TextBox></td>
</tr>
<tr>
<td><asp:Button ID="btnGetCustomer" runat="server" Text="Get Customer" /></td>
<td><asp:Button ID="btnAddCustomer" runat="server" Text="Add Customer" /></td>
</tr>
<tr>
<td> <asp:Button ID="btnUpdateCustomer" runat="server" Text="Update Customer" /></td>
<td><asp:Button ID="btnDeleteCustomer" runat="server" Text="Delete Customer" /></td>
</tr>
<tr>
<td>
<asp:Button id="btnGetCustomers" runat="server" Text="Get All Customers"/></td>
<td><asp:Label ID="lblStatus" runat="server" Text="Status"
ForeColor="#CC3300" style="font-weight: 700"></asp:Label></td>
</tr>
</table>
</div>
</form>
<br />
<form id="frmCustomerS" method="post" action="CustomerWebServiceTest.aspx">
<div>
<table>
<tr><td colspan="2"><b>Through Client Side SOAP/XML HTTP POST</b></td></tr>
<tr><td>Customer ID :</td><td><input name="ID" id="ID" type="text" value="12345" /> </td></tr>
<tr><td>Customer Name :</td><td><input name="Name" id="Name" type="text" value="Chris Clark" /> </td></tr>
<tr><td>Customer DOB (yyyy-mm-dd):</td><td><input name="DOB" id="DOB" type="text" value="1980-08-08"/> </td></tr>
<tr><td>Customer Address:</td><td><input name="Address" id="Address" type="text" value="unknown"/> </td></tr>
<tr>
<td><input type="button" name="btnGetCustomer" value="Get Customer" onclick="GetCustomerSOAP()" /></td>
<td><input type="button" name="btnAddCustomer" value="Add Customer" onclick="AddCustomerSOAP()" /></td>
</tr>
<tr>
<td><input type="button" name="btnUpdateCustomerS" value="Update Customer" onclick="UpdateCustomerSOAP()" /></td>
<td><input type="button" name="btnDeleteCustomerS" value="Delete Customer" onclick="DeleteCustomerSOAP()"/></td>
</tr>
<tr>
<td colspan="2"><input type="button" name="btnGetCustomersS" value="Get All Customers" onclick="GetCustomersSOAP()"/></td>
</tr>
</table>
</div>
</form>
<br />
<form id="frmCustomerPost" method="post" action="http://vishwa/examplewebservice/customerwebservice.asmx/GetCustomer">
<div>
<table>
<tr><td colspan="2"><b>Through Client Side HTML Form HTTP POST</b></td></tr>
<tr><td>Customer ID :</td><td><input name="ID" type="text" value="969225896" /> </td></tr>
<tr>
<td colspan="2"><input type="submit" name="btnGetAllCustomers" value="Get Customer"/></td>
</tr>
</table>
</div>
</form>
<form id="frmCustomerGet" method="get" action="http://vishwa/examplewebservice/customerwebservice.asmx/GetCustomer">
<div>
<table>
<tr><td colspan="2"><b>Through Client Side HTML Form HTTP GET</b></td></tr>
<tr><td>Customer ID :</td><td><input name="ID" type="text" value="969225896" /> </td></tr>
<tr>
<td colspan="2"><input type="submit" name="btnGetAllCustomers" value="Get Customer"/></td>
</tr>
</table>
</div>
</form>
<script type="text/javascript" language="javascript">
var urlToPost = "http://vishwa/examplewebservice/customerwebservice.asmx";
var fixedSoapAction = "http://webservices.vishwamohan.net/";
var serviceNameSpace = "\"http://webservices.vishwamohan.net\"";
var d = new Date();
function getFullDate()
{
if (d.getDate()<10)
return "0" + d.getDate();
else
return d.getDate();
}
function getFullMonth()
{
if (d.getMonth()<10)
return "0" + parseInt(d.getMonth()+1);
else
return parseInt(d.getMonth()+1);
}
var curdate = d.getFullYear() + "-" + getFullMonth()+ "-" + getFullDate();
function GetCustomerSOAP()
{
var dataText = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"";
dataText = dataText + " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">";
dataText = dataText + " <soap:Body><GetCustomer xmlns=" + serviceNameSpace + ">";
dataText += " <ID>" + frmCustomerS.ID.value + "</ID>";
dataText += " </GetCustomer>";
dataText += " </soap:Body></soap:Envelope>";
alert(dataText);
var xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlHttp.open("POST", urlToPost,false);
xmlHttp.setRequestHeader("Content-Type", "text/xml");
xmlHttp.setRequestHeader("SOAPAction", fixedSoapAction +"GetCustomer");
xmlHttp.send(dataText);
alert(xmlHttp.responseText);
}
function GetCustomersSOAP()
{
var dataText = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"";
dataText = dataText + " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">";
dataText = dataText + " <soap:Body><GetCustomers xmlns=" + serviceNameSpace + ">";
dataText += " </GetCustomers>";
dataText += " </soap:Body></soap:Envelope>";
alert(dataText);
var xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlHttp.open("POST", urlToPost,false);
xmlHttp.setRequestHeader("Content-Type", "text/xml");
xmlHttp.setRequestHeader("SOAPAction", fixedSoapAction +"GetCustomers");
xmlHttp.send(dataText);
alert(xmlHttp.responseText);
}
function AddCustomerSOAP()
{
var dataText = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"";
dataText += " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">";
dataText += " <soap:Body><AddCustomer xmlns=" + serviceNameSpace + "> <CustomerRecord>";
dataText += " <ID>0</ID><Name>" + frmCustomerS.Name.value + "</Name><DOB>" + frmCustomerS.DOB.value +"</DOB>" ;
dataText += " <Address>" + frmCustomerS.Address.value + "</Address>";
dataText += " <DateCreated>" + curdate + "</DateCreated><DateModified>" + curdate + "</DateModified>" ;
dataText += " </CustomerRecord></AddCustomer>"
dataText += " </soap:Body></soap:Envelope>";
alert(dataText);
var xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlHttp.open("POST", urlToPost,false);
xmlHttp.setRequestHeader("Content-Type", "text/xml");
xmlHttp.setRequestHeader("SOAPAction", fixedSoapAction +"AddCustomer");
xmlHttp.send(dataText);
alert(xmlHttp.responseText);
}
function UpdateCustomerSOAP()
{
var dataText = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"";
dataText += " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">";
dataText += " <soap:Body><UpdateCustomer xmlns=" + serviceNameSpace + "> <CustomerRecord>";
dataText += " <ID>" + frmCustomerS.ID.value + "</ID><Name>" + frmCustomerS.Name.value + "</Name><DOB>" + frmCustomerS.DOB.value +"</DOB>" ;
dataText += " <Address>" + frmCustomerS.Address.value + "</Address>";
dataText += " <DateCreated>" + curdate + "</DateCreated><DateModified>" + curdate + "</DateModified>" ;
dataText += " </CustomerRecord></UpdateCustomer>"
dataText += " </soap:Body></soap:Envelope>";
alert(dataText);
var xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlHttp.open("POST", urlToPost,false);
xmlHttp.setRequestHeader("Content-Type", "text/xml");
xmlHttp.setRequestHeader("SOAPAction", fixedSoapAction +"UpdateCustomer");
xmlHttp.send(dataText);
alert(xmlHttp.responseText);
}
function DeleteCustomerSOAP()
{
var dataText = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"";
dataText = dataText + " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">";
dataText = dataText + " <soap:Body><DeleteCustomer xmlns=" + serviceNameSpace + ">";
dataText += " <ID>" + frmCustomerS.ID.value + "</ID>";
dataText += " </DeleteCustomer>";
dataText += " </soap:Body></soap:Envelope>";
alert(dataText);
var xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlHttp.open("POST", urlToPost,false);
xmlHttp.setRequestHeader("Content-Type", "text/xml");
xmlHttp.setRequestHeader("SOAPAction", fixedSoapAction +"DeleteCustomer");
xmlHttp.send(dataText);
alert(xmlHttp.responseText);
}
</script>
</body>
</html>