Integrating with soapUI
Many of the classes in soapUI can be used directly in other programs, for example if you want to set up requests and/or TestCases manually.
The following code is taken from the WsdlRequestTestCase and illustrates how to create a project, import a WSDL, create a request and submit it:
// create new project WsdlProject project = new WsdlProject();
// import amazon wsdl WsdlInterface iface = WsdlInterfaceFactory.importWsdl( “http://www.mycorp.com/somewsdl.wsdl”, true )[0];
// get desired operation WsdlOperation operation = (WsdlOperation) iface.getOperationByName( “MyOperation” );
// create a new empty request for that operation WsdlRequest request = operation.addNewRequest( “My request” );
// generate the request content from the schema request.setRequestContent( operation.createRequest( true ) );
// submit the request WsdlSubmit submit = (WsdlSubmit) request.submit( new WsdlSubmitContext(), false );
// wait for the response Response response = submit.getResponse();
// print the response String content = response.getContentAsString(); System.out.println( content ); assertNotNull( content ); assertTrue( content.indexOf( “404 Not Found” ) > 0 );
For this to work you will need the same dependencies as the SoapUI Maven plugin.