| By Kunal Mittal | Article Rating: |
|
| February 26, 2004 12:00 AM EST | Reads: |
13,885 |
You can create a Java Page Flow application in BEA WebLogic Workshop that utilizes a Service control generated from a Web service.
This article uses the example of an external Web service listed on the XMethods.net site. We will import the WSDL for the Web service into BEA WebLogic Workshop and see the custom Service control that is generated. We will then consume this control within a simple Page Flow application. We can also create a sample JWS file that allows you to quickly test the control.
Getting the WSDL File from XMethods.net
Visit the XMethods.net site. It lists a number of Web services. My example uses the "Dead Or Alive" Web service. The description (taken right from the listing) is, "includes methods to search the DeadOrAlive database by name, and search for people born on or died on a date (dd/mm). Also a method to get today's birthdays."
According to the listing, this Web service runs on .NET technology. The URL to the WSDL is www.abundanttech.com/webservices/deadoralive/deadoralive.wsdl.
There is a link to this WSDL from the Web service listing on the XMethods site. Feel free to use another Web service from that site as you apply this article. You will need the URL to the WSDL file to create the Service control. Or, you can download the WSDL file to your local machine and import it into the Workshop environment. However, in general that is not a good idea as you will not know if the WSDL changes in the future.
Starting WebLogic Workshop
The next step is to set up BEA WebLogic Workshop. I assume that you have basic familiarity with the tool and have the latest release of BEA WebLogic Platform 8.1 installed. If not, you will need to download and install that from the BEA Web site. Launch Workshop and create a new application. Within the application create a new Web project.
Generating the Service Control from the WSDL File/URI
Create a folder in which to store this control. In my example, I named the folder "ServiceControls". Now, create a new Java control and then select Web services. The wizard will prompt you to name the control. Give your control a name like "DeadOrAliveCtrl". The next step is to enter the URI for the Web service. You can point to the URI or to a local copy of the WSDL file. That's it. You're done. WebLogic Workshop will generate a control that consumes this Web service. Figure 1 shows the Service control that is generated for you. If you are interested in it, click the source tab to see the source code.

If you have a different Web service as an example, you will see the corresponding control. The same applies if you want to leverage any other Web service, such as the Amazon.com or Google.com Web services within WebLogic Workshop.
You can now use this control as part of any other WebLogic Workshop application. For this article, we will generate a Java Page Flow from this control. Since this is an automated step, it is a quick and easy way to test the consumption of the Web service and the control generated by Workshop.
Generating a Java Page Flow
This is a one-step process. Right-click on your control and select "Generate Page Flow". Use the wizard to give your page flow a name such as "DeadOrAlive", or based on the Web service you selected. Figure 2 shows the generated Java Page Flow.

The Page Flow can be used to test your control. Click on the "Start" button from your debug menu. This will start an instance of the BEA WebLogic Server; build and deploy your application, and then load a test browser that allows you to test the operations. Play around a little bit and test the different operations that your control supports. Figure 3 shows the test browser.

One thing you will notice is that the results displayed are meaningless. By default, the index.jsp displays something like
ServiceControls.DeadOrAliveCtrl$getDeadOrAliveResult@4d3078
for the results. This doesn't help much. You will need to change the Page Flow code to correct this problem.
Generating a Web Service from the Service Control
Another quick way of testing your control is to use the "Generate Test JWS file" option. This option is available by right-clicking on the control and will generate a simple Web service. Once you have generated the JWS file, select it and then click on "Start" from the Debug menu. This will once again bring up the test browser with the Web service. Click on "Start TestDrive" and then "Continue this conversation". This is like a handshake between the Web services and now you can execute operations on the Web service you are consuming, from your Web service (see Figure 4).

Summary
In this article I showed you how BEA WebLogic Workshop can be used to consume Web services that are running on other machines. All you need to know is the location of the WSDL file. From that, Workshop can generate everything you need to consume that Web service, in a matter of minutes. This shows you the power, not only of BEA WebLogic Workshop, but of Web services, which enable tools such as Workshop to automate and provide this capability.
References
Published February 26, 2004 Reads 13,885
Copyright © 2004 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Kunal Mittal
Kunal Mittal is a consultant for implementation and strategy for Web services and services-oriented architectures. He has co-authored and contributed to several books on Java, WebLogic and Web services.
- Oracle To Keynote Cloud Computing Expo
- The Economics of Cloud Computing Analyzed
- The Difference Between Web Hosting and Cloud Computing
- GovIT Expo Highlights Cloud Computing
- Cloud Computing Best Practices
- Gang of Four Creates Cloud BI Stack
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Citrix Aims To Cripple VMware’s Cloud Designs
- Product Evaluation: JBoss TCO Calculator
- Platform as a Service Journal Launched on Ulitzer
- An Introduction to Abbot
- Oracle To Keynote Cloud Computing Expo
- Will Ulitzer Dominate News Content on The Web? -Gartner
- REA Is Where RIA Becomes the Norm
- The Economics of Cloud Computing Analyzed
- Software AG Named "Gold Sponsor" of SOA World Conference & Expo 2009 East
- The Difference Between Web Hosting and Cloud Computing
- GovIT Expo Highlights Cloud Computing
- Cloud Computing Best Practices
- Gang of Four Creates Cloud BI Stack
- Java vs C++ "Shootout" Revisited
- Where Are RIA Technologies Headed in 2008?
- Configuring Eclipse for Remote Debugging a WebLogic Java Application
- Migrating a JBoss EJB Application to WebLogic
- XA Transactions
- An Introduction to Abbot
- WebLogic Tutorial: "Integrating Apache Poi in WebLogic Server"
- Eclipse "Pollinate" Project to Integrate with Apache Beehive
- Failover and Recovery of Enterprise Applications - Part 1
- Cover Story: A Practical Solution to Internationalization of a J2EE Web App






























