Home arrow Graphic Design arrow Page 6 - Working with Web Services
GRAPHIC DESIGN

Working with Web Services


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.

Author Info:
By: Albert J. Saganich, Jr.
Rating: 4 stars4 stars4 stars4 stars4 stars / 15
June 28, 2004
TABLE OF CONTENTS:
  1. · Working with Web Services
  2. · Web Services Benefits for Service Developers
  3. · Understanding SOAP, WSDL, and UDDI and Their Place in WebLogic Workshop
  4. · Developing Web Services
  5. · Using Web Services Within Workshop Applications
  6. · Using Web Services from Standalone Applications
  7. · Conversations
  8. · Web Service Security
  9. · Associating Security with Web Services

print this article
SEARCH DEVARTICLES

Working with Web Services - Using Web Services from Standalone Applications
(Page 6 of 9 )

As you've seen, using Web services from within a Workshop application is easy. But what about using Workshop-created Web services from within a standalone Java client or JSP page?


Preparing to Run client.java - Windows developers can run the client example by modifying the prompt.cmd file found in chapter09standalone and pointing the BEA_HOME directory to the location of your WebLogic Platform install. Double-clicking the command file opens a property-configured DOS window with the appropriate classpath and path settings. Unix developers need only run the commEnv.sh shell script found in weblogic81/common/bin and add the provided JAR files to the classpath.


Workshop-based Web services provide proxy JAR files that enable standalone clients to call Web services directly. Listing 9.1 details a simple Java client that uses the checkcredit method of the client service's Web service.

Listing 9.1 client.java

import weblogic.jws.proxies.*;

public class client {
  public static void main(String[] args) {
    try {
      System.out.println("Attempting to get credit services proxy");
      CreditServices_Impl proxy = new CreditServices_Impl();
      System.out.println("Using proxy to get service object instance");
      CreditServicesSoap sp = proxy.getcreditServicesSoap();
      System.out.println("Calling service method");
      System.out.println("check credit(Al,100) returned:" +
        + sp.checkcredit("Al",100));
      System.out.println("check credit(Tom,1000) returned:" +
        sp.checkcredit("Tom",1000));
      System.out.println("check credit(Unknown,1000) returned:" +
        sp.checkcredit("Unknown",1000));
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }
}

Using a Web service from a Java client requires first downloading the client proxy JAR and its associated Web service's support JAR file (in this example, creditServices.jar and webservicesclient.jar), and then adding them to the application's classpath.

After you've obtained the required JARs, using the Web service is a three-step coding process:

  1. Obtain a handle to the proxy implementation of the service. Using the CreditServices Web service, you simply append _Impl to the name of the Web service. Notice that Workshop capitalizes the first letter of the name:CreditServices_Impl proxy = new CreditServices_Impl();
  2. Obtain a handle to a SOAP proxy:CreditServicesSoap sp = proxy.getcreditServicesSoap();
  3. For all practical purposes, you can think of the SOAP proxy as though it were an instance of a local Java object implementing the actual business method you're interested in.

  4. Finally, call the method of interest: System.out.println("check credit(Al,100) returned:" + sp.checkcredit("Al",100));

Of course, you can also use the client normally from a JSP by writing similar code, but embedding it appropriately within <% and %> JSP tags.


Java Clients and Web Service URLs - It is assumed that the URL of the Web service implementation the client is using is the same as the URL where the client JAR file was downloaded. However, the actual URL is contained in the client JAR file WSDL within the WSDL address element. You can change this element if needed to access the same Web service at a different location, perhaps when moving from development to testing or from testing to production.


SamsThis 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.

Buy this book now.


blog comments powered by Disqus
GRAPHIC DESIGN ARTICLES

- Customizing Wordpress Favicons and Gravatars
- Building Corner Effects with Transparent Bac...
- 3D Graphics Technology: VRML Part I - Introd...
- Creating Visual Effects
- Web Page Design Overview
- Creating Artistic Photographs
- Working with Tools in Paint Shop Pro 8
- Using HTML Quickform for Form Processing
- Introduction to Adobe FrameMaker
- WebLogic Workshop, WebLogic Platform, and th...
- Planning the Site
- Working with Web Services
- WebLogic Workshop Application Development Ba...
- Scanning Images for Web Use
- Web Graphics Overview

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials