Forum Discussion

Cizo89's avatar
Frequent Contributor
11 years ago

[Resolved]Problem with creating REST TestRequests via Groovy


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="" xmlns:xsi="" />')

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,

12 Replies