Step 2. Create the Web Service Client artifacts from WSDL
Time to complete this step: 10 minutes
OEPE provides a wizard that wraps the
ClientGen Ant task. The
ClientGen Ant task generates, from an existing WSDL file, the client component files that client applications use to invoke both WebLogic and non-WebLogic Web Services. This allows your web service to be called from a web or non-web client. When generating a JAX-WS Web Services, the output includes:
- The Java class for the Service interface implementation for the particular Web Service you want to invoke.
- JAXB data binding artifacts.
- The Java class for any user-defined XML Schema data types included in the WSDL file.
Client applications can use the generated artifacts of
ClientGen to invoke Web Services, for example with:
- Stand-alone Java clients that do not use the Java Platform, Enterprise Edition (Java EE) Version 5 client container.
- Java EE clients, such as EJBs, JSPs, and Web Services, that use the Java EE client container.
In this step, you will use the
ClientGen tool for generating the client component files for web services (like Login, Product and Ticket web services) generated during previous tutorial parts.
Before you start this tutorial step, make sure that the
TroubleTicketSystemServer and
TroubleTicketSystemWebClient projects are deployed and running on the Oracle WebLogic Server.
You will perform the following tasks in this step:
Create web service client artifacts for the Login Web Service
- In the
Project Explorer view, right click the
TroubleTicketSystemWebClient and choose
New > Other...
- In the
New wizard page, select
WebLogic Web Services > Web Service Client.
- Click
Next.
- In the
WSDL file wizard page, select the
Remote option for WSDL location. Select the
TroubleTicketSystemWebClient project for where to generate the client artifacts and specify the remote WSDL URL from which to generate the client artifacts. For the
LoginWebService (from
TroubleTicketSystemServer), the URL would be
http://localhost:7001/TroubleTicketSystemServer/LoginWebServiceService?wsdl
- Click the
Validate WSDL button to validate the given WSDL URL for connectivity and availability. If the WSDL is valid, then it enables the
Next and
Finish buttons.
- Click
Next.
- The
Generated Artifacts wizard page offers following options:
- The
Service field describes the
LoginWebServiceService, which is the name of the Web service in the WSDL file for which the corresponding client component files should be generated.
- The
JAR location field specifies the name and location of the JAR file into which the
ClientGen ANT task packages the client source code, compiled classes, WSDL and client deployment descriptor file.
- Select the
Keep generated ANT script option, if you want to keep the generated ANT script.
- Click
Next.
- In the
Customization Options wizard page, for the
Runtime WSDL Location, select the
Copy WSDL into client JAR option. Choosing the
Copy WSDL into client JAR does the following:
- Sets the
wsdlLocation attribute on the
@WebServiceClient annotation of the generated Web Service Client class to a location in the client JAR file;
- Copies the WSDL file to that location in the produced client JAR file through the
copyWsdl attribute. By default, the WSDL file is placed in the JAR at the
META-INF/wsdls location. You can modify this location by overwriting the
WSDL path in JAR field.
- Click
Finish.
- That generates the
LoginWebServiceService.jar file under the
TroubleTicketSystemWebClient/WebContent/WEB-INF/lib folder.
- You can open the generated JAR file with some JAR extracter program and review the generated artifacts.
Create the web service client artifacts for the Product Web Service
- Follow the similar steps for generating the client artifacts for the Product Web service that you performed in the previous step for the Login web service.
- In the
Project Explorer view, right click the
TroubleTicketSystemWebClient and choose
New > Other...
- In the
New wizard page, select the
WebLogic Web Services > Web Service Client.
- Click
Next.
- In the
WSDL file wizard page, select the
Remote option for the WSDL location. Select the
TroubleTicketSystemWebClient project where to generate the client artifacts and specify the remote WSDL URL from which to generate the client artifacts. For the
ProductWebService (from
TroubleTicketSystemServer), the URL would be
http://localhost:7001/TroubleTicketSystemServer/ProductWebServiceService?wsdl
- Click the
Validate WSDL button to validate the given WSDL URL for connectivity and availability.
- Click
Next.
- Click
Next in the
Generated Artifacts wizard page.
- In the
Customization Options wizard page, for the
Runtime WSDL Location, select the
Copy WSDL into client JAR option.
- Click
Finish.
- That generates the
ProductWebServiceService.jar file under the
TroubleTicketSystemWebClient/WebContent/WEB-INF/lib folder.
- You can open the generated JAR file with a JAR extracter program and review the generated artifacts.
Create web service client artifacts for the Ticket Web Service
- Follow the similar steps for generating the client artifacts for the Ticket Web service that you performed in the previous step for the Product web service.
- In the
Project Explorer view, right click the
TroubleTicketSystemWebClient and choose
New > Other...
- In the
New wizard page, select
WebLogic Web Services > Web Service Client.
- Click
Next.
- In
WSDL file wizard page, select the
Remote option for the WSDL location. Select the
TroubleTicketSystemWebClient project for where to generate the client artifacts and specify the remote WSDL URL from which to generate the client artifacts. For the
ProductWebService (from
TroubleTicketSystemServer), the URL would be
http://localhost:7001/TroubleTicketSystemServer/TicketWebServiceService?wsdl
- Click the
Validate WSDL button to validate the given WSDL URL for connectivity and availability.
- Click
Next.
- Click
Next in the
Generated Artifacts wizard page.
- In the
Customization Options wizard page, for the
Runtime WSDL Location, select the
Copy WSDL into client JAR option.
- Click
Finish.
- That generates the
TicketWebServiceService.jar file under the
TroubleTicketSystemWebClient/WebContent/WEB-INF/lib folder.
- You can open the generated JAR file with some JAR extracter program and review the generated artifacts.
Click the arrow below to navigate through the tutorial: