Yeah, the compare assertion is a bit odd about how it handles null variables. I always assign a result from an XPath to a string context variable, that way if the result had been null then the context variable will be empty.
So, for starters, you don't need to copy the request message to run the XPath assertion. Unlike most of the assertions, which have a message targeting option, the Evaluate XPath functionality has two different assertions, one for requests and one for responses and arbitrary variables (the latter of which does have targeting, but it can't include the request). This is a holdover from the very early days of the Layer 7 policy language and one which I wish we would fix. Anyway, in your policy you are assigning the request payload to a new variable and using the Evaluate Response XPath assertion with that variable targeted. You should be using the Evaluate Request XPath assertion which automatically works on the request message so you don't need to spin cycles copying ${request.mainpart} to a new context variable.
I don't have any visibility into your policy beyond the screen shot and a description, but I suspect what you are trying to do is this:
------------------------------
Jay MacDonald - Adoption Architect - Broadcom API Management (Layer 7)
------------------------------
Original Message:
Sent: 04-01-2020 05:46 PM
From: Robert Kohler
Subject: Error on Compare assertion
To clarify,
The source will either have a value or be empty.
The requirement is to set a context variable if the path has a certain value.
So in keeping with your sample xml I need to set OT-aprf = "NEWCODE" if baz = "123"
The issue is that when I use compare to check for that value it fails when it's empty.
With respect to why separate variable I took this from another policy that was doing something similar, I'm not an expert so if you have better way I'm all ears.
Original Message:
Sent: 04-01-2020 01:59 PM
From: Robert Kohler
Subject: Error on Compare assertion
Correct the value in <Reference9></Reference9> could be blank.
So how to you get compare to deal with null values?
Bob
Original Message:
Sent: 03-31-2020 10:50 PM
From: Irfan Mugale
Subject: Error on Compare assertion
Hi Bob.
As per the screenshot it seems you are getting a empty result.
Please check if the rf9 value is passed in the xml packet. Currently it is empty due to which it is failing in compare assertion.
Thanks,
------------------------------
Application Development Analyst
Accenture
Original Message:
Sent: 03-31-2020 05:41 PM
From: Robert Kohler
Subject: Error on Compare assertion
Using Gateway ver 9.4
No matter what I do to switch up the logic it always gives the same error on the compare, line 28. Any ideas?
And goes in the log like this which is a 2,4,8,16,32 sec diff between them.
2020-03-31T21:22:10.138+0000 WARNING 250587 com.l7tech.server.policy.assertion.ServerAuditDetailAssertion: -5: [FDX-39031658188389] Starting Policy: MONITOR-RCVPIX-HOLON
2020-03-31T21:22:33.149+0000 WARNING 250587 com.l7tech.server.event.AdminInfo: The administrative event caused as local call, outside of servicing an adminstrative remote call.Will use ip/user127.0.0.1/localsystem
2020-03-31T21:22:35.155+0000 WARNING 250583 com.l7tech.server.policy.assertion.ServerAuditDetailAssertion: -5: [FDX-150117304217041] Starting Policy: MONITOR-RCVPIX-HOLON
2020-03-31T21:22:39.161+0000 WARNING 250584 com.l7tech.server.policy.assertion.ServerAuditDetailAssertion: -5: [FDX-147964495146141] Starting Policy: MONITOR-RCVPIX-HOLON
2020-03-31T21:22:47.165+0000 WARNING 250585 com.l7tech.server.policy.assertion.ServerAuditDetailAssertion: -5: [FDX-40062953976274] Starting Policy: MONITOR-RCVPIX-HOLON
2020-03-31T21:23:03.171+0000 WARNING 250586 com.l7tech.server.policy.assertion.ServerAuditDetailAssertion: -5: [FDX-64930921149188] Starting Policy: MONITOR-RCVPIX-HOLON
2020-03-31T21:23:35.175+0000 WARNING 250587 com.l7tech.server.policy.assertion.ServerAuditDetailAssertion: -5: [FDX-242325993772905] Starting Policy: MONITOR-RCVPIX-HOLON
------------------------------
Thanks for the help
Bob
------------------------------