Forum Discussion

dseel's avatar
dseel
Contributor
14 years ago

Mock Service For HEAD Operations

Hi:

I'd like to be able to create a Mock service to handle REST HEAD requests and be able to customize the response in an OnRequest script. Currently the Mock Engine responds to all HEAD requests with a 200 response code instead of processing the request in the OnRequest script.

Tested with SOAPUI Pro 3.5.1 and 3.6 beta 2.

Thanks,
Dave

2 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi Dave,

    the following dispatch-script worked fine for me:

    if( mockRequest.method == "HEAD" )
    {
    log.info "Got HEAD Request"
    mockRequest.httpResponse.status = 201
    return new com.eviware.soapui.impl.wsdl.mock.WsdlMockResult( mockRequest )
    }

    remember you need to return a MockResult from the handler, otherwise the request will be dispatched internally.

    regards!

    /Ole
    evwiare.com