Forum Discussion

tim's avatar
tim
Contributor
16 years ago

Dynamic assignment of port for MockService?

Is it possible set the Port value for MockServices using a Global variable of some sort?

I would like to be able to pick a port at run time instead of relying on a hard coded value in the project xml.

3 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi,

    sorry, not at the moment, but we could make this available in a future version. Currently you can use the onStart script for the MockService to achieve this, since it is run before the mock is actually started, so setting the port from there (mockRunner.mockService.port = ...) should achieve this..

    regards,

    /Ole
    eviware.com
  • tim's avatar
    tim
    Contributor
    This is really helpful!

    Now how do I modify the port using the API?
    I would like to modify the SoapUIMockServiceRunner class to be able set the port dynamically, based on whether the port is already in use.

    The MockService interface class has a getPort() method but not a setPort() method.


    omatzura wrote:

    Hi,

    sorry, not at the moment, but we could make this available in a future version. Currently you can use the onStart script for the MockService to achieve this, since it is run before the mock is actually started, so setting the port from there (mockRunner.mockService.port = ...) should achieve this..

    regards,

    /Ole
    eviware.com
  • tim's avatar
    tim
    Contributor
    Nevermind. I figured it out.

    WsdlMockService has a setPort() method.