D4B3 New Feature: Calling web services

BDD has always supported rules processing via CustomSettings.ini, where values from the local machine, typically retrieved via WMI, could be used to make decisions on what needs to be done on each machine during a deployment.  It could also make SQL queries and stored procedure calls to retrieve additional information from external databases.  There were always challenges with that though, especially around making secure SQL connections.

To help with that problem, we have added the capability in Deployment 4 to make web service calls based on simple rules defined in CustomSettings.ini.  These web service requests don't require any special security context and can use whatever TCP/IP port is needed, to simplify firewall configurations.

Here's a sample showing how to configure CustomSettings.ini to call a particular web service.  In this case, the web service is just one picked at random from an internet search.  It takes a Zip code as input and returns the city, state, area code, and time zone (as a letter, strangely enough) for the specified Zip code.

[Settings]
Priority=Default, USZipService
Properties=USZip, City, State, Zip, Area_Code, Time_Zones

[Default]
USZip=98052

[USZipService]
WebService=https://www.webservicex.net/uszip.asmx/GetInfoByZIP
Parameters=USZip

So if you were to execute this, you would see output something like this:

Added new custom property USZIP
Added new custom property CITY
Added new custom property STATE
Added new custom property ZIP
Added new custom property AREA_CODE
Added new custom property TIME_ZONES
Using from [Settings]: Rule Priority = DEFAULT, USZIPSERVICE
------ Processing the [DEFAULT] section ------
Property USZIP is now = 98052
Using from [DEFAULT]: USZIP = 98052
------ Processing the [USZIPSERVICE] section ------
Using COMMAND LINE ARG: Ini file = CustomSettings.ini
CHECKING the [USZIPSERVICE] section
About to execute web service call to https://www.webservicex.net/uszip.asmx/GetInfoByZIP: USZip=98052
Response from web service: 200 OK
Successfully executed the web service.
Property CITY is now = Redmond
Obtained CITY value from web service:  CITY = Redmond
Property STATE is now = WA
Obtained STATE value from web service:  STATE = WA
Property ZIP is now = 98052
Obtained ZIP value from web service:  ZIP = 98052
Property AREA_CODE is now = 425
Obtained AREA_CODE value from web service:  AREA_CODE = 425
------ Done processing CustomSettings.ini ------

There are a few minor complications to watch out for when doing this:

  • We don't do anything special with proxy servers.  If there is an anonymous proxy present we will use it, but authenticating proxies will cause issues.  But in most cases, I wouldn't expect you to really be calling an internet web service.
  • The XML returned as a result of the web service call is searched for any property defined via CustomSettings.ini or ZTIGather.xml (just like with a database query or other rule).  However, the XML search is case-sensitive.  Fortunately the web service above returns all upper case property names, which is what ZTIGather expects.  It is possible to remap lower or mixed-case entries to get around this.
  • We always perform a POST request to the web service, so it needs to support a POST.

With any luck, we'll provide some real sample web services as we get closer to the release of Deployment 4.  If you come up with any creative samples that you would be willing to share, let me know.