Home  /  Resources  /  Blog  /  Full REST Web Service Support in RPG API Express 3.2

Full REST Web Service Support in RPG API Express 3.2

RPG API Express version 3.2 is officially released

Since the January 2014 introduction of the new RXS3 API and its improvements, our RPG API Express customers have continued to make suggestions for even more features and new functionality. At Kato Integrations we embrace these suggestions to allow developers to leverage their existing RPG skills and couple them with newer, advanced technologies.

With the introduction of version 3.2 for RPG API Express we have added support for the following:

  • RESTful HTTP Methods such as PUT, DELETE, HEAD, OPTIONS and PATCH (POST and GET continue to be available)
  • Easy parsing of content from RESTful URI’s such as http://www.example.com/customer/53874
  • Support for dynamic as well as compiled templates
  • Extended length templates up to 256K
  • Automatic compression of whitespace when composing from templates
  • Automatic omission of uncomposed template content
  • New function RXS_ResetDS() for easily initializing data structures used by the RXS3 API
  • Enhanced RXS_GetStmf() to allow easy reading of stream file content in “chunks” within a loop
  • Enhanced RXS_PutStdOut() for easy output of HTTP Status, Content Type and other HTTP headers
  • Extended support for very large XML stream files when using the event based parser
  • Improvements to CRTRPGTPL command

Below are some simple code examples of the enhanced features highlighted above.

Consuming a RESTful web service with the DELETE method

				
					TransmitDS.HTTPMethod = RXS_HTTP_METHOD_DELETE;
gXmlResponse = RXS_Transmit( gXmlRequest : TransmitDS );
				
			

Offering a RESTful web service processing the DELETE method

				
					gMethod = RXS_GetEnvVar( ‘REQUEST_METHOD’ );
    if gMethod = ‘DELETE’;
    …
endif;
				
			

Parsing a RESTful URI such as http://www.example.com/customer/53874

				
					gCustomer = RXS_GetUrlVar( ‘customer/’ );
				
			

Compiled templates are a hit! Now dynamically processed templates are available as well

				
					ComposeDS.Stmf = ‘/www/rxs/templates/geturi2.tpl’;
				
			

Extended length templates up to 256K

				
					ComposeDS.LargeTemplate = RXS_YES;
				
			

Compression of whitespace when composing

				
					ComposeDS.TrimTemplateLines = RXS_YES;
ComposeDS.OmitLineControls = RXS_YES;
				
			

Reset or Initialize an RXS data structure

				
					RXS_ResetDS( GetStmfDS : RXS_DS_TYPE_GETSTMF );
				
			

Omit uncomposed template lines

				
					ComposeDS.OmitUncomposedLines = RXS_YES;
				
			

Reading a SMTF in “chunks”

				
					RXS_ResetDS( GetStmfDS : RXS_DS_TYPE_GETSTMF );
GetStmfDS.Stmf = ‘/tmp/bigfile.txt;
GetStmfDS.ChunkedLength = 65535;
dou %len(Data) = 0;
  Data = RXS_GetStmf( GetStmfDS );
  …
enddo;
				
			

Output required HTTP headers easily

				
					RXS_ResetDS( PutStdOutDS : RXS_DS_TYPE_PUTSTDOUT );
PutStdOutDS.HeaderStatusCode = 500;
PutStdOutDS.HeaderStatusText = ‘SOAP Fault’; PutStdOutDS.HeaderContentType = ‘text/xml’;
RXS_PutStdOut( gXml : PutStdOutDS ); 
				
			

Read STDIN over 16MB directly to a stream file

				
					RXS_ResetDS( GetStdInDS : RXS_DS_TYPE_GETSTDIN );
GetStdInDS.Stmf = ‘/tmp/over16mb.xml’;
RXS_GetStdIn( GetStdinDS ); 
				
			

Output large stream files over 16MB in size to STDOUT

				
					RXS_ResetDS( gPutStdOutDS : RXS_DS_TYPE_PUTSTDOUT );
gPutStdOutDS.HeaderContentType = ‘text/xml’;
gPutStdOutDS.Stmf = ‘/tmp/over16mb.xml’;
RXS_PutStdOut( *Omit : gPutStdOutDS ); 
				
			

Improved logging from RXS_Transmit()

				
					# Timestamp: 2015-09-22-14.16.05.604000
# Product: RPG-XML Suite
# Version: 3.20
# JobCcsid: 37
# URI: http://www.w3schools.com/webservices/tempconvert.asmx
# RequestStmf:
# ResponseStmf:
# RequestCcsid: 1208
# ResponseCcsid: 65535
# ResponseStmfCcsid: 1208
# Timeout: 60
				
			

Interested in installing or upgrading to the newest version of RPG API Express?

Contact our support team here.

Coming next to RPG API Express?  JSON composition and parsing!

Table of Contents