137 lines
4.0 KiB
JavaScript
137 lines
4.0 KiB
JavaScript
|
|
///////////////////////////////////////////////////////////////////
|
||
|
|
function BeginSumMethod()
|
||
|
|
{
|
||
|
|
//ClearLog();
|
||
|
|
AddLineToLog('----------------------');
|
||
|
|
AddLineToLog('Calling Sum method.');
|
||
|
|
AddToLog('Creating MegaDemoService ...');
|
||
|
|
var service = new MegaDemoService('http://localhost:8099/json')
|
||
|
|
AddLineToLog(' ok.');
|
||
|
|
|
||
|
|
var A = editA.value;
|
||
|
|
var B = editB.value;
|
||
|
|
|
||
|
|
AddLineToLog('Method: Sum; Params: A=' + A + '; B=' + B + ';');
|
||
|
|
AddToLog('Sending request...');
|
||
|
|
service.Sum(A, B, EndSumMethod);
|
||
|
|
AddLineToLog(' ok.');
|
||
|
|
|
||
|
|
AddToLog('Waiting for response... ');
|
||
|
|
}
|
||
|
|
|
||
|
|
function EndSumMethod(result)
|
||
|
|
{
|
||
|
|
AddLineToLog(' ok.');
|
||
|
|
AddLineToLog('Result is ' + result);
|
||
|
|
AddLineToLog('Done.');
|
||
|
|
alert('Result is ' + result);
|
||
|
|
}
|
||
|
|
///////////////////////////////////////////////////////////////////
|
||
|
|
function BeginGetServerTimeMethod()
|
||
|
|
{
|
||
|
|
//ClearLog();
|
||
|
|
AddLineToLog('----------------------');
|
||
|
|
AddLineToLog('Calling Sum method.');
|
||
|
|
AddToLog('Creating MegaDemoService ...');
|
||
|
|
var service = new MegaDemoService('http://localhost:8099/json')
|
||
|
|
AddLineToLog(' ok.');
|
||
|
|
|
||
|
|
AddLineToLog('Method: GetServerTime;');
|
||
|
|
AddToLog('Sending request...');
|
||
|
|
service.GetServerTime(EndGetServerTimeMethod);
|
||
|
|
AddToLog('Waiting for response... ');
|
||
|
|
}
|
||
|
|
|
||
|
|
function EndGetServerTimeMethod(result)
|
||
|
|
{
|
||
|
|
AddLineToLog(' ok.');
|
||
|
|
AddLineToLog('Result is ' + result);
|
||
|
|
AddLineToLog('Done.');
|
||
|
|
alert('Result is ' + result);
|
||
|
|
}
|
||
|
|
///////////////////////////////////////////////////////////////////
|
||
|
|
function BeginEchoPersonMethod()
|
||
|
|
{
|
||
|
|
//ClearLog();
|
||
|
|
AddLineToLog('----------------------');
|
||
|
|
AddLineToLog('Calling EchoPerson method.');
|
||
|
|
AddToLog('Creating MegaDemoService ...');
|
||
|
|
var service = new MegaDemoService('http://localhost:8099/json')
|
||
|
|
AddLineToLog(' ok.');
|
||
|
|
|
||
|
|
var myPerson =
|
||
|
|
{
|
||
|
|
FirstName: editFN.value,
|
||
|
|
LastName: editLN.value,
|
||
|
|
Age: editAg.value,
|
||
|
|
Sex: editSx.value
|
||
|
|
};
|
||
|
|
|
||
|
|
|
||
|
|
AddLineToLog("Method: EchoPerson; Params: Person " + myPerson.FirstName + " " + myPerson.LastName + " " + myPerson.Age + " years old;");
|
||
|
|
AddToLog('Sending request...');
|
||
|
|
service.EchoPerson(myPerson, EndEchoPersonMethod);
|
||
|
|
AddLineToLog(' ok.');
|
||
|
|
|
||
|
|
AddToLog('Waiting for response... ');
|
||
|
|
}
|
||
|
|
|
||
|
|
function EndEchoPersonMethod(result)
|
||
|
|
{
|
||
|
|
AddLineToLog(' ok.');
|
||
|
|
AddLineToLog("Result is: " + result.FirstName + " " + result.LastName + " " + result.Age + " years old.");
|
||
|
|
AddLineToLog('Done.');
|
||
|
|
alert("Result is: " + result.FirstName + " " + result.LastName + " " + result.Age + " years old.");
|
||
|
|
}
|
||
|
|
|
||
|
|
///////////////////////////////////////////////////////////////////
|
||
|
|
function BeginTestPersonArrayMethod()
|
||
|
|
{
|
||
|
|
//ClearLog();
|
||
|
|
AddLineToLog('----------------------');
|
||
|
|
AddLineToLog('Calling EchoPerson method.');
|
||
|
|
AddToLog('Creating MegaDemoService ...');
|
||
|
|
var service = new MegaDemoService('http://localhost:8099/json')
|
||
|
|
AddLineToLog(' ok.');
|
||
|
|
|
||
|
|
var myPersons =
|
||
|
|
[
|
||
|
|
{ FirstName: "John", LastName: "Doe", Age: 33, Sex: "sxMale" },
|
||
|
|
{ FirstName: "Will", LastName: "Smith", Age: 35, Sex: "sxMale" },
|
||
|
|
{ FirstName: "Samanta", LastName: "Carter", Age: 28, Sex: "sxFemale" }
|
||
|
|
];
|
||
|
|
|
||
|
|
var myPersonAsString = YAHOO.lang.JSON.stringify(myPersons, ["FirstName", "LastName"]);
|
||
|
|
AddLineToLog('Method: EchoPerson; Params: Person ' + myPersonAsString + ';');
|
||
|
|
AddToLog('Sending request...');
|
||
|
|
service.TestPersonArray(myPersons, EndTestPersonArrayMethod);
|
||
|
|
AddLineToLog(' ok.');
|
||
|
|
|
||
|
|
AddToLog('Waiting for response... ');
|
||
|
|
}
|
||
|
|
|
||
|
|
function EndTestPersonArrayMethod(result)
|
||
|
|
{
|
||
|
|
AddLineToLog(' ok.');
|
||
|
|
AddLineToLog('Result is ' + result);
|
||
|
|
AddLineToLog('Done.');
|
||
|
|
alert('Result is ' + result);
|
||
|
|
}
|
||
|
|
///////////////////////////////////////////////////////////////////
|
||
|
|
|
||
|
|
function AddToLog(message)
|
||
|
|
{
|
||
|
|
log.value += message;
|
||
|
|
}
|
||
|
|
|
||
|
|
function AddLineToLog(message)
|
||
|
|
{
|
||
|
|
AddToLog(message);
|
||
|
|
log.value += "\n";
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
function ClearLog()
|
||
|
|
{
|
||
|
|
log.value = "";
|
||
|
|
}
|