Enroll in Selenium Training

Let's continue our journey from the previous article "REST Assertions in SoapUI for Rest Services" There we understood the details of various assertions provided by SoapUI, which can just apply to the REST services. In this article, we will cover the details of SOAP Services Assertions in SoapUI which are specific to SOAP services. Major of these assertions fall under the category "Compliance, Status and Standards" in SoapUI. These assertions will be enabled only when you are testing a SOAP service. In this article, we will cover details of all those SOAP specific assertions in the following topics:

  • What are Test specific assertions for SOAP services in SoapUI?
    • What is Not SOAP Fault Assertion in SoapUI?
    • Similarly, what is a SOAP Fault Assertion in SoapUI?
    • What is a SOAP Response Assertion in SoapUI?
    • What is WS-Addressing Response Assertion in SoapUI?
    • Similarly, what is WS-Security Status Response Assertion in SoapUI?
    • What are JMS assertions in SoapUI?

What are SOAP Services Assertions in SoapUI?

There are specific assertions in SoapUI which are applicable only to the SOAP services. Major of these assertions lie under the bucket of “Compliance, Status, and Standards” and shown below:

SOAP service specific assertions in SoapUI

As is evident from the above image, all of these assertions are the validations specific to the SOAP services.

  • For understanding the details of these assertions, we will use the SOAP serviceWSDL: "http://bookstore.toolsqa.com/BookStoreService.wsdl".

  • Add a new project for this SOAP service as per the steps mentioned in the article “SoapUI: Working with Projects“.

  • The sample output of the service will look as below:

