<?vsp 
--  
--  $Id: echoEmployee.vsp,v 1.3 2008/04/11 09:09:57 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 _caller, _out_str, _soap_url, _err2, p0, opl1, opl2, opl_home varchar;
  declare state, msg, st, temp_url varchar;
  declare _in, _out, _err any;
  declare meta any;
  declare urls any;

  _caller := {?'caller'};
  _in := {?'in'};
  _out := {?'out'};
  opl_home := {?'opl_home'};

  if (_caller= 'Compound2')
    {
       opl1 := concat (opl_home, '/r3/Compound2');
       opl2 := concat ('OpenLink Software (', opl1, ')');
       urls := vector (
	       vector (opl1, opl2),
	       vector ('http://mssoapinterop.org/stkv3/wsdl/Compound2.wsdl', 'Microsoft (http://mssoapinterop.org/stkv3/wsdl/Compound2.wsdl)'),
	       vector ('http://www.soapclient.com/interop/compound2.wsdl', 'SQLData (http://www.soapclient.com/interop/compound2.wsdl)'),
	       vector ('http://mssoapinterop.org/asmx/wsdl/compound2.asmx', 'ASP.NET (http://mssoapinterop.org/asmx/wsdl/compound2.wsdl)')
		 );
    }

  _out_str := '';
  p0 := '"http://soapinterop.org/"';

  if ({?'step'} = '1')
    {
       declare t_pol integer;

       if ({?'IsMale'} = 'on')
	 t_pol := 1;
       else
	 t_pol := 0;

       _soap_url := {?'soap_svc_url'};
       if (_soap_url = '')
         _soap_url := {?'other_uri'};
       if (strstr (_soap_url, 'stkv3') > 0 or (strstr (_soap_url, 'asmx') > 0) or (strstr (_soap_url, 'xmlbus') > 0))
	  p0 := '"#echoEmployee"';

       temp_url := _soap_url;
       _soap_url := WS.WS.PARSE_URI (_soap_url);

          st := sprintf ('
	    select soap_call (''%s'', ''%s'', ''http://soapinterop/'', ''echoEmployee'',
	     vector ( vector (''x'', ''http://soapinterop.org/employee:x_Employee''),
	     soap_box_structure (
	     ''person'',
	     soap_box_structure (
	     ''Name'', ''%s'',
	     ''Male'', soap_boolean (%i)
	     ),
	     ''salary'', cast (''%s'' as double precision),
	     ''ID'', %s
	     )),
	  11, NULL, NULL, ''%s'', 3)',
	  _soap_url[1],_soap_url[2], {?'Name'}, t_pol, {?'Salary'}, {?'IDNbr'}, p0);
       state := '00000';
       exec (st, state, msg, vector (), 1000, meta, _out_str);

       if (state = '00000')
	 {
	    _out_str := _out_str[0];
	    _out_str := _out_str[0];
	    _in := _out_str[1];
	    _out := _out_str[2];
	    _err := _out_str[3];
	    if (_err <> 0) goto next;
	    _out_str := _out_str[0];
	 }
       else
	 {
           _err2 := 'Yes';
           _out_str := 'Error (see error message)';
	   _in := msg;
	 }
    }
next:
?>
<HTML>
  <HEAD>
    <TITLE><?=_caller?> Test</TITLE>
    <LINK rel="stylesheet" type="text/css" href="../demo.css">
    <META http-equiv=Content-Type content="text/html; charset=windows-1252">
    <META name="AUTHOR" content="OpenLink Software">
    <META name="DESCRIPTION" content="<?=_caller?> Test">
  </HEAD>
<BODY>
  <P><H3><B>echoEmployee</B> from <?=_caller?></H3>
    <P>This operation sends and receives a XML document containing a single element of type 'Employee'.
    <P>Select the SOAP service endpoint URL you wish to use:</P><BR />
<TABLE WIDTH="100%" CLASS="tableentry" BORDER="0">
  <TR><TD ALIGN="left">
  <FORM method="POST" action="echoEmployee.vsp">
  <input type="hidden" name="opl_home" value="<?={?'opl_home'}?>">
<?vsp
    declare idx, len integer;
    declare ch varchar;

    idx := 0;
    len := length (urls);

    while (idx < len)
      {
        ch  := '';
	if (temp_url = urls[idx][0] or idx = 0) ch := 'checked';
?>
        <P><INPUT TYPE="radio" name="soap_svc_url" value="<?=urls[idx][0]?>" <?=ch?>><?=urls[idx][1]?>
<?vsp
         idx := idx + 1;
      }
?>
    <P><INPUT TYPE="radio" name="soap_svc_url" value="">Other
    <INPUT size=50 value="" name="other_uri">
	<P>Enter the values for the 'Employee' element:
	<P>Name:&nbsp;&nbsp;<INPUT size=50 value="Jack Benny" name="Name">
	<P>ID number:&nbsp;&nbsp;<INPUT value=42679 name="IDNbr">
	<P>Salary:&nbsp;&nbsp;<INPUT size=10 value=75000.00 name="Salary">
	<P><INPUT type=checkbox name=IsMale>&nbsp;&nbsp;Gender is 'Male'
    <P><INPUT type="submit" value="Call">
       <INPUT type="hidden" name="caller" value="<?=_caller?>">
       <INPUT type="hidden" name="step" value="1">
       </TABLE>

<?vsp  if (_err <> 0)
         {
?>
    	   <H2>Error:</H2>
	   <b><?=_err[2]?></b>
<?vsp
	   goto buff;
	 }
?>

<?vsp  if (_out_str <> '')
         {
	   if (_err2 = 'Yes')
	     {
?>
    <P>Return value:
    <P><?=_out_str?>
<?vsp
	     }
	   else
	     {
?>
    <P>Return value:
    <TABLE border="1" class="tableresult">
    <TR><TD>
    <P><H2><?=_out_str[1][0][0]?></H2>
    <P><?=_out_str[1][1][0][0]?> = <b><?=_out_str[1][1][1]?></b>
    <P><?=_out_str[1][2][0][0]?> = <b><?=_out_str[1][2][1]?></b>
    <P><?=_out_str[2][0][0]?>    = <b><?=_out_str[2][1]?></b>
    <P><?=_out_str[3][0][0]?>    = <b><?=_out_str[3][1]?></b>
<?vsp
	     }
	 }
buff:
       if (_in is not NULL)
         {
?>
    <P>Request message buffer:
    <P><TEXTAREA name=buffer_request rows=15 cols=80><?=_in?></TEXTAREA>
<?vsp    }
       if (_out is not NULL)
         {
?>
    <P>Response message buffer:
    <P><TEXTAREA name=buffer_response rows=15 cols=80><?=_out?></TEXTAREA></P>
<?vsp    }   ?>
  </TD></TR>
</TABLE>
</FORM>
</BODY>
</HTML>
