0%

Book Description

BEA WebLogic Workshop is a rapid application development tool that makes building Java-based Web service applications simple. With just a basic foundation of Java programming, you can use WebLogic Workshop to develop Web services. BEA WebLogic Workshop Kick Start provides everything you need to get started with WebLogic Workshop, including a quick Java primer and appendixes covering the essentials of XML, SOAP and WSDL. Learn the features of WebLogic Workshop and review hundreds of code examples, and explore the inner workings of this new tool.

The book's CD-ROM contains all the source code and examples from the book, plus a 90-day trial version of BEA WebLogic Platform, which includes WebLogic Workshop.

Foreword

Web services have attracted much attention recently as the next "big thing" in computing technology. Vendors of all shapes and sizes have announced their support for Web services technologies, and every month a new Web services conference is popping up somewhere on the globe. With all this hype and attention, sometimes it¿s difficult to really discover what Web services are, where they fit in your company, what the business case is, and how you can actually get started taking advantage of this technology.

BEA has been working with customers to answer many of these questions, and provide solutions that enable companies to easily construct Web services that meet their needs today. Contrary to the common conception of Web services as a consumer-focused technology, Web services may have the greatest potential as a technology inside enterprises as a new way of tying disparate applications together using standards-based technologies. To make Web services really work in the enterprise, however, it¿s essential that they meet core enterprise requirements: Web services applications have to exist in a constantly changing IT environment where different applications are built and modified by different people on different schedules. They must accommodate everything from modern J2EE-based applications, to legacy systems, to applications at business partners. They must be able to handle rich and complex information and transmit it between internal and external applications. They must easily interact with other applications to leverage existing investments. They must be robust, reliable, and they must perform. Perhaps most important of all, they have to be easy to build. For Web services to flourish within an organization, all developers will need to be able to build Web services that meet these requirements.

BEA WebLogic Workshop Kick Start introduces you to BEA¿s new WebLogic Workshop product, a development tool and runtime framework that makes it easy to build powerful Web services that take advantage of the robust, enterprise features of the WebLogic J2EE application server. WebLogic Workshop provides a graphical tool that makes it easy to visualize, develop, and test Web service applications and visual controls that dramatically simplify access to existing resources like databases, packaged applications, Enterprise Java Beans, and other Web services. The Workshop framework provides out-of-the-box support for building Web services that are loosely coupled so that the internal implementation details of an application can be cleanly separated from the "public contract" that a Web service offers to other applications. This makes Workshop Web services flexible in the face of a constantly changing IT environment. Workshop also provides built-in support for asynchronous messaging so that Web service applications can carry on rich, two-way conversations with their clients and accommodate interaction with legacy systems and human users. Finally, Workshop supports easy manipulation of coarse-grained messages so that rich documents can be handled without resorting to tedious XML DOM programming. All of these capabilities can be accessed in a simple, declarative fashion that enables all developers not just J2EE experts to get started building Web services today.

Even if you are new to the Java programming language, or have never built a J2EE application before, I think you¿ll be surprised how easy it is to get started with Workshop. Working inside the WebLogic Workshop environment, you can focus on the procedural business code that is important to getting your applications built and leave all of the details of Web service and J2EE plumbing to the application framework. BEA WebLogic Workshop Kick Start will give you an introduction to Web services in general, and teach you the few Java and J2EE concepts you¿ll need to know along the way. Rich with examples, this book illustrates the power of Web services, and will help you realize the value they can bring to your company.

--Carl Sjogreen, Product Manager, WebLogic Workshop, BEA Systems, Inc

