Using SoapUI for testing your webservice

In my previous post I showed you how you can use Ant and XFire to create a client for your webservice. Another, even nicer and easier way, to test your webservice is to make use of soapUI. This is a free tool (I haven’t used the Pro version yet) with which you can easily create a SOAP request and send them to your webservice and see the repsonse that is send back by the webservice. Beside just sending SOAP requests you can also have executed Groovy scripts with which you can prepare the state of your database for instance, so you can create a full and clean test cycle.
I have installed the standalone version of soapUI version 1.7 which can be downloaded here. After installing it, you can start it and create a new WSDL project:

The WSDL I am pointing to, is the WSDL of the service I deployed in this post. Here is the content of the WSDL:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="" xmlns:ns1="" xmlns:soap11="" xmlns:soap12="" xmlns:soapenc11="" xmlns:soapenc12="" xmlns:tns="" xmlns:wsdlsoap="" xmlns:xsd="" targetNamespace="">
    <xsd:schema targetNamespace="" elementFormDefault="qualified" attributeFormDefault="qualified">
      <xsd:complexType name="ArrayOfBookObject">
          <xsd:element name="BookObject" type="ns1:BookObject" nillable="true" minOccurs="0" maxOccurs="unbounded" />
      <xsd:complexType name="BookObject">
          <xsd:element name="author" type="xsd:string" minOccurs="0" nillable="true" />
          <xsd:element name="isbn" type="xsd:string" minOccurs="0" nillable="true" />
          <xsd:element name="title" type="xsd:string" minOccurs="0" nillable="true" />
    <xsd:schema targetNamespace="" elementFormDefault="qualified" attributeFormDefault="qualified">
      <xsd:element name="myAnswer" type="ns1:ArrayOfBookObject" />
  <wsdl:message name="getBooksRequest" />
  <wsdl:message name="getBooksResponse">
    <wsdl:part element="tns:myAnswer" name="myAnswer" />
  <wsdl:portType name="BookServiceImpl">
    <wsdl:operation name="getBooks">
      <wsdl:input message="tns:getBooksRequest" name="getBooksRequest" />
      <wsdl:output message="tns:getBooksResponse" name="getBooksResponse" />
  <wsdl:binding name="BookServiceHttpBinding" type="tns:BookServiceImpl">
    <wsdlsoap:binding style="document" transport="" />
    <wsdl:operation name="getBooks">
      <wsdlsoap:operation soapAction="urn:getBooks" />
      <wsdl:input name="getBooksRequest">
        <wsdlsoap:body use="literal" />
      <wsdl:output name="getBooksResponse">
        <wsdlsoap:body use="literal" />
  <wsdl:service name="BookService">
    <wsdl:port binding="tns:BookServiceHttpBinding" name="BookServiceHttpPort">
      <wsdlsoap:address location="http://localhost:8080/XFireTest/services/BookService" />

As you can see it is a simple WSDL:
there are no input parameters for the service and it will return a list (array) of bookObjectTypes. After creation of the soapUI project, you directly create tests for your webservice since the checkbox asking to create a SOAP request for each operation was checked. If you double click the request you can see the content of the SOAP request in the main window:

Since my webservice doesn’t have any input parameters, it is very simple request. When we click the green arrow the request is sent and we will see the SOAP response we got back from the server:

<soap:Envelope xmlns:soap="" xmlns:xsd="" xmlns:xsi="">
      <myAnswer xmlns="">
         <ns1:BookObject xmlns:ns1="">
            <author xmlns="">Pascal Alma</author>
            <isbn xmlns="">1313131313</isbn>
            <title xmlns="">XFire Tutorial</title>
         <ns1:BookObject xmlns:ns1="">
            <author xmlns="">Pascal Alma</author>
            <isbn xmlns="">1413135316</isbn>
            <title xmlns="">XFire Advanced</title>

So now we know the webservice is working. To make it a good test case, we need to create a new testsuite in our project and add testcases to it. With these test cases you can send your custom SOAP requests and check the response with asserts. You can do this by right-clicking the BookServiceHttpBinding and choose ‘Generate Testsuite’. You will now get a testsuite with one test case (in my situation). If you expand the Test Steps node and double click at the TestRequestStep getBooks you will see the simple SOAP request again in the main window. But this time you can right-click in the bottom of the window to add assertions:

This way it is not only checking whether the service is reached, but it also checks if the content of the reponse is what you would expect to be returned by the service. This is just a small example of all the things you can do with soapUI but I hope when you play around with it, you will get enthousiastic about the tool as I am.


About Pascal Alma

Pascal is a senior IT consultant and has been working in IT since 1997. He is monitoring the latest development in new technologies (Mobile, Cloud, Big Data) closely and particularly interested in Java open source tool stacks, cloud related technologies like AWS and mobile development like building iOS apps with Swift. Specialties: Java/JEE/Spring Amazon AWS API/REST Big Data Continuous Delivery Swift/iOS
This entry was posted in SoapUI, Web Service and tagged , . Bookmark the permalink.

154 Responses to Using SoapUI for testing your webservice

  1. jayachandra says:

    Hi , I am New to SOAP UI Tool can u explain the functioning of tool and utilisation of tool

  2. Henk Bekkering says:

    I have the same problem. I use SoapUI 3.5, and sometimes I get the soapUI received fatal alert unexpected_message error.

    I have noticed that the certificate is not (completely) correct, the name of the machine is not the name as in the certificate.

    But I have no solution yet 😦

  3. Sabir says:

    Hi Pascal,
    I’m currently using the SOAP UI 3.5 to attach client certificate.
    On the preference tab I did mention the certificate key location.
    Also i did attach the certificate to the web service and gave the password.
    Still i dont see the certificate getting attached to the message header.
    The Web Service throws forbidden error from the server.
    Any suggestion would help

  4. Pascal Alma says:

    I guess you followed these steps:
    otherwise you should check if you forgot a step, because this functionality has worked for me (in older versions).

    I do not have a simple solution for this as I said before. This could have many reasons and I do not known if soapUI is doing something wrong here.
    I guess you are not able to recreate the certificate so that it matches the name of the machine? That would remove one possibility as a reason. And can you supply some more error info, maybe it triggers someone else who has been in the same situation.

Comments are closed.