Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a mock web service from a WSDL file in Python

We are writing a client for a remote service that exposes SOAP web services and publishes a WSDL definition for those services.

We don't have access to the system during testing, so we'd like to write a mock service. We're using Python for the client, so ideally we'd want to use Python for the mock server, although I suppose it's not strictly necessary.

The dream would be to be able to generate stubs from the WSDL file which we could fill in, and then serve those using Paste Deploy as a WSGI server, although it doesn't have to be Paste Deploy or WSGI so long as it works reliably. The main thing is that we need to be generating the stubs from the "real" WSDL file so that we don't accidentally write a non-compliant mock server.

We're using suds for the client side library, and have looked at soaplib and ZSI. However, the wsgi2py stuff in soaplib says "do not use" at the top and ZSI seems like a lot to swallow. What do people generally use for this kind of thing?

Martin

like image 680
optilude Avatar asked Jan 25 '10 09:01

optilude


2 Answers

As a mock server I would really recommend soapUI (http://www.soapui.org).

It takes a WSDL and generates the services and service methods automatically. You can then go on and define static returns or dynamic ones using Groovy scripts. Take a look here for the documentation of web service mocking.

soapUI comes in a free and paid pro version. I have used the free version with great success.

like image 125
spa Avatar answered Oct 19 '22 09:10

spa


I would recommend you use soapUI for creating a mock service. It's very easy to install. It's just as easy to create a WS mock service. It takes the WSDL file from your desired location, it creates the structure for the requests and if you wish, it also creates the mock web service with the intended structure drawn from the WSDL file. When you create the new soapUI project, select the third checkbox option to create the mock web service.

If xsd schema files are required, make sure they are well referenced from the WSDL file.

It doesn't use python but if all you need is a test environment that you can send requests and get responses, that will be more than enough.

I hope that helps.

like image 6
Lucas T Avatar answered Oct 19 '22 09:10

Lucas T