<s:Envelope xmlns:xsd="https://www.w3.org/2001/XMLSchema" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns:s="https://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <BooksResponse xmlns="https://tempuri.org/">
         <BooksResult>
            <Books>
               <CustomBookModel>
                  <Isbn>9781449325862</Isbn>
                  <Title>Git Pocket Guide</Title>
                  <SubTitle>A Working Introduction</SubTitle>
                  <Author>Richard E. Silverman</Author>
                  <Published>2013-08-02T00:00:00</Published>
                  <Publisher>O'Reilly Media</Publisher>
                  <Pages>234</Pages>
                  <Description>This pocket guide is the perfect on-the-job companion to Git, the distributed version control system. It provides a compact, readable introduction to Git for new users, as well as a reference to common commands and procedures for those of you with Git experience.</Description>
                  <Website>http://chimera.labs.oreilly.com/books/1230000000561/index.html</Website>
               </CustomBookModel>
               <CustomBookModel>
                  <Isbn>9781449331818</Isbn>
                  <Title>Learning JavaScript Design Patterns</Title>
                  <SubTitle>A JavaScript and jQuery Developer's Guide</SubTitle>
                  <Author>Addy Osmani</Author>
                  <Published>2012-07-01T00:00:00</Published>
                  <Publisher>O'Reilly Media</Publisher>
                  <Pages>254</Pages>
                  <Description>With Learning JavaScript Design Patterns, you'll learn how to write beautiful, structured, and maintainable JavaScript by applying classical and modern design patterns to the language. If you want to keep your code efficient, more manageable, and up-to-date with the latest best practices, this book is for you.</Description>
                  <Website>http://www.addyosmani.com/resources/essentialjsdesignpatterns/book/</Website>
               </CustomBookModel>
               <CustomBookModel>
                  <Isbn>9781449337711</Isbn>
                  <Title>Designing Evolvable Web APIs with ASP.NET</Title>
                  <SubTitle>Harnessing the Power of the Web</SubTitle>
                  <Author>Glenn Block et al.</Author>
                  <Published>2014-04-07T00:00:00</Published>
                  <Publisher>O'Reilly Media</Publisher>
                  <Pages>538</Pages>
                  <Description>Design and build Web APIs for a broad range of clients—including browsers and mobile devices—that can adapt to change over time. This practical, hands-on guide takes you through the theory and tools you need to build evolvable HTTP services with Microsoft’s ASP.NET Web API framework. In the process, you’ll learn how design and implement a real-world Web API.</Description>
                  <Website>http://chimera.labs.oreilly.com/books/1234000001708/index.html</Website>
               </CustomBookModel>
               <CustomBookModel>
                  <Isbn>9781449365035</Isbn>
                  <Title>Speaking JavaScript</Title>
                  <SubTitle>An In-Depth Guide for Programmers</SubTitle>
                  <Author>Axel Rauschmayer</Author>
                  <Published>2014-02-01T00:00:00</Published>
                  <Publisher>O'Reilly Media</Publisher>
                  <Pages>460</Pages>
                  <Description>Like it or not, JavaScript is everywhere these days-from browser to server to mobile-and now you, too, need to learn the language or dive deeper than you have. This concise book guides you into and through JavaScript, written by a veteran programmer who once found himself in the same position.</Description>
                  <Website>http://speakingjs.com/</Website>
               </CustomBookModel>
               <CustomBookModel>
                  <Isbn>9781491904244</Isbn>
                  <Title>You Don't Know JS</Title>
                  <SubTitle>ES6 &amp; Beyond</SubTitle>
                  <Author>Kyle Simpson</Author>
                  <Published>2015-12-27T00:00:00</Published>
                  <Publisher>O'Reilly Media</Publisher>
                  <Pages>278</Pages>
                  <Description>No matter how much experience you have with JavaScript, odds are you don’t fully understand the language. As part of the "You Don’t Know JS" series, this compact guide focuses on new features available in ECMAScript 6 (ES6), the latest version of the standard upon which JavaScript is built.</Description>
                  <Website>https://github.com/getify/You-Dont-Know-JS/tree/master/es6%20&amp;%20beyond</Website>
               </CustomBookModel>
               <CustomBookModel>
                  <Isbn>9781491950296</Isbn>
                  <Title>Programming JavaScript Applications</Title>
                  <SubTitle>Robust Web Architecture with Node, HTML5, and Modern JS Libraries</SubTitle>
                  <Author>Eric Elliott</Author>
                  <Published>2014-07-01T00:00:00</Published>
                  <Publisher>O'Reilly Media</Publisher>
                  <Pages>254</Pages>
                  <Description>Take advantage of JavaScript's power to build robust web-scale or enterprise applications that are easy to extend and maintain. By applying the design patterns outlined in this practical book, experienced JavaScript developers will learn how to write flexible and resilient code that's easier-yes, easier-to work with as your code base grows.</Description>
                  <Website>http://chimera.labs.oreilly.com/books/1234000000262/index.html</Website>
               </CustomBookModel>
               <CustomBookModel>
                  <Isbn>9781593275846</Isbn>
                  <Title>Eloquent JavaScript, Second Edition</Title>
                  <SubTitle>A Modern Introduction to Programming</SubTitle>
                  <Author>Marijn Haverbeke</Author>
                  <Published>2014-12-14T00:00:00</Published>
                  <Publisher>No Starch Press</Publisher>
                  <Pages>472</Pages>
                  <Description>JavaScript lies at the heart of almost every modern web application, from social apps to the newest browser-based games. Though simple for beginners to pick up and play with, JavaScript is a flexible, complex language that you can use to build full-scale applications.</Description>
                  <Website>http://eloquentjavascript.net/</Website>
               </CustomBookModel>
               <CustomBookModel>
                  <Isbn>9781593277574</Isbn>
                  <Title>Understanding ECMAScript 6</Title>
                  <SubTitle>The Definitive Guide for JavaScript Developers</SubTitle>
                  <Author>Nicholas C. Zakas</Author>
                  <Published>2016-09-03T00:00:00</Published>
                  <Publisher>No Starch Press</Publisher>
                  <Pages>352</Pages>
                  <Description>ECMAScript 6 represents the biggest update to the core of JavaScript in the history of the language. In Understanding ECMAScript 6, expert developer Nicholas C. Zakas provides a complete guide to the object types, syntax, and other exciting changes that ECMAScript 6 brings to JavaScript.</Description>
                  <Website>https://leanpub.com/understandinges6/read</Website>
               </CustomBookModel>
            </Books>
         </BooksResult>
      </BooksResponse>
   </s:Body>
</s:Envelope>
  • Add a new TestCase to the same using the steps mentioned in the article “Creating and Structuring TestCases in SoapUI“.
  • Click on the (+) icon on the Assertions tab at the bottom of the SOAP service TestStep screen to add a new assertion as per the steps mentioned in the article "Understanding Assertions in SoapUI".

We will perform all our validations for the SOAP-based assertions on the above-mentioned response of the SOAP service.

Let’s understand the details of all these assertion types in the following sections:

What is Not SOAP Fault Assertion in SoapUI?

A SOAP fault is an error in a SOAP (Simple Object Access Protocol) communication, which can result from either an incorrect message format, header-processing problems, or incompatibility between applications.

This assertion will validate that no fault has occurred during the invocation of the SOAP service. Let’s follow the steps mentioned below to understand how to use the “Not SOAP Fault ” assertion:

  1. In the "Add Assertion" dialogue box, under the "Compliance, Status and Standards" category, select "Not SOAP Fault" assertion as shown below:

Add Not SOAP Fault Assertion in SoapUI

  1. Click on the "Add" button, and it will automatically run the validation on the last response of the service. In our scenario, as the service has returned a valid SOAP response with no SOAP fault, so the assertion will pass and will show the response as shown below:

Not SOAP Fault Assertion in SoapUI

  1. So, we have successfully added one assertion on the SOAP service, which validates that no fault has occurred while invoking the SOAP service.

What is a SOAP Fault Assertion in SoapUI?

As opposed to the "Not SOAP Fault" assertion, the "SOAP Fault" will check for the existence of a SOAP fault in the SOAP service response. So, if there is no fault, this assertion will fail.

Let’s follow the steps mentioned below to understand how to use the “SOAP Fault ” assertion:

  1. Once you navigate to the "Add Assertion" dialogue box, click on the "SOAP Fault" assertion under the "Compliance, Status and Standards" category as shown below:

Add SOAP Fault Assertion in SoapUI

  1. Click on the "Add" button, and it will automatically run the validation on the last response of the service. In our scenario, as the service has returned a valid SOAP response with no SOAP fault, so the assertion will fail and will show the response as shown below:

SOAP Fault assertion failure

  1. So, we have successfully added another assertion on the SOAP service, which validates that the fault has occurred while invoking the SOAP service and fails because, in actual, no SOAP fault occurred while invoking the SOAP service.

What is SOAP Response Assertion in SoapUI?

As the name suggests, this assertion checks whether the response is a valid SOAP response or not. When I say a valid SOAP response, it means that it is compliant to all Simple Object Access Protocol (SOAP) standards. e.g., As we can see, the response of the bookstore web-service (as shown above) is wrapped in an envelope (<s: Envelope>), as mandated by the SOAP protocol.

Let’s follow the steps mentioned below to understand how to use the “SOAP Response” assertion in SoapUI:

  1. Once you navigate to the "Add Assertion" dialogue box, click on the "SOAP Response" assertion under the "Compliance, Status and Standards" category as shown below:

Add SOAP Response Assertion in SoapUI

  1. Click on the "Add" button, and it will automatically run the validation on the last response of the service. In our scenario, as the service has returned a valid SOAP response as per the SOAP standards, so the assertion will pass and will show the response as shown below:

SOAP response assertion validation in SoapUI

  1. So, we have successfully added another assertion on the SOAP service, which validates that the SOAP service response is valid as per the SOAP standards and passes because the response returned by the bookstore service is a valid SOAP response.

What is WS-Addressing Response Assertion in SoapUI?

The WS-Addressing Response assertion validates the WS-Addressing Headers in the response. When importing a WSDL, SoapUI will try to extract WS-Addressing related information from it. If detected, WS-Addressing will automatically enable contained requests with the correct version and headers set. A sample SOAP service response, including the WS-Addressing in the SOAP header, will look as follows:

<S:Envelope
    xmlns:S="https://www.w3.org/2003/05/soap-envelope"
    xmlns:wsa="https://schemas.xmlsoap.org/ws/2004/08/addressing">
    <S:Header>
        <wsa:MessageID>
uuid:6B29FC40-CA47-1067-B31D-00DD010662DA
</wsa:MessageID>
        <wsa:ReplyTo>
            <wsa:Address>http://business456.example/client1</wsa:Address>
        </wsa:ReplyTo>
        <wsa:To>http://fabrikam123.example/Purchasing</wsa:To>
        <wsa:Action>http://fabrikam123.example/SubmitPO</wsa:Action>
    </S:Header>
    <S:Body>
 ...
</S:Body>
</S:Envelope>

Let’s follow the steps mentioned below to understand how to use the “WS-Addressing Response” assertion in SoapUI:

  1. Once you navigate to the "Add Assertion" dialogue box, click on the "WS-Addressing Response" assertion under the "Compliance, Status and Standards" category as shown below:

Add WS Addressing Response Assertion in SoapUI

  1. Once you click on the "Add" button, you shall see the dialogue box as shown below:

Dialog showing WS A properties Assertion in SoapUI

  1. Choose the type of assertion you want to use by selecting the checkboxes and click OK. Each of these checkboxes validates the existence of the mentioned tags in the SOAP response header. In our scenario, as the service doesn't contain the WS-Addressing headers, so the assert will fail and will show the response as below:

WS Adressing Response validation failure in SoapUI

  1. So, we have successfully added another assertion on the SOAP service, which validates that the SOAP service response header contains the WS-Addressing header and fails because the response returned by the bookstore service doesn't contain any WS-Addressing headers.

What is WS-Security Status Response Assertion in SoapUI?

The Web Services Security or WS-Security is a specification that explains how security measures implement in web services. It is a set of protocols that make sure security for SOAP-based messages by implementing the principles of confidentiality, integrity, and authentication.

SoapUI gives us an assertion to automatically validate secured responses. WS-Security Status assertion can validate that the last received message contains a valid WS-Security header.

Let’s follow the steps mentioned below to understand how to use the “WS-Security Status” assertion in SoapUI:

  1. Once you navigate to the "Add Assertion" dialogue box, click on the "WS-Security Status" assertion under the "Compliance, Status and Standards" category as shown below:

Add WS Security Status assertion in SoapUI

  1. Click on the "Add" button, and it will automatically run the validation on the last response of the service. In our scenario, as the service doesn't contain a header for WS-Security, the assertion will fail and will show the response as below:

WS Security assertion validation in SoapUI

  1. So, we have successfully added another assertion on the SOAP service, which validates that the SOAP service response header contains the WS-Security header and fails because the response returned by the bookstore service doesn't contain any WS-Security headers.

What are JMS assertions in SoapUI?

Apart from the assertion as mentioned above types, the JMS assertions enable the SOAP services only. The JMS(Java Messaging Service) comes into the picture while sending messages between two or more clients. It helps communication to be more reliable and asynchronous. JMS is also a standard that allows application based on JEE to create, send, receive, and read the message. The JMS API supports two different models :

  • Point to Point
  • Publish and subscribe

SoapUI integrates/ combines with the HermesJMS open-source application, which supports many various JMS providers. It gives support for Java messaging Service, allowing you to send and receive both text and binary messages.

You can configure, HermesJMS in your SoapUI at the time of installation and then can validate for the time and status of the message with the help of following two assertions provided by SoapUI:

  • JMS Timeout
  • JMS Status.

Let’s follow the steps mentioned below to understand how to use the “JMS ” assertion in SoapUI:

  1. Once you navigate to the "Add Assertion" dialogue box, click on the "JMS Timeout" assertion under the "JMS" category as shown below:

Add JMS Assertion in SoapUI

  1. Click on "Add" button, and it will show the following dialogue box for configuration of JMS timeout

JMS assertion

  1. Enter the value as per your service's response time. Click OK to add it. As the BookStore API does not use any JMS related endpoint, it will fail for this scenario.

  2. Similar to the  JMS Timeout, you can add the "JMS status" assertion also. It helps in the validation of the status of the JMS. As the BookStore API does not have any JMS related endpoint, so no message communication happening and hence considers the assertion as passed. You will see the following assertion validation screen after adding both of the JMS specific validations:

JMS assertions view in SoapUI

  1. So, we have successfully added JMS specific assertions, which enable in SoapUI only for the SOAP services.

Therefore, this completes the details of all the SoapUI assertions, which we can apply for the validation of the response of SOAP Webservices only.

Key Takeaways

  • SoapUI provides categories of assertions which are applicable only for the REST services.
  • The SOAP Fault assertions validate the presence of a Fault in the SOAP response
  • The SOAP Response assertions validate the response of SOAP service against the SOAP standards.
  • The WS-Addressing and WS-Security Status assertions validate the presence of <wsa> headers in the SOAP response.
  • The JMS specific assertions validate the timeout and status of a JMS based endpoint of the SOAP service.

Let's move to the next article where we will cover the details of a few of the "Common assertions which are applicable for both SOAP and REST services".

SoapUI - REST Assertions
SoapUI - REST Assertions
Previous Article
SoapUI Common Assertions
SoapUI Common Assertions
Next Article

Similar Articles

Feedback