Skip to main content

Using XML-RPC for Web services: XML-RPC Middleware

Part 2 of Using XML-RPC for Web services

Return to article


Listing 1: PHP Client Code
<![if !supportEmptyParas]> <![endif]>
       1               <?php
       2                    include("xmlrpc/xmlrpc.inc");
       3                    if(! $username == "" ){
       4                       $client = new xmlrpc_client("/RPC2", "marian.daisypark.net", "1080");
       5                       $client->setDebug(0);
       6                       $arg_usr = new xmlrpcval($username, "string");
       7                       $arg_pw    = new xmlrpcval($password, "string");
       8                       $msg       = new xmlrpcmsg('authenticate', array($arg_usr, $arg_pw));
       9                       $resp      = $client->send($msg);
      10                            
      11                        if( !$resp ){
      12                                  die("ERROR: couldn't contact the server");
      13                      }
      14                          
      15                      $obj = $resp->value();
      16                    
      17                      if( $obj->scalarval() ){
      18                        header("Location: http://php.daisypark.net/post_login.php"
      19                                           ."?sid=" . $obj->scalarval() );
      20                      }else{
      21                        print "<B><font color='#FF0000'>Login Failed</font></B>";
      22                      }                                        
      23                   }                       
      24              ?>
      25                    
      26              <body Bgcolor="#FFFFFF">
      27              <h1>Welcome to Daisypark</h1>
      28                    
      29              <Form>
      30              <TABLE BGCOLOR="#CCCCCC" CELLSPACING=0 CELLPADDING=0>
      31              <tr>
      32              <td>Username:</td>
      33              <td><Input Name="username"></td>
      34              </tr>
      35              <tr>
      36              <td>Password:</td>
      37              <td><Input type="password" name="password"></tD>
      38              </tr>
      39              <tr>
      40              <td><Input Type="Submit" Value="Login"></TD>
      41              <TD> </td>
      42              </TR>
      43              </Table>
      44              </form>
      45              </body>

Return to article