<?vsp 
--  
--  $Id$
--  
--  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
--  project.
--  
--  Copyright (C) 1998-2012 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, sym varchar;
   r := '';
   if ({?'exec'} = 'Get data')
   {
     -- 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;
   if (not exists (select 1 from HTTP_PATH where HP_LPATH = '/xml-soap'))
     {
       r := 'get_NasdaqQuotes service hasn''t been initialized properly, please click on the "set initial state" link before running this demo.';
       goto endf;
     }
     declare exit handler for sqlstate '*' { r := 'Invalid SOAP Service Response:' || __SQL_MESSAGE; goto endf; };
   {
     result := soap_call (sprintf ('localhost:%s', server_http_port ()), '/xml-soap/so_s_7_server.vsp', null, 'get_NasdaqQuotes', params, 11);
   }
   declare exit handler for sqlstate '*' { r := '** no result returned **'; goto endf; };
   {
     r := result[1][1];
     http (r);
     http_xslt (TUTORIAL_XSL_DIR () || '/tutorial/services/so_s_7/sr.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');
  sym := get_keyword ('symbol', params, 'MSFT,ORCL');
?>
<form method="post" action="so_s_7_client.vsp" name="mform">
<input type="hidden" name="url" value="http://quotes.nasdaq.com/quote.dll?page=xml&mode=stock&symbol=">
<table class="tableentry">
<tr><td>1. Enter a symbol to get the stock quotes report</td><td>
<input type="text" name="symbol" size="15" value="<?=sym?>" />
</td></tr>
<tr><td>2. Call the get_NasdaqQuotes</td><td><input type="submit" name="exec" value="Get data"></td></tr>
</table>
</form>

</body>
</html>

