Java and SOAP.pdf

(2763 KB) Pobierz
Java and SOAP
1003724.001.png
Java and SOAP
Robert Englander
Publisher: O'Reilly
Edition May 2002
ISBN: 0-596-00175-4, 276 pages
Java™ and SOAP provides Java developers with an in-depth look at SOAP (the Simple
Object Access Protocol). Of course, it covers the basics: what SOAP is, why it's soared to
a spot on the Buzzwords' Top Ten list, and what its features and capabilities are. And it shows
you how to work with some of the more common Java APIs in the SOAP world: Apache
SOAP and GLUE.
Java™ and SOAP also discusses interoperability between the major SOAP platforms,
including Microsoft's .NET, SOAP messaging, SOAP attachments, message routing, and
a preview of the forthcoming AXIS APIs and server. If you're a Java developer who would
like to start working with SOAP, this is the book you need to get going.
Dedication ............................................................................................................................. 1
Preface ................................................................................................................................... 2
Intended Audience.............................................................................................................. 2
A Moment in Time ............................................................................................................. 2
How This Book Is Organized............................................................................................. 3
Conventions Used in This Book......................................................................................... 4
How to Contact Us ............................................................................................................. 5
Retrieving Examples Online .............................................................................................. 5
Acknowledgments .............................................................................................................. 6
Chapter 1. Introduction ....................................................................................................... 7
1.1 RPC and Message-Oriented Distributed Systems ........................................................ 7
1.2 Self-Describing Data .................................................................................................... 8
1.3 XML ............................................................................................................................. 9
1.4 API Specs Versus Wire-Level Specs ........................................................................... 9
1.5 Overview of SOAP..................................................................................................... 10
1.6 SOAP Implementations.............................................................................................. 11
1.7 The Approach ............................................................................................................. 12
1.8 Getting Started............................................................................................................ 13
Chapter 2. The SOAP Message ......................................................................................... 14
2.1 The HTTP Binding..................................................................................................... 14
2.2 HTTP Request ............................................................................................................ 14
2.3 HTTP Response.......................................................................................................... 16
2.4 The SOAP Envelope .................................................................................................. 18
2.5 The Envelope Element ............................................................................................... 21
2.6 The Header Element................................................................................................... 21
2.7 The actor Attribute ..................................................................................................... 22
2.8 The mustUnderstand Attribute ................................................................................... 22
2.9 The encodingStyle Attribute ...................................................................................... 23
2.10 Envelope Versioning ................................................................................................ 24
2.11 The Body Element.................................................................................................... 25
2.12 SOAP Faults ............................................................................................................. 25
Chapter 3. SOAP Data Encoding...................................................................................... 29
3.1 Schemas and Namespaces .......................................................................................... 29
3.2 Serialization Rules...................................................................................................... 31
3.3 Indicating Type .......................................................................................................... 34
3.4 Default Values............................................................................................................ 45
3.5 The SOAP Root Attribute .......................................................................................... 46
Chapter 4. RPC-Style Services.......................................................................................... 47
4.1 SOAP RPC Elements ................................................................................................. 47
4.2 A Simple Service........................................................................................................ 52
4.3 Deploying the Service ................................................................................................ 53
4.4 Writing Service Clients .............................................................................................. 63
4.5 Deploying with Request-Level Scope........................................................................ 71
4.6 Deploying with Session-Level Scope ........................................................................ 72
4.7 Passing Parameters ..................................................................................................... 74
Chapter 5. Working with Complex Data Types .............................................................. 85
5.1 Passing Arrays as Parameters..................................................................................... 85
5.2 Returning Arrays ........................................................................................................ 93
5.3 Passing Custom Types as Parameters ........................................................................ 96
5.4 Returning Custom Types.......................................................................................... 107
Chapter 6. Custom Serialization..................................................................................... 113
6.1 Custom Type Encoding ............................................................................................ 113
Chapter 7. Faults and Exceptions ................................................................................... 136
7.1 Throwing Server-Side Exceptions in Apache SOAP ............................................... 136
7.2 Creating a Fault Listener in Apache SOAP ............................................................. 139
7.3 Throwing and Catching Exceptions in GLUE ......................................................... 143
Chapter 8. Alternative Techniques................................................................................. 147
8.1 SOAP Messaging ..................................................................................................... 147
8.2 Literal Encoding ....................................................................................................... 157
Chapter 9. SOAP Interoperability and WSDL ............................................................. 170
9.1 Web Services Definition Language.......................................................................... 170
9.2 Calling a GLUE Service from an ApacheSOAP Client ........................................... 179
9.3 A Proxy Service Using Apache SOAP .................................................................... 184
9.4 Calling an Apache SOAP Service from a GLUE Client .......................................... 189
9.5 Accessing .NET Services ......................................................................................... 194
9.6 Writing an Apache Axis Client ................................................................................ 199
Chapter 10. SOAP Headers............................................................................................. 202
10.1 Apache SOAP Providers and Routers .................................................................... 202
10.2 Replacing the Provider and Router Classes ........................................................... 203
10.3 An Apache SOAP Service That Handles SOAP Headers...................................... 207
Chapter 11. JAX-RPC and JAXM ................................................................................. 213
11.1 JAX-RPC................................................................................................................ 213
11.2 Working Without Ant............................................................................................. 215
11.3 Creating a JAX-RPC Service ................................................................................. 215
11.4 Creating a JAX-RPC Client ................................................................................... 221
11.5 Generating Stubs from WSDL ............................................................................... 222
11.6 Dynamic Invocation Interface ................................................................................ 224
11.7 JAXM, in Less Than a Nutshell ............................................................................. 224
11.8 What Next?............................................................................................................. 225
Colophon ........................................................................................................................... 226
Java and SOAP
Dedication
Once again, for my daughter Jessica.
1
Zgłoś jeśli naruszono regulamin