Forum Discussion

davekfrommd's avatar
davekfrommd
Occasional Contributor
8 years ago
Solved

Creating a simple SOAP MockService (help!)

Folks,

I used SOAPUI years ago to perform basic XML testing.  I'd import the WSDL into SOAPUI and it would 'digest it'.  I'd select the operation (?method) to perform and the s/w would put up a sample screen with boxes for the input fields.  I'd plug in values for the various input parameters and then submit the request (and receive the response).  That's about my experience with Webservices testing...

 

Now I have to test a TBD web API and found references to creating a "mock" service.  I have no idea how to do this and tried reading the several articles and forum posts, but they are beyond my knowledge base.  While many web API's are conversational in nature, where you have to make several calls, in sequence, to accomplish a business task, the TBD API I'll be testing is very simple.  It'll be a simple GET with parameters that returns information.  E.g., the call is username, password, business ID, start date, end date, and optional vendor ID.  It returns the business ID, the name associated with the business ID, City, State, ZIP Code, # orders (within state - end date), and percent of orders completed. 

 

It appears that I simply don't have the web background needed to create a mock service for this.  The examples I've seen have scripting, Xpath stuff, and to me, foreign syntax and concepts that are beyond my knowledge.  If someone can point me to the basic topics/disciplines I need to become familiar with, it'd be much appreciated and I'll start learning/training.

 

Thanks much, Dave

  • Hi Dave,

     

    Ah! OK, the port of 8080 was a bad choice, looks like you've got something on there already! Have a go with 9001 or something else until that 'address already in use' error goes away.

     

    Regards,

    Rup

11 Replies

  • rupert_anderson's avatar
    rupert_anderson
    Valued Contributor

    Hi Dave,

     

    So, it sounds like you're looking to create a REST mock - I take it you've seen:

     

    https://www.soapui.org/rest-testing-mocking/rest-service-mocking.html

     

    And related pages on the SoapUI wiki?

     

    Is it just a basic REST mock with GET mock Action and fixed JSON or XML response? You only need scripting skills if you want to make the mock's response dynamic in some way, rather than hard coded.

     

    Let me know how far you've got with creating the REST project & REST Mock and we can take it from there.

     

    Regards,

    Rupert

    • davekfrommd's avatar
      davekfrommd
      Occasional Contributor

      Yep, saw that and other informational pages on Mock Services.  The concept seems OK.  I create a mock service (I guess give it a name).  Then I create mock actions (which I guess are the ?methods? / functionality exposed by the API.  Each mock action (I guess) has one or more responses; made up of success responses, warning, or error responses.  For example, a success response can be 'here's the data you requested' or you made a valid request - there's just no data to return to you', or errors like XYZ is a required input parameter, or the format for DATE is incorrect, or username/password incorrect, etc. etc.

       

      I was able to name a mock service but couldn't get one step past that.  I couldn't name/create a mock action (it was asking for a "resource path".  I don't understand Resource Path or Dispatch.  I guess Resource Path is a folder, but what do you put in the folder?  Dispatch concept is foreign, I just don't understand it.  I don't know any scripting languages... Clearly I don't have sufficient background to create & document a mock service ergo that's why I asked, where do I start?

       

      The API under development is REST based.  It has 5 required inputs and 2 optional inputs.  There's only one mock action, the data request.  The user makes a request for data and the API responds.  There isn't a 'conversation'.  If successful data a 'table' of data (several of rows of data) is returned (the response) to the user.  I know the fields/format of the data that's returned.

       

      Thanks, DaveK

      • rupert_anderson's avatar
        rupert_anderson
        Valued Contributor

        Hi Dave,

         

        OK, first things first, maybe we should work on the terminology side. If you have a REST service:

         

        (GET) http://localhost:8080/hello

         

        Then:

        host->localhost

        port->8080

        path->/

         

        The create the action -> hello

        Set the method->GET and Resource Path->/hello, dispatch type->sequence (not script)

        Create a response, called 'default', Content-Type: text/xml, response body as <xml>hell</hello>

         

        Then just start the mock, make a request to http://localhost:8080/hello, and you should see <xml>hello</xml>!

         

        Regards,

        Rup