I am trying to call the SOAPUI
classes directly in my units test , so that I can directly provide the link to the WSDL
and call individual operations.
The reason behind doing this is , I intend to create individual test cases and suites using these classes (without having to use the actual UI)
I am referring to the example on this page on the SOAPUI
website. I have downloaded all dependencies required for SoapUI maven plugin listed here
After fixing the project buildpath for the following code:
import com.eviware.soapui.impl.WsdlInterfaceFactory;
import com.eviware.soapui.impl.wsdl.WsdlInterface;
import com.eviware.soapui.impl.wsdl.WsdlOperation;
import com.eviware.soapui.impl.wsdl.WsdlProject;
import com.eviware.soapui.impl.wsdl.WsdlRequest;
import com.eviware.soapui.impl.wsdl.WsdlSubmit;
import com.eviware.soapui.impl.wsdl.WsdlSubmitContext;
import com.eviware.soapui.model.iface.Response;
public class someClassName
{
// Create new wsdl project
WsdlProject wsdlProject = new WsdlProject();
// Import webservice wsdl
WsdlInterface iface = WsdlInterfaceFactory.importWsdl(wsdlProject , "http://localhost:8080/MyWebService/MyWebService?wsdl", true)[0];
// Get desired operation
WsdlOperation someOp = (WsdlOperation) iface.getOperationByName("someOpName");
// Create a new empty request for that operation
WsdlRequest someOpRequest = someOp.addNewRequest("My request");
// Generate the request content from the schema
someOpRequest.setRequestContent(someOp.createRequest(true));
// Submit the request
WsdlSubmit submit = (WsdlSubmit) someOpRequest.submit(new WsdlSubmitContext(someOpRequest), false);
// Wait for the response
Response response = submit.getResponse();
// Print the response
String content = response.getContentAsString();
System.out.println(content);
}
I am getting compilation error: .
Syntax error on token "setRequestContent", Identifier expected after this token .
Has any one else tried to run this example ? It would be great if some one can point me out to a clearer and detailed online tutorial/blog on this topic.