The following topics offer a detailed reference to the options provided by SOAP/REST Mock Service.
You can check what service mocks have been defined under the following URL and follow links available for each service operation.
http://server:port/{APP_CONTEXT}/services
API's concerning both REST and SOAP webservice mocks are similar but for better readability the reference has been split to two independent chapters.
SERVICE[0].NAME=dummy-soap-service SERVICE[0].WSDL=dummy.wsdl SERVICE[0].TYPE=SOAP
or
SERVICE[0].NAME=dummy-soap-service SERVICE[0].TYPE=SOAP SERVICE[0].OPERATION[0].INPUT_MESSAGE=dummySoapRequest SERVICE[0].OPERATION[0].DEFAULT_RESPONSE=dummy_soap_response.xml
Mocked webservice endpoint is available under the following URL:
http://server:port/{APP_CONTEXT}/services/{SERVICE[i].TYPE}/{SERVICE[i].NAME}/endpoint
Parameter | Description |
---|---|
SERVICE[i].TYPE | type of service provided in the config file (here: SOAP) |
SERVICE[i].NAME | name of service provided in the config file |
Example:
http://localhost:8080/mock/services/SOAP/dummy-soap-service/endpoint
Each webservice mock can be controlled with a set of RESTful resources.
Root url context of each of the control resources is:
http://server:port/{APP_CONTEXT}/services/{SERVICE[i].TYPE}/{SERVICE[i].NAME}/operations/{SERVICE[i].OPERATION[j].INPUT_MESSAGE}
Parameter | Description |
---|---|
SERVICE[i].NAME | name of service provided in the config file |
SERVICE[i].OPERATION[j].INPUT_MESSAGE | input message of SOAP request. In practice it's the name of the XML element that goes directly after soap:body element of a SOAP request. |
Example:
http://localhost:8080/mock/services/SOAP/dummy-soap-service/operations/dummySoapRequest
The control resources of this root context would affect mock of SOAP operation that accepts dummySoapRequest and is a part of dummy-soap-service.
The Setup Resources allow the user to setup mock's behaviour before each test case is performed.
DESCRIPTION | This resource allows to initialize mock service endpoint and erase previously recorded requests. |
EXAMPLE URL | http://localhost:8080/mock/services/SOAP/dummy-soap-service/dummySoapRequest/init |
HTTP METHOD | POST |
DESCRIPTION | Sets up mock response(s). Posting an xml to this resource will cause the mock to respond with that xml. Multiple consecutive posts to this resource will set a series of consecutive responses | |
EXAMPLE URL | http://localhost:8080/mock/services/SOAP/dummy-soap-service/operations/dummySoapRequest/responses?delay=5 | |
HTTP METHOD | POST | |
REQUEST BODY | The response to be returned by mock. | |
PARAMETERS |
delaySec - integer, optional - number of seconds mock response is to be delayed for |
code - valid http code, optional - HTTP response code to be returned by mock |
DESCRIPTION | PUT'ing an xml to this resource will cause the mock to respond with that xml in n-th request to the mock |
EXAMPLE URL | http://localhost:8080/mock/services/SOAP/dummy-soap-service/operations/dummySoapRequest/responses/2?delay=5 |
HTTP METHOD | PUT |
REQUEST BODY | The response to be returned by mock. |
PARAMETERS |
responseNumber - integer, mandatory - response's serial number delaySec - integer, optional - number of seconds mock response is to be delayed for |
The Verification resources allow to verify requests that reached mock.
DESCRIPTION | Returns recorded requests. |
EXAMPLE URL | http://localhost:8080/mock/services/SOAP/dummy-soap-service/operations/dummySoapRequest/recorded-requests |
HTTP METHOD | GET |
RETURNS | Recorded requests (full SOAP envelopes) enclosed in a <requests> xml tag. |
Exposing WSDL of a mocked service might be usefull for using the mock service with SOAP clients that automatically generate requests basing on WSDL.
Note that WSDL is independent of the mock configuration.
DESCRIPTION | Returns contents of the wsdl file. |
EXAMPLE URL | http://localhost:8080/mock/services/SOAP/dummy-soap-service/wsdl |
HTTP METHOD | GET |
RETURNS | Returns contents of the wsdl file which was defined in ws-mock.properties, SERVICE[i].WSDL property. |
SERVICE[0].NAME=dummy-rest-service SERVICE[0].TYPE=REST SERVICE[0].OPERATION[0].HTTP_METHOD=GET SERVICE[0].OPERATION[0].DEFAULT_RESPONSE=dummy_default_rest_get_response.xml SERVICE[0].OPERATION[0].DEFAULT_RESPONSE_CODE=200 SERVICE[0].OPERATION[1].HTTP_METHOD=POST SERVICE[0].OPERATION[1].DEFAULT_RESPONSE=dummy_default_rest_post_response.xml SERVICE[0].OPERATION[1].DEFAULT_RESPONSE_CODE=201 SERVICE[0].OPERATION[2].HTTP_METHOD=PUT SERVICE[0].OPERATION[2].DEFAULT_RESPONSE=dummy_default_rest_put_response.xml SERVICE[0].OPERATION[2].DEFAULT_RESPONSE_CODE=200 SERVICE[0].OPERATION[3].HTTP_METHOD=DELETE SERVICE[0].OPERATION[3].DEFAULT_RESPONSE=dummy_default_rest_delete_response.xml SERVICE[0].OPERATION[3].DEFAULT_RESPONSE_CODE=200 SERVICE[1].NAME=rest-service-json SERVICE[1].TYPE=REST SERVICE[1].OPERATION[0].HTTP_METHOD=GET SERVICE[1].OPERATION[0].DEFAULT_RESPONSE=dummy_default_rest_get_response.json SERVICE[1].OPERATION[0].DEFAULT_RESPONSE_CODE=200 SERVICE[1].OPERATION[0].DEFAULT_RESPONSE_CONTENT_TYPE=application/json SERVICE[1].OPERATION[1].HTTP_METHOD=POST SERVICE[1].OPERATION[1].DEFAULT_RESPONSE=dummy_default_rest_post_response.json SERVICE[1].OPERATION[1].DEFAULT_RESPONSE_CODE=201 SERVICE[1].OPERATION[1].DEFAULT_RESPONSE_CONTENT_TYPE=application/json SERVICE[1].OPERATION[2].HTTP_METHOD=PUT SERVICE[1].OPERATION[2].DEFAULT_RESPONSE=dummy_default_rest_put_response.json SERVICE[1].OPERATION[2].DEFAULT_RESPONSE_CODE=200 SERVICE[1].OPERATION[2].DEFAULT_RESPONSE_CONTENT_TYPE=application/json SERVICE[1].OPERATION[3].HTTP_METHOD=DELETE SERVICE[1].OPERATION[3].DEFAULT_RESPONSE=dummy_default_rest_delete_response.json SERVICE[1].OPERATION[3].DEFAULT_RESPONSE_CODE=200 SERVICE[1].OPERATION[3].DEFAULT_RESPONSE_CONTENT_TYPE=application/json
Mocked webservice endpoint is available under the following URL:
http://server:port/{APP_CONTEXT}/services/{SERVICE[i].TYPE}/{SERVICE[i].NAME}/endpoint/{RESOURCE_ID}
Parameter | Description |
---|---|
SERVICE[i].TYPE | type of service provided in the config file (here: REST) |
SERVICE[i].NAME | name of service provided in the config file |
RESOURCE_ID | resource id - optional, only for PUT,GET and DELETE methods |
Example:
http://localhost:8080/mock/services/REST/dummy-rest-service/endpoint/id123
Each webservice mock can be controlled with a set of RESTful resources.
Root url context of each of the control resources is:
http://server:port/{APP_CONTEXT}/services/{SERVICE[i].TYPE}/{SERVICE[i].NAME}/operations/{SERVICE[i].OPERATION[j].HTTP_METHOD}
Parameter | Description |
---|---|
SERVICE[i].NAME | name of service provided in the config file |
SERVICE[i].OPERATION[j].HTTP_METHOD | HTTP method - PUT, POST, GET or DELETE |
Example:
http://localhost:8080/mock/services/REST/dummy-rest-service/operations/POST
The control resources of this root context would affect mock of POST method of dummy-rest-service
The Setup Resources allow the user to setup mock's behaviour before each test case is performed.
DESCRIPTION | This resource allows to initialize mock service endpoint and erase previously recorded requests. |
EXAMPLE URL | http://localhost:8080/mock/services/REST/dummy-rest-service/operations/PUT/init |
HTTP METHOD | POST |
DESCRIPTION | Sets up mock response(s). Posting an xml/json string and response code to this resource will cause the mock to respond with that string and response code. If response code is not specified the mock will return the default response code defined in ws-mock.properties for given service and method. Multiple consecutive posts to this resource will set a series of consecutive responses |
EXAMPLE URL | http://localhost:8080/mock/services/REST/dummy-rest-service/operations/POST/responses?code=201 |
HTTP METHOD | POST |
HTTP HEADERS | Content-Type - (optional, default: text/xml) The MIME type of the body of the custom response |
REQUEST BODY | The response to be returned by mock. |
PARAMETERS |
code - valid http code, optional - HTTP response code to be returned by mock delaySec - integer, optional - number of seconds mock response is to be delayed for |
DESCRIPTION | PUTting an xml/json string, response code and request number to this resource will cause the mock to respond with that string and response code to a consecutive request in n-th request to the mock. E.g. if n=3, then the specified response will be returned to 3rd request. If the response code is not specified the mock will return the default response code defined in ws-mock.properties for given service and method. |
EXAMPLE URL | http://localhost:8080/mock/services/REST/dummy-rest-service/operations/POST/responses/3?code=200&delay=3 |
HTTP METHOD | PUT |
HTTP HEADERS | Content-Type - (optional, default: text/xml) The MIME type of the body of the custom response |
REQUEST BODY | The response body to be returned by mock. |
PARAMETERS |
n - integer, mandatory - response's serial number code - valid http code, optional - HTTP response code to be returned by mock delaySec - integer, optional - number of seconds mock response is to be delayed for |
The Verification resources allow to verify requests that reached mock.
DESCRIPTION | Returns recorded requests. |
EXAMPLE URL | http://localhost:8080/mock/services/REST/dummy-rest-service/operations/PUT/recorded-full-requests |
HTTP METHOD | GET |
RETURNS | Full data data about recorded requests enclosed in an xml response. |
DESCRIPTION | Returns recorded request payloads only. |
EXAMPLE URL | http://localhost:8080/mock/services/REST/dummy-rest-service/operations/PUT/recorded-requests |
HTTP METHOD | GET |
RETURNS | Recorded requests payloads in a <recorded-requests> xml tag. |
DESCRIPTION | Returns resource ids that were requested in GET, PUT and DELETE requests. |
EXAMPLE URL | http://localhost:8080/mock/services/REST/dummy-rest/operations/PUT/recorded-resource-ids |
HTTP METHOD | GET |
RETURNS | Recorded resource ids enclosed in a <recorded-resource-ids> xml tag: <recorded-resource-ids> <recorded-resource-id>id123</recorded-resource-id> <recorded-resource-id>id546</recorded-resource-id> </recorded-resource-ids> |
DESCRIPTION | Returns recorded url query params. |
EXAMPLE URL | http://localhost:8080/mock/services/REST/dummy-rest/operations/PUT/recorded-request-params |
HTTP METHOD | GET |
RETURNS | Recorded resource ids enclosed in a <recorded-request-params> xml tag: <recorded-request-params> <recorded-request-param>id123</recorded-request-param> <recorded-request-param>id546</recorded-request-param> </recorded-request-params> |