Welcome!

Java Authors: Maureen O'Gara, Liz McMillan, Walter H. Pinson, III, Yakov Werde, Tony Bishop

Related Topics: Java, SOA & WOA

Java: Article

Java Feature: Putting a Face on Web Services and SOA

It's easier than you think

We'll now modify it to call our BPEL Web Service. Before we can call the service, we must create a Web Service proxy class which will provide a way to call the service from Java.

To create the proxy class, you can use the Web Service Proxy wizard in JDeveloper (File->New...->Business-Tier->Web Services->Web Service Proxy). As the wizard commences, all that is needed to generate the necessary proxy to call the BPEL Web Service is to supply the WSDL URL http://localhost:9700/orabpel/default/LoanCompare/1.0/LoanCompare?wsdl (Figure 16).

Accept the remaining defaults and click Finish to generate the Proxy code. As the code generates you will see a Java Proxy client, LoanCompareWSHttpPortClient.java which is a runnable Java client with a main method. The main method looks like:

     public static void main(String[] args) {
       try {
       proxy.CheaploansWSSoapHttpPortClient myPort = new
proxy.CheaploansWSSoapHttpPortClient();
       System.out.println("calling " + myPort.getEndpoint());
      // Add your own code here
       } catch (Exception ex) {
         ex.printStackTrace();
      }
     }

You can issue a test call to the Web Service by adding the line:

System.out.println(myPort.getLoanrate("123-45-6789"));

To the location denoted by the comment "// Add your own code here".

The next step is to modify the action method linked our button with code to call the BPEL Web Service using the Proxy class, "LoanCompareWSSoapHttpPortClient".

Jumping back into the backing bean code, "Form.java", we will edit the action method, "" as follows:

public String commandButton1_action() {
     // Call BPEL Web service through Proxy Class
     float returnedRate = 0;
     try {
       proxy.CheaploansWSSoapHttpPortClient myPort = new proxy.CheaploansWSSoapHttpPortClient();
       returnedRate = myPort.invokeCompareLoan((String)inputText1.getValue());
     }
     catch (Exception e) {
       e.printStackTrace();
     };
     // Display the returned value in the outputText field.
     outputText1.setValue(returnedRate);

     return "Success";
}

Now when the button is clicked at runtime, the proxy class, myPort, will be instantiated and the invokeCompareLoan( ) method is invoked and the Social Security value passed from the form is supplied as an argument. The BPEL Web service initiates on the BPEL Process Manager server and determines the lowest loan rate and returns it into the returnedRate float variable. This variable is then applied to the Output Text (outputText1) Faces UI component and a "success" String is returned (Figure 17).

When the JSF application is run, the form will appear in a browser, and when a Social Security number is entered and the button is clicked, the BPEL Process Web Service would be called and the lowest returned rate determined by the BPEL process will be displayed in the JSF form.

Summary
With SOA comes the unique possibility to easily couple vastly different sets of services together into single, cohesive business service. When accompanied with a JSF-based user interface, a BPEL process can then offer its services through a rich user interface.

As our example has shown, building a composite SOA application with an included JSF-based user interface is actually a straightforward process. When a tool such as Oracle JDeveloper 10g is used, it can easily be accomplished in an entirely visual manner.

More Stories By Chris Schalk

Chris Schalk is a Tech Lead in the Developer API Evangelism group at Google. He is also one of the original members of the OpenAjax Alliance. Prior to Google, Chris was a Principal Product Manager and Java Evangelist for Oracle's application server and development tools division. While at Oracle, he worked to define the overall web development experience for Oracle JDeveloper and ADF Faces (Trinidad). He is also the co-author of JavaServer Faces: The Complete Reference published through McGraw-Hill Osborne (ISBN: 0072262400) and maintains a popular Blog on J2EE Web development at www.jroller.com/page/cschalk.

More Stories By Michael O'Neill

Michael O'Neill is manager of developer programs at Oracle, with six years of experience in Web and UI development utilizing both Java and Microsoft technologies.

Comments (3) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
Mark 05/01/07 12:47:16 PM EDT

Hi,

I have attempted to use the example (http://java.sys-con.com/read/192427.htm)with JDeveloper 10.1.3, and
I keep running into the same error when I compile the BPEL, it complains regarding
the "soc_security" global variable - "make sure variable with messageType definition is used" this
is just a local variable to pass a value around?

Any comments/suggestions regarding how I can fix this issue would be most appreciated.

Details from JDeveloper below.

Error(84):
[Error ORABPEL-10032]: missing messageType
[Description]: in line 84 of "C:\002_DEV\loanMark1\loanMark1\bpel\loanMark1.bpel",
variable "soc_security" of invoke does not have a messageType definition..
[Potential fix]: make sure variable with messageType definition is used in incoming
and outgoing activities.

Error(84):
[Error ORABPEL-10032]: missing messageType
[Description]: in line 84 of "C:\002_DEV\loanMark1\loanMark1\bpel\loanMark1.bpel",
variable "soc_security" of invoke does not have a messageType definition..
[Potential fix]: make sure variable with messageType definition is used in incoming and outgoing activities.

Thank you

Fred Holahan 03/17/06 10:39:59 AM EST

Guys,

I enjoyed your piece entitled "Putting a Face on Web Services and SOA". With regard to BPEL, you really should check out Active Endpoints. We offer a world-class, Eclipse based BPEL designer FOR FREE, and servers that range from our open source ActiveBPEL Engine all the way up to enterprise class BPEL solutions for popular J2EE containers.

Readers who want to download the free ActiveBPEL Designer can do so at http://www.active-endpoints.com/products/activebpeldes/index.html. Readers who need access to commercial grade open source BPEL engine can visit http://www.activebpel.org.

Fred

SYS-CON Italy News Desk 03/16/06 08:23:04 PM EST

Service-Oriented Architecture (SOA) is a hot topic among analysts, CIOs, and technology marketers, but the path from high-level architectural principles to programming a functioning, real-world service isn't always clear, especially since, in the end, you still need to create a clean user interface that's as flexible as the services it consumes.