File:  [mozdev] / certs / www / test.html
Revision 1.1: download - view: text, annotated - select for diffs - revision graph
Fri Jun 14 05:18:25 2002 UTC (15 years, 6 months ago) by eric
Branches: MAIN
CVS tags: HEAD
no message

<html>
  <body>

    <script>

      const soapVersion  = 0; // Version 1.1
      const object       = "uri:SnakeScore";
      const transportURI = "http://localhost/SnakeService/SnakeService.asmx";

      // SAVE PLAYER SCORE
 
      function SaveScore(PlayerName,Score)
      {
        var method  = "SaveScore";
        var headers = new Array();
        var params  = new Array(new SOAPParameter(PlayerName,"PlayerName"),
                                new SOAPParameter(Score,"Score"));
        var call = new SOAPCall();
        call.transportURI = transportURI;
        call.actionURI = object+"/"+method;

        call.encode(soapVersion,method,object,headers.length,headers,params.length,params);

        //DUMP
        var r = new XMLSerializer().serializeToString(call.message);
        document.getElementById("P").firstChild.nodeValue = r;
        


try{
        //netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
        var currentRequest = call.asyncInvoke(SaveScoreResponse);
} catch(e)
{
alert(e);
}

alert(currentRequest);
      }

      function SaveScoreResponse(resp,call,status)
      {
        alert(resp.body.firstChild.firstChild.firstChild.data);
      }

      // GET PLAYER SCORE

      function GetScore(PlayerName,Score)
      {
        var method  = "GetScore";
        var headers = new Array();
        var params  = new Array(new SOAPParameter(PlayerName,"PlayerName"));
        var call = new SOAPCall();
        call.transportURI = transportURI;
        call.actionURI = object+"/"+method;

        call.encode(soapVersion,method,object,headers.length,headers,params.length,params);

        // DUMP
        var r = new XMLSerializer().serializeToString(call.message);
        document.getElementById("P").firstChild.nodeValue = r;
        //

        netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
        currentRequest = call.asyncInvoke(GetScoreResponse);
      }

      function GetScoreResponse(resp,call,status)
      {
        alert(resp.body.firstChild.firstChild.firstChild.data);
      }

      // GET HIGH SCORES

      function GetHighScores()
      {
        var method  = "GetHighScores";
        var headers = new Array();
        var params  = new Array();
        var call = new SOAPCall();
        call.transportURI = transportURI;
        call.actionURI = object+"/"+method;

        call.encode(soapVersion,method,object,headers.length,headers,params.length,params);

        // DUMP
        var r = new XMLSerializer().serializeToString(call.message);
        document.getElementById("P").firstChild.nodeValue = r;
        //

        netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
        currentRequest = call.asyncInvoke(GetScoreResponse);
      }

      function GetHighScoresResponse(resp,call,status)
      {
        alert(resp.body.firstChild.firstChild.firstChild.data);
      }



      /* Non-working Response code.
        try {
          ret = resp.getParameters(false, new Array());
        }
        catch(e){
          alert(e);
        }
      */

    </script>


     <img alt="SaveScore" onclick="SaveScore('Eric','10');"><br>
     <img alt="GetScore" onclick="GetScore('Eric');"><br>
     <img alt="GetHighScores" onclick="GetHighScores();"><br>


    <p>
     <code id=P>The SOAP call was not encoded.  Look at the Javascript console to determine why.

  </body>
</html>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>