HTTP Response Code

jefftuckerbofajefftuckerbofa Posts: 47

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

  • williammccuskerwilliammccusker Posts: 392 ✭✭

    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.

  • williammccuskerwilliammccusker Posts: 392 ✭✭

    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())
    }
    

  • jefftuckerbofajefftuckerbofa Posts: 47

    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.

  • jefftuckerbofajefftuckerbofa Posts: 47

    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

  • williammccuskerwilliammccusker Posts: 392 ✭✭

    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.

  • jefftuckerbofajefftuckerbofa Posts: 47

    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

Sign In or Register to comment.