Change request-data/xml of every new created WsdlRequest
Hello,
I hope this is the correct location for my question.
I have the following scenario/problem:
I have a soapUI project for a big IT-System, which offers a lot of webservices. I don't test this IT-System, but I need to send webservice request to this System for getting data or debugging other applications (which also uses webservices from this IT-System). Because I need no assertion and the data I send change alot, I don't use any testcases. Instead I send the request directly from the project (Interface > Operation > Request > "Submit request to specified Endpoint" (green play button). For every new request I add, I have to do a lot of monkey work to setup the request-data/xml.
My idea now was, to use the load script of the project (number 2 in the attached picture), and register some listener to react to new added requests. If a new request ("Request 2" in the picture) was added, I wanted to change the generated xml data (no. 4) to the format I needed (no. 5). I succeded to register the listeners and react to the addition of requests. But as soon as I try to access the data for the request, I fail.I have no idea how I do it is the right way and searching the documentation and the net, did not bring up any solutions.
My try, the magic happens (or not) in the method requestAdded.
import com.eviware.soapui.SoapUI import com.eviware.soapui.model.support.ProjectListenerAdapter import com.eviware.soapui.model.support.InterfaceListenerAdapter import com.eviware.soapui.model.iface.* import com.eviware.soapui.impl.wsdl.WsdlRequest import com.eviware.soapui.impl.wsdl.WsdlContentPart import com.eviware.soapui.model.propertyexpansion.DefaultPropertyExpansionContext import com.eviware.soapui.support.XmlHolder SoapUI.log.info("Load Script executet") for(Interface i : project.getInterfaceList()){ i.addInterfaceListener(new RequestAddListener()) } project.addProjectListener(new ProjectListenerAdapter(){ public void interfaceAdded(Interface i){ SoapUI.log.info("Interface added: "+ i.getName()) i.addInterfaceListener(new RequestAddListener()) } }) public class RequestAddListener extends InterfaceListenerAdapter { public void requestAdded(Request r) { if(r instanceof WsdlRequest){ WsdlRequest request = (WsdlRequest) r SoapUI.log.info(request.getName()) // out: Request 2 // Methodname sounds good SoapUI.log.info("^"+request.getRequestContent()+"\$") // out: ^$ // found some expamles on the net, but they all did it in testcases, // and there the context is provided // No idea if this is the right way to create a context def context = new DefaultPropertyExpansionContext(request.getOperation()) def utils = new com.eviware.soapui.support.GroovyUtils(context) // don't know what to put in as parameter def holder = utils.getXmlHolder(r.getName()+"#request") // throws error: Unexpected element: CDATA SoapUI.log.info("request data: "+ holder.getPrettyXml()) } } }
Does anybody knows how to access and change the request-data of the WsdlRequest from the load script? Or is there a better way to avoid the monkey work?