Download Trial - Free 14 day evaluation

Securing MockServices with SSL

PDF Print E-mail
User Rating:  / 43
Rate this article: PoorBest 

The MockService functionality in soapUI is a simple way to quickly get a working simulation of your Web Service up and running in seconds. Even better, you can secure it with SSL to be sure your client handles this correctly. Check out this mini-tutorial to get going.

Create a new soapUI Project for the Currency Converter WSDL available at http://www.webservicex.net/CurrencyConvertor.asmx?WSDL. In the "New Project" dialog be sure to select the "Generate Web Service Simulation" option:

create-project

After churning a bit, soapUI will have imported the WSDL and then prompt for the MockService creation:

create-mockservice

Make sure to select the "Add Endpoint" and "Start MockService" options and press OK; soapUI will show the same dialog again for the second binding (the SOAP 1.2 version) but lets just cancel that to avoid too much confusion. After this soapUI will create and start the MockService for the SOAP 1.1 Binding as specified; If you now open the default request created for the ConversionRate request and change the endpoint to the preconfigured one pointing at the local MockService, you'll get the following result:

default-request

(The response being the default MockResponse generated by the MockService Wizard)

Ok.. lets rush ahead.. to secure this MockService via SSL, we first need to generate a keystore with a private and public key; we'll use the command-line keytool for this. Open a command-prompt and navigate to the java bin folder (which you might have to install by installing the jdk from http://java.sun.com).

We need to start by generating a keystore containing our private/public keypair, type something like

c:\java\jdk1.6.0_14\bin\keytool -genkey -alias soapui -keyalg RSA -keystore .keystore

at the prompt (set the -keystore argument to where you want the keystore saved). You will be prompted for a bunch of input before the .keystore is actually created. My session went as follows:

create-keystore

Now back to soapUI; configure the global SSL Preferences as follows (be sure to specify the same password you used everywhere above):

ssl-prefs

Now go back to your request and edit the endpoint to use https instead:

ssl-endpoint

and presto: you get an encrypted request/response (although you can't see the actual encrypted version here in soapUI.. SSL is on the transport level).

Enjoy!