Forum Discussion
DSB_IT_Support
14 years agoOccasional Contributor
Here is the code (placed in RequestFilter.filterRequest)
Please note, that the signature is calculated on the Body contents and the contents of the OurHeader element. So it is not an option to insert changes to the header in the RequestFilter.filterRequest hook since that would invalidate the signature. That is why I need an event that is fired before the signing occurs.
For my sake I have worked around the problem by eliminating the use of the event-hook. Instead I insert the desired value in each single request.
However, I believe that it would be of general interest to know whether there is an option to perform changes to the requests in an event-hook that is invoked before signing occurs.
if ( !(context.requestContent.contains("some_element") ||
context.requestContent.contains("some_other_element"))) {
value1 = "aeb34c46-1653-42cc-8f26-20c505e5519c"
value2 = ourUtils.xsdDate()
value3 = ourUtils.randomUuid()
newHeader = "<soapenv:Header>
<ihe:OurHeader>
<ihe:element1>
<ihe:element2>${value1}</ihe:element2>
</ihe:element1>
<ihe:element3>${value2}</ihe:element3>
<ihe:element4>${value3}</ihe:element4>
</ihe:OurHeader>"
req = context.requestContent
ind1 = req.indexOf("<soapenv:Header>")
ind2 = req.indexOf("</soapenv:Header>") - 1
sb= new StringBuffer(context.requestContent)
sb[ind1..ind2] = newHeader
context.requestContent = sb.toString()
}
Please note, that the signature is calculated on the Body contents and the contents of the OurHeader element. So it is not an option to insert changes to the header in the RequestFilter.filterRequest hook since that would invalidate the signature. That is why I need an event that is fired before the signing occurs.
For my sake I have worked around the problem by eliminating the use of the event-hook. Instead I insert the desired value in each single request.
However, I believe that it would be of general interest to know whether there is an option to perform changes to the requests in an event-hook that is invoked before signing occurs.