<?vsp 
--  
--  $Id$
--  
--  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
--  project.
--  
--  Copyright (C) 1998-2018 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, opl1, opl2, opl_home varchar;
  declare state, msg, st, p0, p1, p2, temp_url varchar;
  declare is_literal integer;
  declare _in, _out, _err any;
  declare meta any;
  declare urls any;

  _caller := {?'caller'};
  _in := {?'in'};
  _out := {?'out'};
  is_literal := 3;
  opl_home := {?'opl_home'};
  p1 := '';
  p2 := 'http://soapinterop/';

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

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

  if (_caller= 'InteropTestRpcEncoded')
    {
       opl1 := concat (opl_home, '/r3/RpcEnc');
       opl2 := concat ('OpenLink Software (', opl1, ')');
       urls := vector (
	       vector (opl1, opl2),
	       vector ('http://mssoapinterop.org/stkv3/wsdl/interopTestRpcEnc.wsdl','Microsoft (http://mssoapinterop.org/stkv3/wsdl/interopTestRpcEnc.wsdl)'),
	       vector ('http://www.soapclient.com/interop/RpcEnc.wsdl','SQLData (http://www.soapclient.com/interop/RpcEnc.wsdl)'),
	       vector ('http://mssoapinterop.org/asmx/wsdl/WSDLInteropTestRpcEncService.asmx','ASP.NET (http://mssoapinterop.org/asmx/wsdl/WSDLInteropTestRpcEncService.wsdl)')
		 );
	is_literal := 2;
       p1 := '"http://soapinterop.org/"';
    }

  _out_str := '';

  if ({?'step'} = '1')
    {
       _soap_url := {?'soap_svc_url'};
       if (_soap_url = '')
         _soap_url := {?'other_uri'};

       p0 := '''inputStruct''';
       if (_caller= 'InteropTestRpcEncoded')
         p0 := 'vector (''param0'', ''http://soapinterop.org/xsd:SOAPStruct'')';

       if (strstr (_soap_url, 'stkv3') > 0 and _caller = 'InteropTestRpcEncoded')
	 {
	   p2 := 'http://soapinterop.org/WSDLInteropTestRpcEnc';
	   p1 := 'http://soapinterop.org/';
	 }

       if (strstr (_soap_url, 'xmlbus') > 0 and _caller = 'InteropTestRpcEncoded')
	 {
	   p2 := 'http://soapinterop.org/WSDLInteropTestRpcEnc';
	   p1 := '""';
	 }

       if (strstr (_soap_url, 'asmx') > 0 and _caller = 'InteropTestRpcEncoded')
	 {
	   p2 := 'http://soapinterop.org/WSDLInteropTestRpcEnc';
	   p1 := '';
	 }

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

          st := sprintf ('select soap_call (''%s'', ''%s'', ''%s'',
	     ''echoStruct'', vector (%s,
	     soap_box_structure (
	     ''varInt'', cast (%s as integer),
	     ''varFloat'', cast (%s as real),
	     ''varString'', ''%s''
	     )),
	  11, NULL, NULL, ''%s'', %i)',
	  _soap_url[1],_soap_url[2], p2, p0, {?'param1'}, {?'param2'}, {?'param3'}, p1, is_literal);
       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];
	    _out_str := _out_str[1];
	 }
       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><H2><B>echoStruct</B> from <?=_caller?></H2>
    <P>This method has a Struct return type and one Struct [in] parameter.<BR>The
       struct consists of an integer value, a float value, and a string value.
    <P>Select the SOAP service endpoint URL you wish to use:<BR />
<TABLE CLASS="tableentry" BORDER="0">
  <TR CLASS="ctrlmain"><TD ALIGN="left">
  <FORM method="POST" action="echoStruct.vsp">
<?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">
       <H3>Enter the input Struct parameter values desired:</H3>
       <P><B>varInt</B> (please enter an <I>integer</I> value)&nbsp;&nbsp;<INPUT value=42 name=param1>
       <P><B>varFloat</B> (please enter a <I>float</I> value)&nbsp;&nbsp;<INPUT value=99.005 name=param2>
       <P><B>varString</B> (please enter a <I>string</I> value)&nbsp;&nbsp;<INPUT value=hello name=param3>
    <P><INPUT type="submit" value="Call">
       <INPUT type="hidden" name="caller" value="<?=_caller?>">
       <INPUT type="hidden" name="opl_home" value="<?=opl_home?>">
       <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><H2>Return value:</H2>
    <TABLE class="tableresult" BORDER="1">
    <TR>
     <TD>
    <P><?=_out_str[1][0][0]?> = <b><?=_out_str[1][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>
