I am creating a virtual service for a customer who is performing data validation on the response they get back from the service. The response is being sent back as JSON text along with some headers. One of the items they require in the header is a SHA-1 hash of the full JSON body of the response.
My first approach to get this hash is to generate it using a Java class in a Dynamic Java Execution Step. The JDK contains the MessageDigest class, which will return the hash needed. I've copied the relevant .jar file into the hotDeploy folder. However, when I click 'Finish' in the Object Constructor window, I get the following error:
"Constructor threw an exception: Invocation Exception on Dynamic Call/Ctor com.itko.lisa.dynexec.StaticCtor@20b38b34.
| Trapped Exception: missing provider| Trapped Message: java.lang.IllegalArgumentException: missing provider"
(Can provide the entire stack trace if necessary.)
Currently working in version 9.5.1 of the Workstation. I'd like some advice for if this approach makes sense in this situation. If so, can anyone provide insight on this error? And if not, is there a better solution I should be looking at? Happy to provide additional details.
Thanks in advance.
Just a thought... But, is it possible for you to use org.apache.commons.codec.digest.DigestUtils.sha1Hex("yourJsonString")?
This class and the static sha1Hex method is located in the commons-codec-1.9.jar in the LISA_HOME\lib\shared directory. If usable, you could implement a Response-side Scriptable DPH to convert the response string and add the hash to the response MetaData as a header.
Thanks for the response, Joel.
That's a good suggestion. I'll take a look at that implementation this week.