www.krengeltech.com

RXS_soapDecode

From Wiki

User Guide

Contents

Description

Call this subprocedure to take XML from its encoded form (i.e. &lt;tagname&gt;content&lt;/tagname&gt;) to actual XML that can be parsed (i.e. <tagname>content</tagname>).

The reason this subprocedure is named soapDecode speaks to why this API is needed in the first place. Many programmers in .NET and Java environments have their code generated which inherently means the encoding style usually defaults to RPC (Remote Procedure Call) vs. Document Literal. Note that RXS_soapDecode can also be used to encode values if your program is composing the XML to be sent to an RPC style web service. In the end RXS_soapDecode is simply an easy to use find/replace mechanism to use on files and variable data.

Prototype

     D RXS_soapDecode  pr
     D  pFileOrData                        like(RXS_XmlData)     
     D  pType                              value like(RXS_Type)
     D  pFrom                        10a   dim(10) varying options(*nopass)
     D  pTo                          10a   dim(10) varying options(*nopass)

Parameters

pFilePathOrData
Used to specify a file in the IFS or actual XML residing in an RPG variable. If an IFS file is specified it must either be fully qualified (i.e. /home/aaron/mydoc.xml) or must reside in the default transaction directory (i.e. /www/myrxs/trans.) If it resides in the default transaction directory then you can just specify it as ‘mydoc.xml.’
pType
This parameter can either have RXS_STMF or RXS_VAR specified as it’s value. Use RXS_STMF if the value passed in pFilePathOrData is a path to an IFS file. Use RXS_VAR if the value passed in pFilePathOrData contains XML.
pFrom
Not a required parameter. Used to specify a list of from values in an array that correspond to the to values in pTo. If not specified the default set of decoding characters are used as specified in the notes below.
pTo
Not a required parameter. Used to specify a list of to values in an array that correspond to the from values in pFrom. If not specified the default set of decoding characters are used as specified in the notes below.

Return value

None.

Notes / Examples

The following are the default from/to array values if pFrom and pTo are not specifed on the call to RXS_soapDecode.


     from(1) = '&amp;lt;';
     to(1) = '<';
     from(2) = '&amp;gt;';
     to(2) = '>';
     from(3) = '&amp;quot;';
     to(3) = '"';
     from(4) = '&apos;';
     to(4) = '"';
     from(5) = '&amp;amp;';
     to(5) = '&';

The following is an example program showing how to translate the contents of a variable to an encoded form. Decoding would simply be taking the opposite approach, essentially switching the from values with the to values and vice versa.


     H dftactgrp(*no) bnddir('RXSBND')
 
      /copy rxs,RXSCp
 
     D from            s             10a   dim(10) varying
     D to              s             10a   dim(10) varying
     D str             s          65535a   varying
      /free
 
       str = 'ADAMS & SONS >< LTD';
 
       from(1) = '&';
       to(1) = '&amp;';
       from(2) = '<';
       to(2) = '&lt;';
       from(3) = '>';
       to(3) = '&gt;';
       RXS_soapDecode(str: RXS_VAR: from: to);
 
       *inlr = *on;
 
      /end-free