Table of Contents

  1. Copyright
    1. Dedication
  2. Preface
  3. About the Authors
  4. Acknowledgments
  5. Tell Us What You Think!
  6. Introduction
    1. Who Should Buy This Book
    2. How This Book Is Organized
    3. Conventions Used in This Book
    4. Source Code and Updates
    5. System Requirements
  7. I. Introduction to WebLogic Workshop
    1. 1. Introduction to Web Services
      1. What Are Web Services?
      2. Examples of Web Services
      3. Advantages of Web Services
      4. Disadvantages of Web Services
      5. The Web Service Protocols
        1. XML
        2. SOAP
        3. WSDL
        4. UDDI
      6. Why Use WebLogic Workshop?
    2. 2. The WebLogic Workshop
      1. Verify That Everything Is Functional
        1. Open the Samples Project
        2. Testing HelloWorld
        3. Starting the WebLogic Server
        4. Starting the HelloWorld Service
        5. Running HelloWorld
        6. Understanding the Output
      2. Overview of the Workshop Environment
        1. The Project Tree
          1. The CreditReport Example
        2. Structure Pane
        3. Hide and Show Panes
        4. Design View
          1. Structural View of the Service
          2. Properties Pane
          3. Description
          4. Tasks
          5. Source View
        5. Test View
      3. Changing the Workshop Environment
        1. Changing the Display Properties
        2. Changing the Editor Settings
          1. Design View Sorting
          2. Indentation
          3. Code Completion
        3. Changing Colors
        4. Configuring System Paths
          1. WebLogic Development Server
          2. Browser Path
    3. 3. Building an Application in WebLogic Workshop
      1. Creating a Project
      2. Creating the HelloWorld Service
        1. Add a Method
        2. Go to Source of Message
        3. Return a Value
        4. Define Response
      3. Testing Your New Service
        1. Build the File
        2. Run the Service
        3. Stop the Service
      4. Passing Information to the Service
        1. Build and Rerun the Program
      5. The JWS File
      6. Adding Methods in Code
        1. JavaDoc Comments
        2. Creating an Operation Method
        3. Creating the helloByHand() Method
      7. Adding a Description
        1. Adding Method Descriptions
        2. Adding a Description for the Whole Service
    4. 4. Developing Conversant Applications
      1. Conversations
      2. A Two-Stage Conversation
        1. Starting a Conversation
        2. Declaring a Class Variable
        3. Edit the Method
        4. Workshop JavaDoc Variables
        5. Continuing a Conversation
        6. Finishing a Conversation
      3. Testing HelloConversation
        1. Continuing the Conversation
        2. Finishing the Conversation
        3. Begin a New Conversation
      4. Why Is Asynchronous Activity Different from Synchronous Activity?
        1. Diagrams of Synchronous Activity Versus Asynchronous Activity
          1. A Political Debate as an Example
        2. Appropriate Situations to Use Asynchrony
      5. Limitations and Advantages
        1. Advantages
          1. Clients Don’t Have to Wait
          2. More Transport Protocols Available
        2. Limitations
          1. Not Supported by All Web Service Platforms
          2. Clients Usually Must Be Multithreaded
          3. Blocking Responses Are Difficult
      6. What Makes HelloConversation Synchronous?
      7. HelloConversation as an Asynchronous Conversation
        1. Creating a Buffered Message
        2. Buffer JavaDoc Comments
      8. Adding a Callback
        1. Changing the Parameters of the Callback
        2. Editing the Callback Manually
        3. Calling the Callback Method
      9. Testing HelloConversationAsync
        1. Refreshing the List
      10. Buffering a Callback
      11. Timeout Parameters
        1. Defining the Entire Lifetime of a Conversation
        2. Defining the Idle Timeout Values
        3. Changing the Timeout Values in Code
          1. Setting the Idle Time
          2. Setting Maximum Age
      12. Cleaning Up After Your Conversation Ends
        1. Creating an onFinish() Method
  8. II. Building Applications in WebLogic Workshop
    1. 5. Controls
      1. Using a Timer
      2. Creating HelloDelayed
        1. Adding the Timer Control
        2. Starting the Timer
        3. Defining onTimeout
      3. Testing HelloDelayed
      4. Stopping the Timer
      5. Defining a Timer Control in Code
        1. The @control Tag
        2. The @jws:timer Tag
        3. Specifying Time in Workshop
          1. Getting the Timer to Fire Immediately
        4. Repeated Firing
        5. Coalesce of Events
      6. Adjusting Timing Defaults Programmatically
        1. Changing the Timeout Time
        2. Obtaining Current Timeout
        3. Changing/Obtaining the Repeats-Every Value
        4. Toggling Coalesce Events
      7. Restarting the Timer
      8. Obtaining Time at Event
      9. Broadcast Date Example
      10. HelloWorld as a Service
        1. Creating the Control File
        2. Using a CTRL in Another Service
          1. Drag and Drop from Project Tree
          2. Adding the Control from the Design Panel
          3. Invoking CTRL Methods
          4. Testing HelloAggregate
          5. Including a CTRL in Code
          6. Exceptions from CTRL Methods
        3. Accessing a CTRL File That Is Not in the Current Package
        4. Using a CTRL File from a Different Project
      11. Handling Callbacks from CTRLs
    2. 6. The Database Control
      1. Creating a Database Control
      2. Defining a Database Connection
      3. Creating an SQL String
        1. Selecting Values
        2. Updating Values
        3. Inserting Values
        4. Deleting Values
        5. Joining Tables
      4. Including Variables
      5. Getting a Result Set
        1. Returning a Variable
        2. Returning a Row of Results
        3. Returning a Class
        4. Returning a HashMap
        5. Returning a Multiple Row Result Set in a Container
      6. Executing Multiple Statements
      7. A Sample Application
    3. 7. Debugging
      1. Debugging in WebLogic Workshop
      2. Debugging a Web Service
        1. Start
        2. Setting Breakpoints
        3. Stepping Through Code
          1. Step Into
          2. Step Out
          3. Step Over
        4. Continue
      3. Variables
        1. Locals
        2. Watching Variables
      4. The Call Stack
  9. III. Declaring Maps and Controls
    1. 8. Creating a Map
      1. Customizing XML Content
      2. Building XML Maps Using Workshop
        1. Input Maps
        2. Output Maps
      3. XML Map Elements
        1. <xm:value>
        2. <xm:attribute>
        3. Mapping Java Objects
        4. Declaring Map Variables
        5. Including Multiple Elements
      4. Storing Maps in External Files
      5. Using XMLScript
        1. ECMAScript Overview
        2. XML Scripts
        3. ECMAScript and XML
        4. Extracting Parameters from XML Data
        5. Mapping XML into Java with ECMAScript
    2. 9. Messaging Using JMS
      1. Connections and Connection Factories
      2. Sessions
      3. Sending and Receiving
      4. Using the JMS Control
        1. Sending Queue Messages
        2. Receiving Queue Messages
        3. Sending Topic Messages
        4. Receiving Topic Messages
      5. JMS JavaDoc Options
      6. Sending XML Messages
    3. 10. Including an EJB Control
      1. EJB Overview
      2. Including an EJB in Your Workshop Project
      3. An EJB Control Example
      4. EJB JavaDoc Options
    4. 11. Accessing Web Services from Java
      1. The Client Side of Web Services
      2. Java Proxy Details
      3. JavaServer Pages and the Java Proxy
      4. Using the Proxy Outside the WebLogic Environment
      5. Changing the Web Service Location
    5. 12. @jws JavaDoc Tags
      1. Method Tags
        1. @jws:conversation—Define Conversation Boundaries
        2. @jws:operation—Label a Method as a Web Service Method
        3. @jws:parameter-xml—Define Incoming XML Format
        4. @jws:return-xml—Define Outgoing XML Format
        5. @jws:sql—Define SQL Statement
        6. @jws:target-namespace—Specify Namespace for Outgoing Messages
      2. Control Tags
        1. @jws:connection—Define a Database Connection
        2. @jws:ejb—Specify an EJB Home Interface
        3. @jws:jms—Configure a JMS Control
        4. @jws:jms-header—Specify the Format of a JMS Header
        5. @jws:jms-message—Specify the Format of a JMS Message
        6. @jws:jms-property—Specify JMS Message Properties
        7. @jws:timer—Configure a Timer Control
      3. Defining Filewide Enhancements
        1. @jws:conversation-lifetime
        2. @jws:define—Create Inline Files
        3. @jws:protocol—Specify Web Service Protocols
        4. @jws:schema—Use an XML Schema
        5. @jws:wsdl—Use a WSDL File
        6. @jws:xmlns—Specify an XML Namespace
    6. 13. An Online Ordering System
      1. Designing an Ordering System
      2. Working with the Database
        1. Creating the Database Tables
        2. Creating the Database Control
      3. Creating the OrderEntry Service
      4. Creating the OrderTracking Service
  10. IV. Appendixes
    1. A. Java Essentials
      1. Your First Java Program
      2. Declaring Variables
        1. Values
        2. Object References
      3. Operators
      4. Conversions
      5. Classes and Objects
      6. Control Flow
        1. if-else
        2. while
        3. for
        4. switch
        5. continue and break
        6. return
      7. Exceptions
      8. Interfaces
      9. Packages
      10. Common Java Packages
        1. java.lang
        2. java.io
        3. java.util
        4. java.net
        5. java.sql
      11. Where to Go from Here
    2. B. XML
      1. What Is XML?
        1. Why Use XML?
      2. XML Basics
        1. Elements
        2. Attributes
        3. Comments
        4. Data
        5. Document Type Definitions
      3. XML Schema
        1. XML Schema Basics
          1. Defining Elements
          2. Supported Data Types
          3. Defining Simple Types
          4. Defining Complex Types
          5. Attributes
          6. Mixed Content
        2. Using XML Schema in a JWS File
      4. Related XML Specifications
        1. XML Namespaces
        2. XSL
        3. XPath
    3. C. Web Service Description Language (WSDL)
      1. History of WSDL
      2. WSDL in Workshop
      3. Obtaining the WSDL Definition for Any Service in Workshop
        1. Generate a WSDL for Your Service
        2. View Current WSDL for Service
      4. Utilizing an External Web Service When You Have Its WSDL URL
      5. Creating a Service That Complies with a WSDL File
      6. WSDL Definition
      7. Communication Processes
      8. Types
        1. Creating the Address Type for the WSDL Document
      9. Messages
        1. Using Elemental Form to Create Messages
        2. Using Types to Create Messages
      10. Operations
        1. Types of Operations
        2. Creating a One-Way Operation
        3. Creating a Request/Response Operation
        4. Creating a Notification Operation
        5. Creating a Solicit/Response Operation
      11. Port Type
        1. Creating a Port Type with a One-Way Operation
      12. Binding
        1. Binding myMethod to SOAP over HTTP
        2. Binding myMethod to Multiple Transports
      13. Port
        1. Defining a Port
      14. Service
        1. Declaring the Service
        2. Combining Port Types Within a Service
    4. D. SOAP
      1. SOAP Message Exchange
      2. Web Services and SOAP
      3. SOAP Message Format
      4. SOAP Data Encoding
      5. SOAP over HTTP
      6. SOAP Headers
3.145.77.114