Forum Discussion

Siemens__s_r_o_'s avatar
Siemens__s_r_o_
Occasional Contributor
10 years ago

Programmatically retrieveing SOAP request from a MockService (not from OnRequest script)

Hi guys,

 

I'm trying to get a Request object (see the image1.png below) from a MockService.

This woudln't be a problem to do if I was in the context of the running MockService, where it's easily available in the OnRequest script.

image1.png

 

However, due to the structure of our tests, I needs to access the Request object from a Script TestStep.

Since it's available in the UI and I'm working directly with the object model, I believe it must be possible to do this, but even after quite thorough research of the API docs, I was unable to to achieve what I need :(

 

I think it should be available either from the WsdlMockService or the WsdlMockRunner object (although the request list persists atfer the mock service is stopped, so MockRunner is probably a wrong direction...).

Here is a code snippet which I started with:

import com.eviware.soapui.impl.wsdl.WsdlTestSuite;
import com.eviware.soapui.impl.wsdl.WsdlProject;
import com.eviware.soapui.impl.wsdl.mock.WsdlMockService;
import com.eviware.soapui.impl.wsdl.mock.WsdlMockRunner

WsdlTestSuite testSuite = testRunner.runContext.testCase.testSuite;
WsdlProject project = testSuite.project;

WsdlMockService mockService = project.getMockServiceByName("mockServiceName");
WsdlMockRunner mockRunner = mockService.getMockRunner();

Now, I guess I should go somewhere from the "mockService" object.

Do you have any idea where?

 

Thanks :)

 

Jakub

 

//Edit: obviously, I need to get hold of the MessageExchange object. I'll try to go there and update if I succeed :)

4 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3

    Please check this link and see that is what you are look for? 

    • Siemens__s_r_o_'s avatar
      Siemens__s_r_o_
      Occasional Contributor

      Hi Rao,

       

      Unfortunately, these are not the droids we are looking for :(

       

      The link you posted describes handling the request from the MockService side. If this was possible in our environment, it would be quite easy, as the MockService provides the 'mockRequest' object directly available in the OnRequest.

       

      There are several reasons why we cannot handle requests from the mockservice:

      - the mockservice is not being triggered as a part of the TestCase, it's running independently

      - we don't know which test step will require to access the request's content, so we cannot inject it into a TestCase context from within the OnRequest Script of the MockService

      - we cannot create a DB which would hold the requests and responses, as it's deployed on the customer's system

       

      I've managed to access the context object of the MockService from within a TestStep script and while this wouls allow me to save each request into the context, it's not a good solution, as the context would grow really big with a large amount of requests.

       

      In short, I need to access the Request content on a MockService from within a TestStep Script, not from the OnRequest Script of the MockService.

       

      Jakub

      • Siemens__s_r_o_'s avatar
        Siemens__s_r_o_
        Occasional Contributor

        Actually, it seems I'm trying to to somthing very similar to larsn here (link doesn't seem to be working, see the post in the old forums), but the link provided there doesnt help, as it deals with the MessageExchage object in context of an assertion script.

         

        //edit with a link to old forums