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 - Developing Web Services (Page 4 of 9 )
WebLogic Workshop fully supports creating and using Web services. With Workshop, you can create Web services from scratch or extend an existing Web service. Workshop also supports creating control wrappers around existing Web services, whether they were created with Workshop or exist outside WebLogic Server.
To create a Web service, follow the steps shown in Figure 9.3:
Select the folder where the Web service will be created.
Choose File, New, Web Service from the WebLogic Workshop menu.
In the New File dialog box, enter a filename for the Web service and click Create.
From a Workshop development perspective, Web services look much like controls. Web services have methods, can support callbacks, and can use other controls, EJBs, or J2EE services. You can add methods simply by dragging them from the Data Palette, as you would with a control or Page Flow.
Exposing Web Services Beyond Workshop
Web services are typically created to make a service or an interface available to the outside world. WebLogic Workshop Web services are no different, and external Web service consumers can easily use them.
Examine the creditServices Web service, which the Wonderland Casino requires to support checking a player's credit limit. creditServices supports the checklimit method, which takes a string name and a bet in the form of an integer and returns true or false, depending on whether the player's bet is within his or her limit. Table 9.1 lists some of the more important components created for the creditServices Web service.
The URL to the service's main page. All Web services automatically generate a set of JSP pages in support of using the Web service. The URL is created from the URL of the running instance of Workshop and the path to the Web service.
A complete WSDL description of the Web service, which external clients can use to access the service. Note that for Web services that provide callbacks, two sets of WSDL are supplied, one with and one without callback definitions.
creditServices.jar and webservicesclient.jar
Client support JAR files that can be used standalone Java clients to call the Web service as though it were a local class.
Overview, Console, Test Form, and Test XML
Workshop generates a set of JSP pages containing support for the Web services. The Overview page provides downloadable client JAR files, WSDL, and so on. Test Form provides a simple JSP with entries for each method of the Web service. The Test XML page is a example of the XML used to call service methods.
The target-namespace Property - By default, newly created Web services do not have a defined namespace. For those unfamiliar with the concept of namespaces, simply consider them as a way to control name collisions. Typically, a namespace is defined by using the Web name of the entity that has developed the service (for example, http://www.samspublishing.com), followed by details of the service. For example, you could use the namespace http://www.samspublishing.com/81kickstart/casino/supportservices as the target namespace of the Web service to ensure that no other services with the same name will be confused with yours.
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.