Figure 1
XML representation of a simple order

 
<order id="1131214" due="2007-04-12" dropShip="false">
    <shipTo>
        <name>Aaron Bartell</name>
        <address1>113 Commerce Lane</address1>
        <city>Mankato</city>
        <state>MN</state>
        <zip>56001</zip>
        <country>US</country>
    </shipTo>
    <item id="H2212R4" qty="21">
        <descr>Super diaper. Holds up to 10 lbs.</descr>
    </item>
</order>
 

Figure 2
RPG data structure representation of a simple order

 
     D Order           ds                  qualified inz
     D  ordId                        10u 0
     D  due                            d
     D  drpShp                         n
     D  shpTo                              likeds(ShipTo)
     D  itm                                likeds(Item) dim(100)

     D ShipTo          ds                  qualified inz
     D  nam                          30a
     D  adr1                         50a
     D  cty                          30a
     D  stt                           2a
     D  zip                          10a
     D  cntry                         2a

     D Item            ds                  qualified inz
     D  itmId                        15a
     D  qty                          10u 0
     D  dscr                        100a

      /free

       Order.ordId = 1131214;
       Order.due = %date();
       Order.drpShp = *off;

       Order.shpTo.nam = 'Aaron Bartell';
       Order.shpTo.adr1 = '113 Commerce Lane';
       Order.shpTo.cty = 'Mankato';
       Order.shpTo.stt = 'MN';
       Order.shpTo.zip = '56001';
       Order.shpTo.cntry = 'US';

       Order.itm(1).itmId = 'H2212R4';
       Order.itm(1).qty = 21;
       Order.itm(1).dscr = 'Super diaper. Holds up to 10 lbs.';

       *inlr = *on;

      /end-free
 

Figure 3
RPG data structure if viewed in memory

  
....+....1....+....2....+....3....+....4....+....5....+....6....+...
1131214   2007-04-12FAaron Bartell                 113 Commerce Lane 
 

Figure 4
XML Schema representation of a simple order

 
    <?xml version="1.0" encoding="UTF-8"?>
    <schema xmlns="http://www.w3.org/2001/XMLSchema">
      <element name="order">
        <complexType>
          <sequence>
            <element name="shipTo" minOccurs="0" maxOccurs="1">
              <complexType>
                <sequence>
                  <element name="name" type="string" minOccurs="1" maxOccurs="1" />
                  <element name="address1" type="string" minOccurs="1" maxOccurs="1" />
                  <element name="city" type="string" minOccurs="1" maxOccurs="1" />
                  <element name="state" type="string" minOccurs="1" maxOccurs="1" />
                  <element name="zip" type="string" minOccurs="1" maxOccurs="1" />
                  <element name="country" type="string" minOccurs="1" maxOccurs="1" />
                </sequence>
              </complexType>
            </element>
            <element name="item" minOccurs="1" maxOccurs="unbounded">
              <complexType>
                <sequence>
                  <element name="descr" type="string" minOccurs="0" maxOccurs="1" />
                </sequence>
                <attribute name="qty" type="positiveInteger" use="required"/>
                <attribute name="id" type="string" use="required"/>
              </complexType>
            </element>
          </sequence>
          <attribute name="dropShip" type="boolean" use="required"/>
          <attribute name="id" type="positiveInteger" use="required"/>
          <attribute name="due" type="date" />
        </complexType>
      </element>
    </schema>

 

Figure5

Figure6

Figure 7
Inventory Product and Order Header physical file definitions

 
     A                                      UNIQUE
     A          R INVPRDR                   TEXT('Inventory Product')
     A            ID            15          COLHDG('Uniqe Id of rcrd')
     A            CRTDT           Z         COLHDG('Rcrd Crt Date')
     A            PRDCD          5A         COLHDG('Product Code')
     A            PRDID         20A         COLHDG('Product Id')
     A            QOH            5P 0       COLHDG('Quantity On Hand')
     A          K ID        

     A                                      UNIQUE
     A          R ORDHDRR                   TEXT('Order Header')
     A            ID            15P 0       COLHDG('Uniqe Id of rcrd')
     A            CRTDT           Z         COLHDG('Rcrd Crt Date')
     A            DUEDT           L         COLHDG('Due Date')
     A            TOTAMT         9P 2       COLHDG('Total Amount')
     A          K ID    

 

Figure 8
refixing PF field names to create uniqueness

 
     H dftactgrp(*no)

     FORDHDRPF  if   e           k disk    prefix(O)
     FINVPRDPF  if   e           k disk    prefix(I)
      /free

       dsply 'Program ran';

       *inlr = *on;

      /end-free 
 

Figure 9
XML namespace example

 
    <envelope xmlns="http://mowyourlawn.com/my.xsd" 
              xmlns:vendor="http://vendor.com/vendor.xsd">
      <order dueDate="2006-10-18">
        <contact>
          <vendor:phone areaCode="612" phoneNumber="112-3212" ext="9908" />
        </contact>
        <PostAdr residential="true">
          <name title="Mr.">
            <first>Aaron</first>
            <last>Bartell</last>
          </name>
          <street>123 Center Rd</street>
          <cty>Mankato</cty>
          <state>MN</state>
          <zip>56001</zip>
          <phone>123-123-1234</phone>
          <phone>321-321-4321</phone>
        </PostAdr>
      </order>
    </envelope> 
 

