cancel
Showing results for 
Search instead for 
Did you mean: 

Making a live service call from a mock service

Highlighted
New Contributor

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 2
Highlighted
Super Contributor

Re: Making a live service call from a mock service

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
Highlighted
New Contributor

Re: Making a live service call from a mock service

Ole, that definitely put me on the right track, thank you so much!
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors