A Web service stub provides replacement implementations for another
Web service that the Web service under test interacts with. By creating a
Web service stub, you can better isolate the testing of the Web service under
test. You can create stubs for Web service components by clicking File
> New or you can create stubs for a particular test suite from
the Test Suite editor.
Web service stubs are deployed on the server at run time. In the case
where a deployed stub throws an exception, you must expect to receive an encapsulated
exception message from the server and not from the actual stub.
To create a stub for a HTTP-based Web service:
- Click and
click Next.
- Select the test project that will contain the stub and click Next or
click New to create a new project and click Next.
- Locate the WSDL definition file for the Web service that you want
to create a stub for. You can use Browse to
use a WSDL from your workspace, or use Import to import
the file from the filesystem.
- Select one or more bindings that you want to stub. For
information about bindings, see the Web Services Description Language (WSDL)
reference.
- In the Web service runtime Java proxy generation list,
select the runtime environment (IBM® WebSphere® or Apache Axis) that you
want to use to generate the Java™ proxy for the test.
Note: You
cannot use multiple runtime environments within a single project. If a Web
service component test or stub already exists in the current test project,
you can use only the runtime environment that was previously used in this
test project. To create a test using a different runtime environment, you
must create a new test project.
- Click Finish. If the stub component
already exists, the wizard prompts you to replace the existing stub. If you
select Yes or Yes to All, then
any changes you have made to the existing stub will be overwritten. If you
select No or No to All, then
the existing files remain unchanged and a new stub is not generated.
- In the Test Navigator view, double-click the test suite to which
you want to add the stub. This opens the Test Suite editor.
- In the Test Suite editor, click the Stubs tab,
click Add, select the stub you want to add to the test
suite, and click Finish.
Note: To create a new stub and
add it automatically to the test suite, click New and
proceed with Step 3.
To replace the stub with the real class at any time, simply remove
the stub from the test suite.