Manipulating "Router Endpoint" in "Message Forward" using script
I'm checking for a string and if string's length is not > 0 than I want to change the endpoint
If I put my Application.showMessage I can see that I'm in else when the size is not > 0 but the return does not seem to be returning because I get the error
Here is my sample code jython code
from com.parasoft.api import *
from soaptest.api import *
from java.lang import *
from com.parasoft.api import Application
from java.lang import *
from com.parasoft.api.Context import *
def printConsole(context):
appdirect_to_csp_endpoint = context.getValue("appdirect_to_csp_endpoint") default = context.getValue("default") if len(appdirect_to_csp_endpoint) > 0: return appdirect_to_csp_endpoint else: return default
Comments
-
Can you try using something other than "default" as the variable? Just in case it's because that is a reserved word. And can you tell us what error you get?
0 -
I changed it to testendpoint and same behavior. I have initialized that as a variable in responder suites level and made it google.com as an example.
If it goes to else I should see the request getting forwarded there but it is not. Even if it is in if statement it is not taking the URL so something to do with the way I'm returning I feel that is not working correctly.
Its a simple return statement for jython so not really sure what I'm doing wrong
0 -
Could you share you pva file?
0 -
It's going to be hard to send the existing PVA because of some of the DB dependency but will try to create a sample. Just to explain the image what I'm doing is I'm extracting value in XML Data Bank and saving that into the environment variable variable_1 that is at the responder suite. Using that variable I'm retrieving appdirect_to_csp_endpoint from the DB. If the size of that URL is 0 I want to use the URL specified in testendpoint variable and forward the traffic to that or forward the traffic to appdirect_to_csp_endpoint
0 -
Try using the URL as a "Fixed" endpoint in the Message Forward to see if it's forwarding as you expect.
0 -
Fixed & Parameterized both works but that defeats the purpose of lookup and making it more dynamic. I want to retrieve the endpoint and if endpoint length is 0, I want to send info to default URL
0 -
On the Message Forward tool could you try unchecking the Dynamic Forwarding option "Forward incoming URL path and parameters"?
0 -
I will try that out. For now I was able to use the workaround i.e. taking care of the default_url as part of the DB Tool lookup using nvl function so good for now but will definitely try it out of curiousity.
Thanks everyone for your help
0