Skip directly to search Skip directly to A to Z list Skip directly to page options Skip directly to site content

CDC WONDER API Utility

This is simple a utility written in Java to access the CDC WONDER API. If you are having trouble with another utility and you can compile and run a Java program, this may be of use. You will need to download these files:

WonderAPI.zip contains WonderAPI.java and HttpLight.java. WonderAPI is the utility to run. HttpLight is a simple wrappter around the HttpClient library, which does the http communications. The logging library is used by HttpClient. Feel free to modify the packages in the Java files to something more convenient. WonderAPI sends one request file to the WONDER API and writes the server response to a results file. It takes two parameters, a directory and a file in the directory to send. The filename starts with a dataset code and '_', like the example files. Any and all of these conventions can also be changed, the utility is simply provided as a starting point.

HTTPS Considerations

As of Oct. 5, 2016 the WONDER website requires access using https. The WonderAPI utility handles https communications, you just use https:// in the WONDER server url. In testing https connections we have found a couple of issues that can occur, depending on how the server certificate is set up. The WONDER website currently (Oct. 2016) doesn't have either of these issues, but here are some workarounds should they ever arise.

Trusted Certificate Issue
The HttpClient library uses Java library code to make secure connections, including a list of trusted certificates that is part of the JRE. If a server returns a certificate that's not in the JRE's trusted list, an exception is thrown. If this happens, we have another utility you can use to fix this problem:

The InstallCert utility reads the certificate from the server and adds it to the JRE's trusted certificate list, which allows secure connections to work. If the WonderAPI utility encounters this problem, it prints a message to that effect. You then run InstallCert with the server name. It asks which certificate you want to install, if the server returns more than one certificate, start with the first one. Using the certificate you select, it creates a file called jssecacerts. Copy that file to the jre/lib/security directory and run WonderAPI again.

SNI Issue
SNI is a protocol that sits on top of TLS (the replacement protocol for SSL). By default the JDK has this option enabled. However, some server certificate configurations are not compatible with SNI, causing an exception when a secure connection to the server is attempted. When this happens you need to uncomment the line in WonderAPI that disables SNI, recompile and then try again.

If you have any questions about using these utilities, please contact us.


This page last reviewed: Thursday, October 06, 2016
This information is provided as technical reference material. Please contact us at cwus@cdc.gov to request a simple text version of this document.
TOP