Skip to content

Iptv Assist

Learn More from us

Menu
  • HOW TO
  • Firestick
  • Chromecast
  • PC Apps
  • Lg Smart TV
  • IPTV Services
  • Automation Testing
  • Smart TV
  • Software Testing Tools
  • Contact Us
Menu

How to Create Mock Service and Dynamic Response in SoapUI

Posted on March 26, 2023

Best Iptv Service Provider 2023 With 40k+ Channels And 100k+ VOD . 24/7 Suppport . Paypal Supported

In this tutorial, we will cover all about mock services. You will learn:

Best Iptv Service Provider 2023 With 40k+ Channels And 150k+ VOD . Hurry Up

  • What is a mock service and why is it required?
  • How to create a mock service in SOAPUI?
  • What is mock operation and a dynamic mock response?
  • Understanding mock operation and dispatch methods with an example.
  • Scripting for Mock Response.

What You Will Learn:

  • Mock Service:
  • Mock Operation and Dynamic mock responses:
  • Understanding Dispatch Methods:
  • Scripting for Mock Response:
  • Conclusion:

Mock Service:

Mocking a web service will help simulate a response to the request of a web service. It is a very effective tool for testing web services offline while building and evaluating them.

Recommended IPTV Service Providers

  1. IPTVGREAT – Rating 4.8/5 ( 600+ Reviews )
  2. IPTVRESALE – Rating 5/5 ( 200+ Reviews )
  3. IPTVGANG – Rating 4.7/5 ( 1200+ Reviews )
  4. IPTVUNLOCK – Rating 5/5 ( 65 Reviews )
  5. IPTVFOLLOW -Rating 5/5 ( 48 Reviews )
  6. IPTVTOPS – Rating 5/5 ( 43 Reviews )

 

SoapUI Mock Service

Recommended read => 15+ Best SoapUI tutorials

The following are the steps in SOAPUI to create a project using web service WSDL and create a mock service of it.

For simplicity, I have used a sample WSDL in this tutorial:

#1) Create a soap project using the following WSDL:
http://www.webservicex.com/globalweather.asmx

(Note: Click on any image for enlarged view)

new-soapui-project

#2) Select ‘Generate MockService’ option by right-clicking on the project name.

generate-mock-service-option

generate-mock-service-option-1

#3) In MockService dialog box, options are available to change the port number and host name.

change-the-port-number-and-host-name

#4) Default response is created in the Mock Service.

default-response

#5) Start mock service.

start-mock-service

#6) Open the WSDL service in a browser.

open-the-wsdl-service

#7) WSDL of mock service will look like below in the browser:

wsdl-of-mock-service

#8) Copy the WSDL service URL and use it as the New EndPoint to send a request to the mock service.

new-end-point

new-end-point-1

#9) Submit Request to the newly added endpoint to receive a response from the Mock Service.

Mock Operation and Dynamic mock responses:

Once the request is received by a mock service, it will transfer it to the mock operation. Mock operation then selects the correct response from the list of responses and delivers it back to the web service.

1) We can add one more mock response and set a dynamic response based on the request/query or send a response either in sequence or randomly.

2) To add a new mock response, right click on the mock operation and select New Mock Response.

new-mock-response

3) Now in New Mock Response2, you can create soap fault response, if required.

soap-fault-response

4) Double clicking on the mock operation will open configuration panel which provides ways to set dynamic responses

set-dynamic-responses

Understanding Dispatch Methods:

In Configuration panel, by selecting the dispatch method we can set a dynamic response

Let’s see various dispatch methods:

SCRIPT: Using script we can set a dynamic response based on the contents of a request.

See the following example:

set-dynamic-response

In the Script method, use a Groovy script to read the request contents and extract the value of a specific node. See the following script example where the result response changes depending on the input request value.

import javax.xml.xpath.*
import groovy.xml.StreamingMarkupBuilder
import groovy.lang.Binding;
import groovy.lang.Script;
def util = new com.eviware.soapui.support.GroovyUtils( context )
def xml = new XmlSlurper().parseText(mockRequest.requestContent) 
def country = xml.Body.GetCitiesByCountry.CountryName
def str = country.toString()
log.info str
def len = str.size()
log.info len
if(len > 1 ) 
{
 context.ResultResponse = "Response1"
 log.info "r1"
}
else if(len <= 1)
{ 
 context.ResultResponse="InvalidMockResponse 2"
 log.info "r2"
}

SEQUENCE: This is a simple way of sending responses. Responses will be sent in a sequence i.e. first query first response, next query next response, etc.

QUERY_MATCH:  Query can be a little complex dispatch method. In this method, the response is based on the query result.

In the configuration panel, we can list one or more queries on the left and on the right panel we can specify the query (XPATH) and expected value. If the query matches the expected values then the selected response will be dispatched. Otherwise, the default response will be returned.

query_match

XPATH: This is almost similar to QUERY_MATCH but is not as powerful. It sends a response if XPATH matches.

RANDOM: This is one more simple way of dispatching responses; it just picks up any response in a random manner and dispatches right away.

Scripting for Mock Response:

