RAD V6.0 also supports creating a Web service based on a standard (non-EJB) JavaBean. However, best practices recommend basing Web services on stateless session EJBs because they can be accessed securely in a consistent manner across all possible interfaces (Web, thick client, EJB, messaging).
Create an Enterprise Application project (Chapter3EAR).
Create an EJB project (Chapter3EJB).
Create or import an enterprise bean into your EJB project (SayHello bean with REMOTE client view).
Deploy your enterprise bean.
Create a dynamic Web project (Chapter3Web) targeted to the appropriate server (WAS 6.0). It is strongly suggested that you start the server before running the Web service wizard since it may take several minutes to start the WebSphere Application Server depending on the speed of your computer. To start the server, select it in the Servers view (Window > Show View > Servers), right-click and click Start.
Ensure that the test server is running.
From the Project Explorer, select EJB Projects > Chapter3EJB > Chapter3EJB > Sessions Beans > SayHello, and right-click Web Services > Create Web service.
From the Web Services popup, ensure that Web service type is set to EJB Web Service, and click Next. All other settings default to the selections and values in the following illustration:
From the Object Selection Page pop-up, ensure that the SayHello is selected under Stateless EJB beans, and click Next.
At the Service Deployment Configuration pop-up, if Web service runtime: is set to IBM WebSphere and Server is set to 000-257 (your test server), then click Next.
At the Web Services EJB Configuration pop-up, perform the following tasks:
Ensure that Use an existing service endpoint interface is cleared.
Ensure that Select Router Project is Chapter3Web.
Ensure that Select transports is SOAP over HTTP.
At the Web Service Java Bean Identity pop-up, ensure that greet(...) is selected, and click Next. All other settings should default to the selections and values shown in the following illustration:
WS-I compliance requires using Document/Literal (under Style and Use).
At the resulting Web Service Publication pop-up, click Finish. Do not publish to any of the UDDI registries.
Modify the WSDL to remove HTTPS
The WSDL is generated using the secure https://localhost:9443 because RAD V6.0 is configured to interact with the test server in secure mode.
The Web service can be accessed over the HTTPS or HTTP. Since the HTTPS and HTTP interaction is handled by the embedded HTTP server in the Web container, the back end Web service code is unaware of which protocol is used.
Follow these steps to change the WSDL address from HTTPS to HTTP:
Select EJB Projects > Chapter3EJB > ejbModule > META-INF > wsdl > SayHello.wsdl, and double-click to open.
At the SayHello.wsdl editor switch to the Source tab, scroll to the bottom, and change the SOAP address line from the following:
to the following, ensuring that you change BOTH https to http AND 9443 to 9080:
Save and close.
Do the same for \Chapter3Web\WebContent\wsdl\by\iba\rad257\SayHello.wsdl and Chapter3Web\WebContent\WEB-INF\wsdl\SayHello.wsdl.
Test Web Service using Web Service Explorer: