phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] phpgroupware soap.php, NONE, 1.7.4.1 test_soap.php, N


From: Dan Kuykendall <address@hidden>
Subject: [Phpgroupware-cvs] phpgroupware soap.php, NONE, 1.7.4.1 test_soap.php, NONE, 1.1.2.1
Date: Fri, 07 Nov 2003 09:05:44 +0000

Update of /cvsroot/phpgroupware/phpgroupware
In directory subversions:/tmp/cvs-serv27648

Added Files:
      Tag: proposal-branch
        soap.php test_soap.php 
Log Message:
initial soap interface

--- NEW FILE: soap.php ---
<?php
        
/**************************************************************************\
        * phpGroupWare                                                          
   *
        * http://www.phpgroupware.org                                           
   *
        * This file written by Dan Kuykendall <address@hidden>                 *
        * Copyright (C) 2003 Dan Kuykendall                                     
   *
        * 
-------------------------------------------------------------------------*
        * This library is part of the phpGroupWare API                          
   *
        * http://www.phpgroupware.org/api                                       
   * 
        * 
------------------------------------------------------------------------ *
        * This library is free software; you can redistribute it and/or modify 
it  *
        * under the terms of the GNU Lesser General Public License as published 
by *
        * the Free Software Foundation; either version 2.1 of the License,      
   *
        * or any later version.                                                 
   *
        * This library is distributed in the hope that it will be useful, but   
   *
        * WITHOUT ANY WARRANTY; without even the implied warranty of            
   *
        * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                  
   *
        * See the GNU Lesser General Public License for more details.           
   *
        * You should have received a copy of the GNU Lesser General Public 
License *
        * along with this library; if not, write to the Free Software 
Foundation,  *
        * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA         
   *
        
\**************************************************************************/

        /* $Id: soap.php,v 1.7.4.1 2003/11/07 09:05:42 seek3r Exp $ */

        $GLOBALS['phpgw_interface'] = 'soap';
/*
$GLOBALS['HTTP_RAW_POST_DATA'] = '<?xml version="1.0" ?> 
 <SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/";
xmlns:si="http://soapinterop.org/xsd"; xmlns:ns6="http://testuri.org";
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";>
 <SOAP-ENV:Body>
 <ns6:wcm.base.start>
  <phpgw_user xsi:type="xsd:string">admin</phpgw_user> 
  <phpgw_pass xsi:type="xsd:string">temppass</phpgw_pass> 
  </ns6:wcm.base.start>
  </SOAP-ENV:Body>
 </SOAP-ENV:Envelope>';
*/      
        $GLOBALS['phpgw_data'] = array();
        require_once('api/starter.inc.php');

--- NEW FILE: test_soap.php ---
<?php
        require('nusoap.php');
/**************************************************************************\
* The first request logs the user in and grabs the sessionid               *
\**************************************************************************/

$site = 'localhost';
$location = '/demo/soap.php';

$params = array('phpgw_user'=>'admin', 'phpgw_pass'=>'temppass');
$method = "api.base.login";

$soapclient = new soapclient('http://'.$site.$location);
$login_result = $soapclient->call($method,$params);
$sid = $soapclient->document;

/**************************************************************************\
* I got the sessionid, so now I just make whatever request I want          *
* The sessionid needs to be the first param I pass.                        *
\**************************************************************************/
$sid = $result->scalar;

$params = array('sid'=>$sid);
$params = array('sid'=>$sid, 'account_id'=>3);
$params = array('sid'=>$sid, 'account_id'=>3, 
'other'=>array('one','two','three'));
$params = array($sid, 'account_id'=>1);
$method = "api.account_mgr.view";

$soapclient = new soapclient('http://'.$site.$location);
$next_result = $soapclient->call($method,$params);

echo '';
print_r($soapclient);
echo '';
?>
<html>
        <body>
        <h1>This examples the xmlrpc support of the new framework</h1>
        The login request
        <hr>
        <pre><?php echo htmlentities($login_request);?></pre>
        <hr>
        The login result gives me the session id to use from now on.
        <hr>
        <pre><?php echo htmlentities($login_result);?></pre>
        <hr>
        Now that I have a valid session to work with, I will make a simple 
request to the api.base.start function and send it some params to make sure Im 
getting the results properly.<br>
        Notice that the first param I must pass is the sessionid.
        <hr>
        <pre><?php echo htmlentities($next_request);?></pre>
        <hr>
        Here are the final results!.
        <hr>
        <pre><?php echo htmlentities($next_result);?></pre>
        <hr>
        Here is the result after its converted to php vars. I use print_r() to 
display this.
        <hr>
        <?php $result = xmlrpc_decode_request ($result, $method); ?>
        <pre><?php print_r($result); ?></pre>
        <hr>
        </body>
</html>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]