<?vsp 
--  
--  $Id: echoString.vsp,v 1.4 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 state, msg, st, p0, p1, p2, p3, p4, opl1, opl2, opl_home varchar;
  declare _caller, _out_str, _soap_url, wsdl_url, is_literal varchar;
  declare position integer;
  declare sch, pt, wsdl any;
  declare _in, _out, _err any;
  declare meta any;
  declare urls any;

  _caller := {?'caller'};
  _in := {?'in'};
  _out := {?'out'};
  wsdl := NULL;
  wsdl_url := NULL;
  is_literal := 3;
  opl_home := {?'opl_home'};
  p3 := 'http://www.w3.org/2001/XMLSchema:string';
  p4 := '';

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

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

  if (_caller= 'InteropTestDocLitParameters')
    {
       opl1 := concat (opl_home, '/r3/DocPars');
       opl2 := concat ('OpenLink Software (', opl1, ')');
       urls := vector (
	       vector (opl1, opl2),
	       vector ('http://mssoapinterop.org/stkv3/wsdl/interopTestDocLitParameters.wsdl','Microsoft (http://mssoapinterop.org/stkv3/wsdl/interopTestDocLitParameters.wsdl)'),
	       vector ('http://www.soapclient.com/interop/DocLitParam.wsdl','SQLData (http://www.soapclient.com/interop/DocLitParam.wsdl)'),
	       vector ('http://mssoapinterop.org/asmx/wsdl/InteropTestDocLitParameters.asmx','ASP.NET (http://mssoapinterop.org/asmx/wsdl/InteropTestDocLitParameters.wsdl)')
		 );
       p0 := 'inputString';
       p1 := 'http://soapinterop/echoString/';
       p2 := '"http://soapinterop.org/"';
       p3 := 'http://soapinterop.org/xsd:echoString';
    }

  if (_caller= 'InteropTestDocLit')
    {
       opl1 := concat (opl_home, '/r3/DocLit');
       opl2 := concat ('OpenLink Software (', opl1, ')');
       urls := vector (
	       vector (opl1, opl2),
	       vector ('http://mssoapinterop.org/stkv3/wsdl/interopTestDocLit.wsdl','Microsoft (http://mssoapinterop.org/stkv3/wsdl/interopTestDocLit.wsdl)'),
	       vector ('http://www.soapclient.com/interop/DocLit.wsdl','SQLData (http://www.soapclient.com/interop/DocLit.wsdl)'),
	       vector ('http://mssoapinterop.org/asmx/wsdl/InteropTestDocLit.asmx','ASP.NET (http://mssoapinterop.org/asmx/wsdl/InteropTestDocLit.wsdl)')
		 );
       p0 := 'inputString';
       p1 := 'http://soapinterop/echoString/';
       p2 := '"http://soapinterop.org/"';
       p3 := 'http://soapinterop.org/xsd:echoStringParam';
    }

  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)')
		 );
       p0 := 'param0';
       p1 := 'http://soapinterop.org/WSDLInteropTestRpcEnc';
       p2 := '';
       p3 := 'string';
       is_literal := 2;
    }


  _out_str := '';

  if ({?'step'} = '1')
    {

       position := cast ({?'soap_svc_url'} as integer);

       if (position = -1)
	 {
            _soap_url := {?'other_uri'};
            wsdl_url := NULL;
	 }
       else
         _soap_url := urls[position][0];

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

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

       if (wsdl_url is not NULL)
	 {
	    DB.DBA.WSDL_EXPAND (wsdl_url, NULL, sch, pt, wsdl);

	    if (p0 is NULL)
	      p0 := cast (xpath_eval ('definitions/portType/operation/@parameterOrder', wsdl, 1) as varchar);
         }

       _soap_url := WS.WS.PARSE_URI (_soap_url);
       if (_caller= 'InteropTestDocLitParameters')
         st := sprintf ('select soap_call (
		 ''%s'', ''%s'', ''%s'',
		 ''echoString'',
		 vector (vector (''%s'', ''%s''), vector (''%s'')),
		 11, NULL, NULL, ''%s'', %i)',
	         _soap_url[1],_soap_url[2], p1, p0, p3, {?'param1'}, p2, is_literal);
         else
         st := sprintf ('select soap_call (
		 ''%s'', ''%s'', ''%s'',
		 ''echoString'',
		 vector (vector (''%s'', ''%s''), ''%s''),
		 11, NULL, NULL, ''%s'', %i)',
	         _soap_url[1],_soap_url[2], p1, p0, p3, {?'param1'}, p2, 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];
            if (is_literal = 2)
	      _out_str := _out_str[1];
	    if (_caller= 'InteropTestDocLitParameters')
	      _out_str := _out_str[1];
	 }
       else
	 {
           _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="echoString <?=_caller?> Test">
  </HEAD>
<BODY>
    <P><H3><B>echoString</B> from <?=_caller?></H3>
    <P>This method has a string return type and one string [in] parameter.
    <P>Select the SOAP service endpoint URL you wish to use:
    <P>
<TABLE WIDTH="100%" CLASS="tableentry" BORDER="0">
   <TR><TD ALIGN="left">
  <FORM method="POST" action="echoString.vsp">
<?vsp
    declare idx, len integer;
    declare ch varchar;

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

    while (idx < len)
      {
        ch  := '';
	if (idx = position) ch := 'checked';
?>
        <P><INPUT TYPE="radio" name="soap_svc_url" value="<?=idx?>" <?=ch?>><?=urls[idx][1]?>
<?vsp
         idx := idx + 1;
      }
?>
    <P><INPUT TYPE="radio" name="soap_svc_url" value="-1">Other
    <INPUT size=50 value="" name="other_uri">
    <P>Enter the inbound string parameter value desired:
    <P><INPUT size=50 value="Hello world" name="param1">
    <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 <> '')
         {
?>
    <P><H2>Return value:</H2>
    <TABLE border="1" class="tableresult">
    <TR><TD>
    <P><b><?=_out_str?></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    }   ?>
  </FORM>
  </TD></TR>
</TABLE>
</BODY>
</HTML>
