WS.validateXmlAgainstSchema doesn't follow redirects in WSDL URLs

I have a WSDL file in an online URL. This file contains references to xsd schemas that have http in their URLs. But the actual files lie under the https protocol, so following the http link redirects to the https page. But the XML validation method does not follow the redirect and gives an error trying to read the redirection page as an XML.

I cannot change the WSDL.

Operating System

Windows 10

Katalon Studio version

Standalone version 8.5.5

Steps to reproduce

  1. Create a SOAP request based on an XML schema
  2. Create a verification script that will validate the server response (or any xml) against a schema. The WSDL schema should contain XSD imports with links that will redirect to a different page
ResponseObject response = WSResponseManager.getInstance().getCurrentResponse()
WS.validateXmlAgainstSchema(response,"wsdl link")
  1. Send the request and verify

Expected Behavior
XML validator follows redirects from WSDL links. The server response is validated against the given schema

Actual Behavior
Fatal error: The element type “hr” must be terminated by the matching end-tag “”. That is because the requested URL to XSD gives a response like this (redirects not followed)

<html>
    <head><title>301 Moved Permanently</title></head>
    <body>
        <center>
            <h1>301 Moved Permanently</h1>
        </center>
        <hr>
        <center>nginx</center>
    </body>
</html>

By the way, there’s a “Follow redirects” option in the request configuration, but i believe it’s reserved only for the request object itself. It doesn’t help in this situation.

Fatal error: The element type “hr” must be terminated …

This is not the real issue. WSResponseManager is not capable to do anything meaningful for a HTML document.

The real issue is that Katalon is not doing “follow redirects” for you. So you should try to find how to let Katalon do “follow redirects”.

You should be able to create a SOAP request with com.kms.katalon.core.testobject.RequestObject.setFollowRedirect( true ) and setRedirectTimes( some integer larger than 0), shouldn’t you?

If you set the RequestObject with “follow redirects” option enabled, Katalon Studio may perform “follow redirects” when it received a reply “HTTP status=301 Moved Permanent”. (I have never tried it so i am not sure)

If Katalon Studio performs following redirects, eventually SOAP service would reply a valid XML SOAP response; then WSResponseManager would have a chance to validate the XML document. If Katalon Studio does not perform following redirects, no valid XML document would be passed to WSResponseManager.

How do i create the request again?

testobject.RequestObject.setFollowRedirect doesn’t have a setFollowRedirect method or i misunderstand something. And judging from the method name it returns void, not a request object. So it would be a method to set a redirect parameter, not an object.

I tried creating a test object with findTestObject(‘ObjectName’), but it doesn’t have any redirect setting methods either.

I have a sample code:

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

import com.kms.katalon.core.testobject.RequestObject
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS

def response = WS.sendRequestAndVerify(findTestObject("Object Repository/POST a new user",
	["age": 16, "username": "John Doe", "password": "ThisIsNotAPassword", "gender": "male"]))

I can rewrite this into

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

import com.kms.katalon.core.testobject.RequestObject
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS

TestObject tObj = findTestObject("Object Repository/POST a new user",
	["age": 16, "username": "John Doe", "password": "ThisIsNotAPassword", "gender": "male"])
RequestObject request = (RequestObject)tObj
request.setFollowRedirects(true)
request.setRedirectTimes(10)
def response = WS.sendRequestAndVerify(request)

The latter does the same as the former. Please note that I set “follow redirects” enabled in tha latter.

You should know that RequestObject extends TestObject. Please have a look at the javadoc of RequestObject.

Alright, i wrote the code like yours. But i’m getting the same old error when trying to validate.

def request = (RequestObject) findTestObject('request name')
request.setFollowRedirects(true)
request.setRedirectTimes(2)
def response = WS.sendRequest(request)
WS.validateXmlAgainstSchema(response,"WSDL url")

Then it is likely, but I am not sure, that Katalon Studio does not support “follow redirects” in WS testing.

@vu.tran

If you are a paying licensee, you should raise an official support request to Katalon.

I am not surprised if Katalon doesn’t support following redirects. I have an impression that WS features in Katalon Studio is poorly implemented.

You might not be able to solve this issue in Katalon Studio. Why not you try doing the same test in other test tools, like Postman?

Well, i did find a workaround by downloading the WSDL and changing the XSD links inside it (trying to refer to them locally doesn’t work either). And schema validation is optional in my case.

I would like to use Katalon since it makes test organization fairly easy. Something like Postman is not so great for that as every request in it is separate and can’t really be reused. And, uhh, SoapUI interface is pretty horrible.

But it does seem like i’ll have to deal with more issues in the future…

Good luck!