Scripting is the most versatile and complicated option. But scripting provides a way to change the mock response contents, headers, attachments while sending it to the client. It also allows you to simulate valid or Invalid HTTP responses. Each mock response can have its own script for creating dynamic contents in the response message.

The script inspector at the bottom of the mock response editor is shown below:

the-script-inspector

Script example:

import javax.xml.xpath.*
import groovy.xml.StreamingMarkupBuilder
import groovy.lang.Binding;
import groovy.lang.Script;
def util = new com.eviware.soapui.support.GroovyUtils( context )
def xml = new XmlSlurper().parseText(mockRequest.requestContent)
def country = xml.Body.GetCitiesByCountry.CountryName
def str = country.toString()
log.info str
if(str == 'India' || str == 'INDIA')
{
context.CaptialCity = "Delhi"
}
else if(str == 'UK' || str == 'Uk')
{
context.CaptialCity = "London"
}

In the above example, the script simply sets the value of property ‘CaptialCity’ in the response of current context.

We can use a variety of ways to create the dynamic contents of property like querying a database or reading an external file, etc.

Conclusion:

Mock Services is one of the most powerful features of SOAPUI. Mock Service exposes a number of mock operations which in turn can contain an arbitrary number of mock responses. These responses will provide a tangible way to assess how the web service will actually work, how users will respond to it and use the application.

Dynamic mock responses in SOAPUI make it super useful in test automation.

With some extra scripting efforts, you can create Automated Test Steps which will surely increase the quality of testing as well as reduce testing time in development phases of any web application.

Hope this tutorial on creating mock service and producing dynamic response was helpful. Feel free to add your queries in below comments.

Related

Best Iptv Service Provider 2023 With 40k+ Channels And 150k+ VOD . Hurry Up

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • IPTV List: Best iptv lista 2023
  • IPTV Premium: Best Premium IPTV Service Provider List And Benefits
  • Nikon IPTV Review: Over 10,000 Live Channels for $12/Month
  • Iptvwings. Com Review: +18000 Live IPTV Channels ,+70000 Movies, +40000 TV show For $15/1 month
  • IPTVUNO Review: More Than 16000 Live TV channels, 55,000 Movies & VOD For $15/Month

Recent Comments

  1. IPTV List: Play lista iptv 2022 - Iptv Assist on Best IPTV Player in 2023 for Watching Live TV
  2. Cola IPTV – Over 18,000 Live Channels for $12/Month - Iptv Assist on FileLinked – How to Install on Firestick/Fire TV and Android Devices
  3. Cola IPTV – Over 18,000 Live Channels for $12/Month - Iptv Assist on 50+ Best IPTV Service Providers for Streaming Live TV 2023
  4. XoomsTV IPTV – Over 11,000 Channels & VOD for Under $13/Month on Best VPN for IPTV in 2023 and How to Install on Firestick/Android
  5. Voodoo Streams IPTV Review – Over 12,000 Channels for $11/Month - Iptv Assist on Dynasty TV IPTV Review – Over 6,000 Channels for $10/Month

Archives

  • March 2023

Categories

  • Activate
  • Agile Testing
  • Alternatives
  • Android
  • APK
  • Apple TV
  • Automation Testing
  • Basics of Software Testing
  • Best Apps
  • Breakfast Hours
  • Bug Defect tracking
  • Career in Software Testing
  • Chromebook
  • Chromecast
  • Cross Platform
  • Database Testing
  • Delete Account
  • Discord
  • Error Code
  • Firestick
  • Gaming
  • General
  • Google TV
  • Hisense Smart TV
  • HOW TO
  • Interview Questions
  • iPhone
  • IPTV
  • IPTV Apps
  • Iptv Service SP
  • IPTV Services
  • JVC Smart TV
  • Kodi
  • Lg Smart TV
  • Manual Testing
  • MI TV
  • Mobile Testing
  • Mod APK
  • newestiptv.com
  • News
  • Nintendo Switch
  • Panasonic Smart TV
  • PC Apps
  • Performance Testing
  • Philips Smart TV
  • PS4
  • PS5
  • Python
  • QA Certifications
  • QA Leadership
  • QA Team Skills
  • Quality Assurance
  • Reddit
  • Reviews
  • Roku
  • Samsung Smart TV
  • Screenshot
  • Selenium Tutorials
  • Sharp Smart TV
  • Skyworth Smart TV
  • Smart TV
  • Soft Skills For Testers
  • Software Testing Templates
  • Software Testing Tools
  • Software Testing Training
  • Sony Smart TV
  • Sports
  • Streaming Apps
  • Streaming Devices
  • Tech News
  • Test Management Tools
  • Test Strategy
  • Testing Best Practices
  • Testing Concepts
  • Testing Methodologies
  • Testing News
  • Testing Skill Improvement
  • Testing Tips and Resources
  • Toshiba Smart TV
  • Tutorials
  • Twitch
  • Types of Testing
  • Uncategorized
  • Vizio Smart TV
  • VPN
  • Web Testing
  • What is
  • Xbox
©2023 Iptv Assist | Design: Newspaperly WordPress Theme