Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

HTTP Response Code

jefftuckerbofa
jefftuckerbofa Posts: 229

Can someone share an example of how to capture the HTTP response code from a request to a virtual asset message responder? Ideally I would like to get that value and then insert it into a database using a DB Tool. I have successfully added a DB Tool to the Incoming Request and captured static data, however I am not sure how to add the DB Tool to the Outgoing Response and include dynamic data (such as the HTTP response code) to my query.

Comments

  • williammccusker
    williammccusker Posts: 642 ✭✭✭

    Hi,
    I
    s the response code dynamic? If the response code for a given responder is static you could just hard code the value that is inserted.

  • williammccusker
    williammccusker Posts: 642 ✭✭✭

    Hi,

    You could also use a script to extract the value out of the transport headers. Chain an extension tool to the "Outgoing Transport Headers" and then on the "input" arg call "getText" to get all the headers as a string. Then you could write some code to get the first line and get the response code from there.

    import com.parasoft.api.Application
    
    def getResponseCode(input, context) {
        Application.showMessage(input.getText())
    }
    

  • jefftuckerbofa
    jefftuckerbofa Posts: 229

    Dynamic in the sense that a if no matching response was found a 404 would be returned. Basically trying to generate a row in the DB for each request and capture whether or not there was a hit in the VA.

  • jefftuckerbofa
    jefftuckerbofa Posts: 229

    Your comment just made me realize that a responder would always return the status that it has it its configuration... a "miss" is more that the VA didn't find any matching message responders.. so it would hand it back to the message proxy with a 404

  • williammccusker
    williammccusker Posts: 642 ✭✭✭

    Hi,
    In the case that no responder matched the "404" would not be something a chained tool could capture. You could configure a default responder at the very end of you asset that would return a "404" response code rather than leaving it up to the server to respond. Then on that last responder, you could chain your DB tool and execute whatever you liked.

  • jefftuckerbofa
    jefftuckerbofa Posts: 229

    ok I will definitely look into that nice idea...

    we may also be able to get the reporting info we need by looking at the em_event_message_content.messagetext column for "ERROR" events