Forum Discussion

Dish_Network_Su's avatar
Dish_Network_Su
New Contributor
15 years ago

Invoke a test request from mock

Hi All,

I am using SOAPUI Pro 3.5.1 and trying to point my web service requests to mock server, depending on the match on one of the fields in the input mock response is populated which is good till this point. But if it didn't find a match i would like to invoke original web service add service response to mock. Next time when i get the same request it should pull it from the mock.

I have looked at Mock server documentation, it says we could do this above functionality from dispatch script, can you point me to documentation/sample scripts for this.

I have also hard time using the xpath in this version, to validate multiple input fields for a mock response.

Thanks,
Surya.

3 Replies

  • Hi,
    Inside the soapUI installation directory you should be able to find Tutorials/sample-soapui-project.xml . Import this project into soapUI and open SampleServiceSoapBinding MockService/search, there you should be able to find example of what you are looking for.

    Regards,
    Dragica
    /eviware.com
  • Thanks for the quick response.

    In this Sample project, a new request is invoked from the test suite. I am looking for a scenario to invoke from the dispatch script.
    The way we are heading is to create a mock for a external services that go out of the environment for example credit qualification. When i send a credit card number in a range it should respond from the mock, if not invoke a WS and record that response.
    From the above way the client services would have to point to Mock server end point and get the response as usual.


    Thanks,
    Surya.
  • Hi Surya,

    try the following in your dispatch script:

    def request = mockOperation.mockService.project.interfaces[".."].operations[".."].requests[0]
    request.submit( new com.eviware.soapui.impl.wsdl.WsdlSubmitContext( request ), false )
    context.proxyResponse = request.responseContent

    and then dispatch to an empty MockResponse containing just

    ${proxyResponse}

    Does that work ok?

    regards!

    /Ole
    eviware.com