10 April 2007 - 1.7 |
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 = project.importWsdl( "http://localhost:8082/soapui-tests/test1/TestService.wsdl", true )[0]; // get "GetPage" operation WsdlOperation operation = (WsdlOperation) iface.getOperationByName( "GetPage" ); // 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, download the source and have a look at the dependencies in src/maven-soapui-plugin/project.xml.
The LGPL-license allows you to do the following things with soapUI: