ProductivityAndFun Download Trial - Free 14 day evaluation

Web Service Sample Project - 1) Web Service Mocking

PDF Print E-mail
User Rating:  / 140
Rate this article: PoorBest 

1) Web Service Mocking

Now, let's see how you add a MockService.

Introduction

Web Service Mocking is way to fake or simulate the functionality of a Web Service in soapUI; to create a Mock Up. But why do you need such functionality?

Web Service Mocking is very useful in projects where implementation of the Web Service has not started or is not finished for use yet or where you for some other reasons can't access the Web Services live.

In other words, Web Service Mocking makes it possible for you to start creating test for a Web Service the same time you start to develop the same Web Service. This means, when the real Web Service is ready for testing; you can already have the tests done. This can be extremely powerful and will make it possible to work according to Test Driven or Agile Methodologies.

In soapUI you can create a MockService simply by choosing to add a Web Service Request to a MockService in order for the MockService to listen to it. Or you can even right-click the Interface Icon and choose "Generate MockService", which will generate a MockService containing each defined response in the Interface.

Tutorial

  1. To add a MockService, right click on the interface icon and select Generate MockService.
    Generate MockService Dialog
  2. The Generate MockService dialog will open.
  3. Enter the name of your MockService and click OK.
    Naming MockService Dialog
    Note:
    You will receive a Composite Warning if you have two mockservices with the same name.
  4. The MockService will now be successfully generated.

    A Generated MockService
    You can then choose how to Respond to the Request and choose how to Dispatch (send out) different responses.
  5. Now, let's take a look at how the Mock Service works. There is a SampleServiceSoapBinding Mock Service already in the Sample Pro Project, so if you followed the steps above, please discard what you've created or move to the SampleServiceSoapBinding MockService. Open the MockService by double clicking on it.
    Opened Web service Simulation in soapUI
  6. Browse through the different Interfaces in the MockService; login, logout, search, and buy, and see what we do with different requests. As you see all the requests are dispatched using scripts. This is by far the most common way of dispatching, but early on in a project you might just want to create a set of responses and dispatch them in sequence or at random.
  7. Click on the Run button run to start the MockService.
  8. You should now see the MockService running on port 8088.
    MockService running

Go to Article Page: Go to Previous Page 1 2 3 4 5 Go to Next Page