Why would you want to use a Web service? They are flexible and supported on a number of platforms and can be implemented by using a number of languages. This chapter from BEA WebLogic Workshop 8.1 (by Albert J. Saganich, Jr., et al., Sams, 2004, ISBN: 0-672-32622-1) covers Web services concepts, SOA, SOAP, WSDL, and security.
Working with Web Services - Using Web Services Within Workshop Applications (Page 5 of 9 )
Although a Web service is typically used to make a service available to the outside world, often you want to use a previously defined Web service from within a Workshop application. The following list illustrates three possible situations in which you would access Web services from within a Workshop application:
Web service within the same project as the caller—The Web service is defined in the calling application as a JWS file.
Web service in a Web services project—The Web service is developed in another Workshop project, but within the same application.
External Web server—The Web service is external to the application.
The simplest situation is having a Web service contained within the same project as the Web or portal application. In this case, you can simply right-click the Web service JWS file, and choose Generate Service Control. A control with the same name as the Web service is created, with Control.jcx added to the end of the name. Drag and drop the newly created control onto a Page Flow or any other consumer, and use it as you normally would.
If the Web service is nonlocal, you need to access its WSDL to create a control wrapper. WebLogic Workshop can easily create a WSDL file from a Web service. To do this, right-click the Web service, and choose Generate WSDL File. A WSDL file is created with the same name as the Web service, but it ends in Contract.wsdl. Workshop is smart enough to keep the associated WSDL file synchronized with its Web service parent. Changes to the Web service's methods or signatures cause an update to the associated WSDL.
To create a Web service control around an external Web service within a Page Flow, follow the steps shown in Figure 9.4:
Select the folder where the Web service control will be created, and from the Data Palette's Add menu, choose Web Service.
Enter a variable name for the control instance.
Select the Create a New Web Service Control to Use option, and enter a Java Control Extension (JCX) name. A common convention is to use all uppercase letters for the JCX name or add WS to the end.
Browse to the WSDL file defining the interface to the Web service. For those Web services within the same application but in a control project, you can browse to the directory containing the WSDL file. For external Web services, you can enter a fully qualified URL to the WSDL file.
Click Create.
Figure 9.4 -- Creating a Web service control from an external Web service.
Workshop then creates a JCX file defined by the selected WSDL that can be used like any other control. It's important to note that the newly created control represents the Web service as it was defined by the WSDL file at its moment of creation. If the underlying Web service changes, such as modifying a method signature, the control instance will not match the running service. Be careful to ensure that the Web service is stable before you create a control from it.
This chapter is from BEA WebLogic Workshop 8.1, by Albert J. Saganich, Jr., et al. (Sams, 2004, ISBN: 0-672-32622-1). Check it out at your favorite bookstore today.