Forum Discussion

Leinad_Andson's avatar
Leinad_Andson
New Contributor
16 years ago

Making a live service call from a mock service

Hi,

Is there a way for me to use a mock webservice to capture a SOAP request, and then basically forward that request to the actual live web service and then capture the SOAP response and send that back to the service the called the mock webservice (i.e. make the mock webservice basically act as a proxy but it would be saving the requests and responses)?  I have the part done where I can capture and save the request that comes in, it's the second part I am mainly curious about.

Best regards, Thank you!

2 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi Leinand,

    sure! You can submit an existing request in your project with its submit(..) method and then await the response before returning it.. all this could be done in the Script associated with the MockResponse.. something like the following:

    // get request to submit
    def request = context.mockService.project.interfaces[".."].operations[".."].requests[".."]

    // set content and other properties (headers, attachments, endpoint, etc..)
    request.requestContent = mockRequest.requestContent

    // submit synchronously
    request.submit( new WsdlSubmitContent( request ), false )

    // get response
    context.responseContent = request.response.contentAsString

    ..

    And then in the mockResponse content editor just put

    ${responseContent}

    Which should be replaced by the corresponding context variable assigned in the last statement in the script above..

    This should get you going.. let me know otherwise!

    regards,

    /Ole
    eviware.com