SunQuest
 
       Graphic Design
  Home arrow Graphic Design arrow Page 6 - Working with Web Services
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
Moblin 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
IBM developerWorks
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
GRAPHIC DESIGN

Working with Web Services
By: Albert J. Saganich, Jr.
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 8
    2004-06-28

    Table of Contents:
  • Working with Web Services
  • Web Services Benefits for Service Developers
  • Understanding SOAP, WSDL, and UDDI and Their Place in WebLogic Workshop
  • Developing Web Services
  • Using Web Services Within Workshop Applications
  • Using Web Services from Standalone Applications
  • Conversations
  • Web Service Security
  • Associating Security with Web Services

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    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.

    More Graphic Design Articles
    More By Albert J. Saganich, Jr.


     

    GRAPHIC DESIGN ARTICLES

    - 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
    - The Pen is Mightier than the Brush Tool






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway