How to attach ssl certificates to response using Groovy script
Hi,
I am trying to connect a web service using Groovy script which is happening successfuly and I am getting soap message back.However, I am not getting how to attach in incoming ssl certificates to in my response object. I am using following script.
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ) def soapUrl = new URL("https://xxxxxxxxxxxxx") def connection = soapUrl.openConnection() connection.setRequestMethod("POST") connection.setRequestProperty("Accept-Encoding" ,"gzip,deflate") connection.setRequestProperty("Content-Type" ,"text/xml;charset=UTF-8") connection.setRequestProperty("SOAPAction", "xxxxxxxxxxxxxxxx") connection.doOutput = true def soapRequest = mockRequest.getRequestContent() writer.write(soapRequest) writer.flush() writer.close() connection.setConnected(true) connection.connect() def soapResponse = connection.content.text requestContext.responseMessage = soapResponse connection.disconnect()
As this script was meant for the default mock responses which access actual web service in case we have requests other than the mocked ones, I created a keystore locally and imported the client certificates in cacerts in /java/jdk/jre/lib/security/.
Then in preferences->ssl settings, I pointed my 'keystore', 'mock keystore' and 'mock truststore' to my local keystore. Also enabled mock ssl. Its not mandatory to use 8443 as mock port as advised everywhere on net, I just used port 9443 and it worked.
Make sure to call your mock service over https instead http.