Running your MockServices from the command-line is equally simple; use the bundled mockrunner.bat/.sh file with the following arguments:
- m : The name of the MockService to run
- p : The local port to listen on, overrides the port configured for the MockService
- a : The local path to listen on, overrides the path configured for the MockService
- b : Turns off blocking when mockRunner has been started, which is required when wanting to run the MockServiceRunner with (for example) nohup or as a Windows Service
- s : The soapui-settings.xml file to use
- x : Sets project password for decryption if project is encrypted
- v : Sets password for soapui-settings.xml file
- D : Sets system property with name=value
- G : Sets global property with name=value
- P : Sets project property with name=value
- S : Saves the project after running the mockService(s)
- f : Sets the output folder to export results to ( ReadyAPI only )
- o : Opens the Coverage Report in a browser (with the -g option) ( ReadyAPI only )
- g : Sets the output to include Coverage HTML reports ( ReadyAPI only )
The distribution contains a mockservicerunner.bat script for running MockServices in the bin directory, for example;
mockservicerunner.bat -m "IOrderService MockService" "C:\Documents and Settings\Ole Matzura\My Documents\demo2-soapui-project.xml"
Runs the specified MockService as follows:
SoapUI SNAPSHOT MockService Runner
15:08:15,515 INFO [SoapUI] Added [file:/C:/workspace/core/ext/mysql-connector-java-5.0.4-bin.jar] to classpath
15:08:16,375 INFO [SoapUI] initialized soapui-settings from [soapui-settings.xml]
15:08:16,406 INFO [WsdlProject] Loaded project from [C:\Documents and Settings\Ole Matzura\My Documents\demo2-soapui-project.xml]
15:08:17,609 INFO [SoapUIMockServiceRunner] Running MockService [IOrderService MockService] in project [demo]
15:08:17,609 INFO [SoapUIMockServiceRunner] Press any key to terminate
15:08:17,953 INFO [MockEngine] Started mockService [IOrderService MockService] on port [8081] at path [/mockIOrderService]
15:08:17,953 INFO [SoapUIMockServiceRunner] MockService started on port 8081 at path [/mockIOrderService]
Progress: 1 - Loading definition from cache
15:09:18,625 DEBUG [WsdlContext] Loading definition from cache
15:09:18,640 DEBUG [WsdlLoader] Returning baseInputSource [http://evitop:8080/OrderServiceImpl?wsdl]
15:09:18,687 DEBUG [WsdlLoader] Returning baseURI [http://evitop:8080/OrderServiceImpl?wsdl] Retrieving document at 'http://evitop:8080/OrderServiceImpl?wsdl'.
15:09:18,796 DEBUG [WsdlContext] Loaded definition: ok
15:09:18,812 INFO [SchemaUtils] Added default schema from /C:/workspace/core/target/classes/xop.xsd with targetNamespace http://www.w3.org/2004/08/xop/include
15:09:18,890 INFO [SchemaUtils] Added default schema from /C:/workspace/core/target/classes/XMLSchema.xsd with targetNamespace http://www.w3.org/2001/XMLSchema
15:09:18,890 INFO [SchemaUtils] Added default schema from /C:/workspace/core/target/classes/xml.xsd with targetNamespace http://www.w3.org/XML/1998/namespace
15:09:18,890 INFO [SchemaUtils] Added default schema from /C:/workspace/core/target/classes/swaref.xsd with targetNamespace http://ws-i.org/profiles/basic/1.1/xsd
15:09:18,890 INFO [SchemaUtils] Added default schema from /C:/workspace/core/target/classes/xmime200505.xsd with targetNamespace http://www.w3.org/2005/05/xmlmime
15:09:18,890 INFO [SchemaUtils] Added default schema from /C:/workspace/core/target/classes/xmime200411.xsd with targetNamespace http://www.w3.org/2004/11/xmlmime
15:09:18,890 WARN [SchemaUtils] Failed to open schemaDirectory [C:\workspace\soapui-pro\schemas]
15:09:18,890 INFO [SchemaUtils] Loading schema types from [http://evitop:8080/OrderServiceImpl?wsdl]
15:09:18,890 INFO [SchemaUtils] Getting schema http://evitop:8080/OrderServiceImpl?wsdl
15:09:18,906 INFO [SchemaUtils] schema for [http://www.example.org/OrderService/] contained [{}] namespaces
15:09:19,359 INFO [SoapUIMockServiceRunner] Handled request 1; [purchase] with [MockResponse 1] in [9ms] at [2007-04-03 15:09:17.968]
15:09:20,734 INFO [SoapUIMockServiceRunner] Handled request 2; [purchase] with [MockResponse 2] in [0ms] at [2007-04-03 15:09:20.734]
15:09:21,296 INFO [SoapUIMockServiceRunner] Handled request 3; [purchase] with [MockResponse 1] in [0ms] at [2007-04-03 15:09:21.296]
15:09:21,937 INFO [SoapUIMockServiceRunner] Handled request 4; [purchase] with [MockResponse 2] in [0ms] at [2007-04-03 15:09:21.937]
15:09:22,343 INFO [SoapUIMockServiceRunner] Handled request 5; [purchase] with [MockResponse 1] in [0ms] at [2007-04-03 15:09:22.343]
Which can now be invoked from soapUI or any other client. Terminate the runner by pressing the return key in the console, which will shutdown as follows:
15:20:30,703 INFO [MockEngine] Stopping connector on port 8081
15:20:30,703 INFO [MockEngine] No more connectors.. stopping server
15:20:30,703 INFO [SoapUIMockServiceRunner] MockService stopped, handled 7 requests
15:20:30,703 INFO [SoapUIMockServiceRunner] time taken: 733117ms