In this example we’ll take a look at using hoverpy when working with SOAP. To run this example, simply execute:

examples/soap/ --capture

which runs the program in capture mode, then:


Which simply runs our program in simulate mode.

This program gets our IP address from, then uses it to do some geolocation using a WDSL SOAP web service. In my case, I’m getting this:

      'Country':u'United Kingdom',

Which is what the ip2geo service thinks is the location of the SpectoLabs office!

from hoverpy import HoverPy
import pysimplesoap
import requests

Above, we bring in our usual suspect libraries. Namely the HoverPy class, pysimplesoap which is a straight forward SOAP client, and the requests library.

from argparse import ArgumentParser

parser = ArgumentParser(description="Perform proxy testing/URL list creation")
parser.add_argument("--capture", help="capture the data", action="store_true")
args = parser.parse_args()

We use argparse so we can run our app in --capture mode first.

with HoverPy(capture=args.capture):

We then construct HoverPy either in capture, or simulate mode, depending on the flag provided.

    ipAddress = requests.get("").json()["ip"]

We then make a get HTTP request to for our IP address. This is very similar to our basic example.


We now tell pysimplesoap to use urllib2, this is because urllib2 happens to play well with proxies.

    client = pysimplesoap.client.SoapClient(

We then build our SOAP client, pointing to the ip2go WSDL schema description URL.

    print(client.ResolveIP(ipAddress=ipAddress, licenseKey="0"))

We finally invoke the ResolveIP method on our SOAP client. So to resume, in this example we built a program that gets our IP address from one external service, and then builds a SOAP client using a WSDL schema description, and finally queries the SOAP service for our location using said IP address.

If you really want to prove to yourself that hoverfly is indeed playing back the requests, then you can run the script in simulate mode without an internet connection. Timing our script also shows us we’re now running approximately 10x faster.