Forum Discussion

Cizo89's avatar
Cizo89
Frequent Contributor
12 years ago

[Resolved]Problem with creating REST TestRequests via Groovy

Hi,

I want to create a REST TestRequest via Groovy script.
I've tried several codes, but all these attempts ended in dialog window where I had to connect this new REST TestRequest with one of my already existing REST Resources.

After analyzing the SoapUI API I came to solution to use class RestRequestStepFactory and its method createNewTestStep(RestMethod restMethod, String name).
But currently I'm stucked with the contructor for class RestServiceConfigImpl - the constructor is always returning <xml-fragment/>, although I've correctly initialize the object and set the value for it.


import org.apache.xmlbeans.XmlObject.Factory
import com.eviware.soapui.config.impl.RestServiceConfigImpl

def xmlObj = Factory.newInstance()
xmlObj.set('<xml-fragment type="restrequest" name="temp" xmlns:con="http://eviware.com/soapui/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />')

RestServiceConfigImpl restServiceConfig = new RestServiceConfigImpl(xmlObj.schemaType())


Could you, please, help me with this or point me to a solution how to create REST steps via Groovy script?

Thanks in advance,
Marek