Web services have been around for quite a while now. If you attended the Success Partner Conference back in 2006, in London or Boston, you’ll have completed a hands-on tutorial that walked you through the steps required to consume web services with Synergy code.
During the conference, we wrote Synergy code to consume a number of different web services, from a number of different hosting sites. The first service we utilised returned an array of valid country names. We then used the returned information to populate a UI Toolkit combo drop-down input control to allow the user to select the required country. Other services we used allowed us to validate address details and credit card numbers. The final web service we worked with, that I know several customers have since made use of, gave us the ability to interface with a Simple Message Service (SMS) API and send text messages to a mobile phone number. Not all web services are free, and if I remember correctly, I believe the cost for sending an SMS was about $0.008!
So, when I saw the request from Rodney Latham on the Synergy-l list server, requesting if anyone had code to determine if a given date was a public holiday, I thought “there must be a web service to determine that”. After a quick search on the Internet I found one at a site called www.holidaywebservice.com. After a few minutes of navigating the site, and looking at the WSDL (Web Service Description Language), it was obvious that I could write a few lines of Synergy code to consume the web service to determine if a date was a public holiday. Another great feature of the web service was that it was free!
I knew that Rodney’s Synergy software ran on the OpenVMS operating system, so any fancy MS Windows coding was to be avoided – it had to be pure Synergy. As long as the machine could access the internet we could execute the web service.
I could have written a regular Synergy subroutine or function, but instead I chose to implement executing the web service within a static method, as part of a SynPSG.DateFunctions class. By defining the method as static, you don’t need to instantiate an instance of it. This makes the coding very simple. Add a reference in your code, using the “import” statement, to the SynPSG namespace and you’re ready. To determine if the date is a holiday, simply execute the static method, for example;
;;we have a holiday, let’s party!
The first argument to the IsHoliday() method accepts a reversed eight digit date and the second is an enumeration which allows you to select the required country code. The enumeration is defined within the SynPSG namespace;
public enum CountryCode
Simple, free and the code is available on the Synergex Code Exchange – log into the resource centre and search the Code Exchange directory for IsHoliday.