<?vsp 
--  
--  $Id: so_s_11_array_client.vsp,v 1.3 2006/08/15 19:30:34 source Exp $
--  
--  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
--  project.
--  
--  Copyright (C) 1998-2006 OpenLink Software
--  
--  This project is free software; you can redistribute it and/or modify it
--  under the terms of the GNU General Public License as published by the
--  Free Software Foundation; only version 2 of the License, dated June 1991.
--  
--  This program 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
--  General Public License for more details.
--  
--  You should have received a copy of the GNU General Public License along
--  with this program; if not, write to the Free Software Foundation, Inc.,
--  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--  
--  

   declare result, ses, r, sel, _use_stored, val varchar;
   declare idx, len integer;
   declare _list any;
   r := ''; sel := '';
   -- When hosted in dav we set the 'Content' value to empty, because string_session will crate problems
   declare _params any;
   _params := vector();
   for (declare i int,i:=0;i<length(params);i:=i+2)
     if (params[i] <> 'Content')
       _params := vector_concat(_params,vector(params[i],params[i+1]));
   params := _params;
   _use_stored := {?'use_stored'};
   if (_use_stored is NULL)
     params := vector_concat (params, vector ('use_stored', NULL));
   if (isstring ({?'exec'}))
   {
   declare exit handler for sqlstate '*' { r := __SQL_MESSAGE; goto endf; };
   {
     result := soap_call (sprintf ('localhost:%s', server_http_port ()), '/SOAP_SO_S_11/', null, 'get_Divisions2D', params, 11);
   }
   declare exit handler for sqlstate '*' { r := '** no result returned **'; goto endf; };
   {
     declare x any;
     x := xml_tree_doc(result);
     http_value (x);
     if ({?'exec'} = 'Get data')
       http_xslt (TUTORIAL_XSL_DIR() || '/tutorial/services/so_s_11/sr2d.xsl', params);
     else
       http_xslt (TUTORIAL_XSL_DIR() || '/tutorial/services/so_s_11/raw.xsl', params);
     return 0;
   }
   }
endf:
?>
<html>
<HEAD><link rel="stylesheet" type="text/css" href="../demo.css" /></HEAD>
<body>
<H3>SOAP client</H3>
<?vsp
  if (r <> '')
    http_value (r,'pre');
?>
<form method="post" name="so_s_11_c" action="so_s_11_array_client.vsp">
<table class="tableentry">
<tr><td>1. Use the stored data </td><td><input type="checkbox" <?vsp if (_use_stored = 'on') http ('CHECKED'); ?> name="use_stored" onClick="javascript:document.so_s_11_c.submit();"></td></tr>
<tr><td>2. Select country</td><td>
<input type="hidden" name="province" value="">
<select name="mask">
<?vsp
    _list := vector ();
    if (_use_stored = 'on')
      for select c_name from countries_xml do {_list := vector_concat (_list, vector (c_name));}
    else
      for select c_name from countries do {_list := vector_concat (_list, vector (c_name));}
    len := length (_list);
    idx := 0;
    while (idx < len)
     {
       val := _list[idx];
       if (upper(val) = 'UNITED STATES') sel := 'SELECTED'; else  sel := '';
?>
<option value="<?=val?>" <?=sel?>><?=val?></option>
<?vsp
       idx := idx + 1;
     }
?>
</select>
</td></tr>
<tr><td>3. Call the get_Divisions2D</td><td><input type="submit" name="exec" value="Get data"></td></tr>
<tr><td>3a. Show the SOAP response</td><td><input type="submit" name="exec" value="Show response"></td></tr>
</table>
</form>

</body>
</html>