Figure 10
Simple XML request without SOAP

 
        <Ord_calcPrice>
          <orderId>123</orderId>
          <dueDate>2006-10-20</dueDate>
        </Ord_calcPrice> 
 

Figure 11
Simple XML request with SOAP - RPC Encoded

 
    <SOAP-ENV:Envelope 
       xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
       xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <SOAP-ENV:Body>
        <ns0:Ord_calcPrice xmlns:ns0="http://tempuri.org/RPG_SrvPgm/">
          <orderId xsi:type="xsd:int">123</orderId>
          <dueDate xsi:type="xsd:date">2006-10-20</dueDate>
        </ns0:Ord_calcPrice>
      </SOAP-ENV:Body>
    </SOAP-ENV:Envelope> 
 

Figure 12
Simple XML request with SOAP - Document Literal

  
    <SOAP-ENV:Envelope 
       xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
      <SOAP-ENV:Body>
        <Ord_calcPrice>
          <orderId>123</orderId>
          <dueDate>2006-10-21</dueDate>
        </Ord_calcPrice>
      </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
 

Figure 13
An RPG prototype parallels the WSDL portType element

 
     D Ord_calcPrice   pr
     D  pReq                               likeds(Ord_calcPriceReq)
     D  pRsp                               likeds(Ord_calcPriceRsp)


     D Ord_search      pr
     D  pReq                               likeds(Ord_searchReq)
     D  pRsp                               likeds(Ord_searchRsp) 
     
  <portType name="ORDSV">
    <operation name="Ord_calcPrice">
      <input message="rxs:Ord_calcPriceReq" />
      <output message="rxs:Ord_calcPriceRsp" />
    </operation>
    <operation name="Ord_search">
      <input message="rxs:Ord_searchReq" />
      <output message="rxs:Ord_searchRsp" />
    </operation>
  </portType>   
 

Figure 14
An RPG data structure parallels the WSDL message element

 
     D Ord_calcPriceReq...
     D                 ds                  qualified inz
     D  ordId                        10i 0
     D  dueDate                        d

     D Ord_calcPriceRsp...
     D                 ds                  qualified inz
     D  totPrice                      9p 2
     D  totPriceAD                    9p 2
     
     
     D Ord_searchReq   ds                  qualified inz
     D  ordId                        10i 0
     D  dueDate                        d

     D Ord_searchRsp   ds                  qualified inz
     D  totPrice                      9p 2
     D  totPriceAD                    9p 2  
     
     
  <message name="Ord_calcPriceReq">
    <part name="orderId" type="xsd:int" />
    <part name="dueDate" type="xsd:date" />
  </message>
  <message name="Ord_calcPriceRsp">
    <part name="totalPrice" type="xsd:double" />
    <part name="totalPriceAfterDiscounts" type="xsd:double" />
  </message>
  <message name="Ord_searchReq">
    <part name="orderId" type="xsd:int" />
  </message>
  <message name="Ord_searchRsp">
    <part element="rxs:Order" name="Ord_searchRsp" />
  </message>     
 

Figure 15
DSPSRVPGM parallels the WSDL service element

 
                     Display Service Program Information
                                                        
Service program  . . . . . . . . . . . . :   ORDSV      
  Library  . . . . . . . . . . . . . . . :     AARONLIB    
Owner  . . . . . . . . . . . . . . . . . :   AARON      
Service program attribute  . . . . . . . :              
Detail . . . . . . . . . . . . . . . . . :   *BASIC     

  <service name="OrdServices">
    <port binding="rxs:OrdBinding" name="OrdServicesPort">
      <soap:address location="http://192.168.0.100:8181/ORDLIB/ORDSVCGI" />
    </port>
  </service>
  
 

Figure 16
WSDL binding element ties service and portType elements together

 
  <binding name="OrdBinding" type="rxs:ORDSV">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
    <operation name="Ord_calcPrice">
      <soap:operation style="document" soapAction="Ord_calcPrice" />
      <input>
        <soap:body use="literal" />
      </input>
      <output>
        <soap:body use="literal" />
      </output>
    </operation>
    <operation name="Ord_search">
      <soap:operation style="document" soapAction="Ord_search" />
      <input>
        <soap:body use="literal" />
      </input>
      <output>
        <soap:body use="literal" />
      </output>
    </operation>
  </binding> 
 
Figure17

Figure 18
HTTP request

 
POST /myrxs/rxs3 HTTP/1.0
Accept: text/html
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)
Host: 172.29.134.41:8181
Content-type: application/x-www-form-urlencoded
Content-length: 358

<PostAdr residential="true">
  <name title="Mr.">
    <first>Aaron</first>
    <last>Bartell</last>
  </name>
  <street>123 Center Rd</street>
  <cty>Mankato</cty>
  <state>MN</state>
  <zip>56001</zip>
  <phone>123-123-1234</phone>
  <phone>321-321-4321</phone>
</PostAdr> 
 

Figure 19
HTTP response

 
HTTP/1.1 200 OK
Date: Tue, 10 Oct 2006 14:22:48 GMT
Server: Apache
Pragma: no-cache
Expires: Saturday, February 15, 1997 10:10:10 GMT
Content-Length: 84
Connection: close
Content-Type: text/xml; charset=ISO-8859-1

<response status="success">PostAdr for Aaron Bartell has been processed.</response>