Tag Archives: WebSmart Tip

Debugging a WebService response

When running the posturl command a response is sent to the web server.  This response includes both the post data and the http headers.

At times it is necessary to view and debug what is sent in the header since some web servers require specialized headers.

If you need to figure out what is being returned in the header of a request when running posturl follow these steps:

  • Add a folder named ‘zztemp’ to the root directory in your IFS.
  • Run your webservice.
  • Look for the file httpapi_debug.log in zztemp. It will contain the last posturl that was run.

This is a back door debugging tool added by the developers.

Code Snippets for PHP, JavaScript and ILE

Yesterday we added a folder to the consulting SVN repository to store code snippets in (http://svn.excelsystems.com/svn/consulting/001 Code Snippets). There are already a few snippets in there. The purpose is of course easier sharing and accessibility to reusable code. And all the advantages of subversion, e.g. tracking changes.

Please feel free to add any of your code snippets to this folder and/or improve existing snippets.

The following scripts/functions/files are already there:

  • ILE
    • A search and replace function, that scans a text file for place holders and replaces those with any text. WebSmart 8.8 required with local variables and function parameters enabled.
  • JavaScript
    • A print_r/var_dump function that I found on a website. It’s similar to PHPs print_r/var_dump
    • jQuery Plugins: autoSubmit and elapsedTime. I wrote these two scripts. The autoSubmit plugin submits a form when a maximum defined number of characters is reached. The elapsed Time outputs a simple timer, I found the plugins out there too complicated for what I wanted to do. The autosubmit is used for two touch screen applications that we developed, Skechers and Cleveland Gear.

How To Create a WebSmart Template that Converts Data from DB2 to MySQL

This post shows some of the features in the intelligent templates in WebSmart, and how to use those features to write your own powerful customized templates.

Recently, I wanted to convert the data in DB2 physical files to MySQL tables, so that I could easily take advantage of the IBMDB2i database engine for MySQL. I already have a nifty DB2 to MySQL code generator, which you can download for free from our website.  However, I didn’t have an easy way to import data from files.  So I decided to write a WebSmart program to do it. Using phpMyAdmin, I can then cut and paste the output from this program into the SQL text area, and run it. The output needs to look something like this (for a fictitious file):

INSERT into `CUSTOMERS` (`custno`, `custname`, `crtdate`, `crttime`)
VALUES (1, 'Acme Bolts', '2010-06-02', '15:35:12'),
(2, 'Superior Widgets', '2010-06-03', '16:04:35');

You can import tables into MySQL using the phpMyAdmin interface or a command line interface from the PASE environment on the IBM i. In phpMyAdmin, you choose the ‘Import’ option and select a plaintext file with a .sql extension from somewhere locally. So if I save the above code in a text file called customer.sql, I go to phpMyAdmin, choose my database, click the Import link, select the file customer.sql and voila! I have a customer MySQL table, complete with 2 rows of data. Continue reading

Incorrectly sequenced emails from WebSmart programs

We have a program that automatically emails our support team leader a daily summary of support stats. This is generated by a WebSmart program on the iSeries every day at 9:30 AM.

Earlier this week I noticed that when the email came in, it was getting sequenced earlier in my inbox than others that had arrived before it.

On looking into the issue, this was because our area had gone off daylight savings time, and the UTC offset value in the ECFGSMTP command (library XL_WEBSPT) was no longer correct. We changed this value from -0700 to -0800, and expect it to be working correctly again to tomorrow.