Service Virtualization

  • 1.  Which step to use in DevTest for wss requests

    Posted Oct 25, 2018 05:04 AM

    I am using an web application and creating test cases using REST steps in DevTest for that. When performed some actions, in deverloper options found some requests on to WebServer as wss. Web Execution step is not suitable for this as there is no WSDL and it is not a web service request. It is a web socket step.

     

    Which is a suitable step in DevTest for this.

     

    Thanks,

    Vijay.S



  • 2.  Re: Which step to use in DevTest for wss requests

    Broadcom Employee
    Posted Oct 25, 2018 05:53 AM

    At its base websocket is a TCP connection, there’s no OOTB step for setting up a TCP connection. You would have to resort to an Execute Script step.

     

    How complex it would be depends on the complexity of the message exchange you need to have over the websocket.

     

    If it is kind of a fixed communication, example you connect as a client, send one message, expect one answer, close the socket and that is it, then that complete message exchange can be in one script. Do a Google search for “java websocket client example” you will find some examples (e.g. on StackOverflow) where the javax.websocket class is used. It looks like it is not that complex, with a couple of lines you can set up a connection send something over.

     

    If the communication is more complex, maybe you want to loop over an excel file for an arbitrary number of data rows which need to be sent over the websocket then you can’t limit this to one step, so this means you will have to create your websocket object and store it in testExec using setStateObject(). Now everytime you need to send a message over the websocket you need to put an Execute Script step, in that step retrieve the websocket object with testExec.getStateObject() before sending a message.

     

    Cheers,

    Danny