sudo bash /{{SoapUI-Root}}/bin/mockservicerunner.sh -Dsoapui.mock.connector.headerBufferSize=16000 {{url-or-path-to-project-xml}}
Example :
- sudo bash /apps/soapUI/SoapUI-5.4.0/bin/mockservicerunner.sh -Dsoapui.mock.connector.headerBufferSize=16000 https://mock.awshost.io/soapUI/Projects/mock-xyz-soapui-project.xml &
- sudo bash /home/namal/Fun/soapui/SoapUI-5.6.0/bin/mockservicerunner.sh -Dsoapui.mock.connector.headerBufferSize=16000 /home/namal/Fun/soapui/test-mock/Project-1-soapui-project.xml
Match response based on request body

def requestBody = mockRequest.getRequestContent()
log.info "Request body: " + requestBody
if( requestBody.contains("reschedule") ){
return "Reschedule POST res"
}
else if( requestBody.contains("cause") ){
return "Cancel Response"
}else if( requestBody.contains("amendendusertype") ){
return "Ammend-EndUser-POST"
}
Calling TestSuit within MockService

OnRequest Script
import com.eviware.soapui.support.types.StringToStringMap
import java.net.URL
import groovy.json.JsonSlurper
def authtoken = ""
def post = new URL("https://keycloak.awshost.io/auth/realms/cossmos/protocol/openid-connect/token").openConnection()
def message = 'grant_type=password&client_id=xyzClient&username=xyz&password=123456&client_secret=dsa213-4gfd-5645fds42423-324das'
post.setRequestMethod("POST")
post.setDoOutput(true)
post.setRequestProperty("Content-Type", "application/x-www-form-urlencoded")
post.getOutputStream().write(message.getBytes("UTF-8"))
def postRC = post.getResponseCode()
if(postRC.equals(200)) {
def resp = post.getInputStream().getText()
def json = new JsonSlurper().parseText(resp)
authtoken = json.'access_token'
log.info("Call back authToken retrieved!");
}else{
log.info("Call back authToken not retrieved!")
}
context.setProperty("authtoken","bearer " + authtoken)
def callbackEp = mockRequest.getRequestHeaders().get("callback-ep-uri").get(0).toString()
context.setProperty("callback-ep-uri",callbackEp)
AfterRequest Script
import com.eviware.soapui.support.GroovyUtils
import com.eviware.soapui.support.types.StringToObjectMap
import com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep
import com.eviware.soapui.support.types.StringToStringMap
def groovyUtils = new GroovyUtils( context )
def headers = new StringToStringMap()
if(mockResult != null){
def requestContent=mockResult.getMockRequest().requestContent;
def requestBody = new groovy.json.JsonSlurper().parseText(requestContent)
def map = new StringToObjectMap()
def authtoken = context.getProperty("authtoken")
def callbackEndpoint = context.getProperty("callback-ep-uri")
def testsuite = context.mockService.project.getTestSuiteByName("MagnifyDiagnosticTestsuite")
def testcaseName = null;
def actualExtId = null;
if(requestBody.cause != null){
testcaseName = "AppointmentCancel"
}else if(requestBody.externalId.contains("reschedule")){
testcaseName = "ApppointmentReschedule"
}else{
testcaseName = "AppointmentCallbackAsyncMessages"
}
if(requestBody.externalId.contains("-::") ){
actualExtId = requestBody.externalId.split('-::')
}
def testcase = testsuite.getTestCaseByName(testcaseName)
if(actualExtId != null){
testcase.setPropertyValue( "externalId", actualExtId[0] )
}else{
testcase.setPropertyValue( "externalId", requestBody.externalId )
}
headers.put("Authorization",authtoken)
headers.put("Content-Type","application/json")
headers.put("NBN-ConversationID","unique-identifier")
headers.put("NBN-APIVersion","test-version")
headers.put("NBN-RSPSecurityToken","securityTokenValue")
headers.put("NBN-TransactionID","transaction-id")
def teststep = testcase.getTestStepsOfType(RestTestRequestStep.class)
teststep.eachWithIndex(){ step, index ->
teststep.get(index).testRequest.setEndpoint(callbackEndpoint)
teststep.get(index).testRequest.setRequestHeaders(headers)
}
testcase.run(map, true) //true here means call asynchronously i.e. dont wait to the TestCase to finish first
}