Forum Discussion

Cybele's avatar
Cybele
Occasional Contributor
13 years ago

Mock service calling another webservice

I'm using SoapUI (v 4.5.1) to create a mock service for one of my webservices. The original service to be mocked calls a second webservice as part of the functionality. Can this additional call be done in a mock service?

Thanks in advance for any advice.
  • Cybele's avatar
    Cybele
    Occasional Contributor
    astafev wrote:
    I think, you shoul use Groovy for this.

    Could you point me towards any examples, please? Thanks.
  • astafev's avatar
    astafev
    Occasional Contributor
    This worked for me:
    com.eviware.soapui.model.testsuite.TestStepResult  testResult = testRunner.runTestStepByName("FlcApply");
    log.info(testResult.getResponseContent())
  • Cybele's avatar
    Cybele
    Occasional Contributor
    astafev wrote:
    This worked for me:
    com.eviware.soapui.model.testsuite.TestStepResult  testResult = testRunner.runTestStepByName("FlcApply");
    log.info(testResult.getResponseContent())

    I'm sorry, but I not sure how this is related to what I want to achieve. I need to call another web service from within my mock service - it's not related to a test suite at all.

    Thanks.
  • astafev's avatar
    astafev
    Occasional Contributor
    In MockService you can use variable mockRunner to get to WsdlProject, than use it.
    import com.eviware.soapui.impl.wsdl.*

    WsdlProject proj = mockRunner.getMockService().getProject();
    for(WsdlTestSuite suite : proj.getTestSuiteList())
    {
    log.info(suite.getLabel())
    //use this runner
    com.eviware.soapui.model.testsuite.TestSuiteRunner runner = suite.run((com.eviware.soapui.support.types.StringToObjectMap)context, true)
    log.info(runner.getClass())
    }

    Sorry, but i don't have more time to extend this example...
    Or, you can use Apache HttpClient v4.1 right from groovy script (i think so, i only saw that classes are available) if you don't want to work with TestSuites).