Debian Codegraph @

docs/user-guide.html

raw
1 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5 <title>Axis User's Guide</title>
6 <link href="axis.css" rel=stylesheet type=text/css>
7 </head>
8 <body >
9
10 <center>
11 <h1>
12 <img SRC="images/axis.jpg" height=96 width=176></h1></center>
13
14 <h1>Axis User's Guide</h1>
15 <i>1.4 Version</i>
16 <br><i>Feedback: <a href="mailto:[email protected]">[email protected]</a></i>
17
18 <h3>
19 Table of Contents</h3>
20
21 <ul>
22 <li> <a href="#Introduction">Introduction</a></li>
23 <li> <a href="#Installation">Installing Axis</a></li>
24 <li> <a href="#ConsumingServices">Consuming Web Services with Axis</a></li>
25 <li> <a href="#PublishingServices">Publishing Web Services with Axis</a></li>
26 <li> <a href="#DataMapping">XML &lt;-&gt; Java Data Mapping in Axis</a></li>
27 <li> <a href="#WSDL">Using WSDL with Axis</a></li>
28 <ul>
29 <li> <a href="#WSDL: Obtaining WSDL for deployed services">?WSDL: Obtaining
30 WSDL for deployed services</a></li>
31 <li> <a href="#WSDL2Java: Building stubs, skeletons, and data">WSDL2Java:
32 Building stubs, skeletons, and data</a></li>
33 <li> <a href="#Java2WSDL: Building WSDL from Java">Java2WSDL: Building
34 WSDL from Java</a></li>
35 </ul>
36 <li> <a href="#published interfaces">Published Interfaces</a></li>
37 <li> <a href="#newbie">Newbie Tips: Finding Your Way Around</a></li>
38 <li> <a href="#tcpmon">Appendix : Using TCPMon</a></li>
39 <li> <a href="#soapmon">Appendix : Using SOAP Monitor</a></li>
40 <li> <a href="#Glossary">Glossary</a></li>
41 </ul>
42
43 <h2>
44 <a NAME="Introduction"></a>Introduction</h2>
45 Welcome to Axis, the third generation of Apache SOAP!
46 <h3>
47 What is SOAP?</h3>
48
49 <p>
50 SOAP is an XML<i>-</i>based communication protocol and encoding format for inter-application
51 communication. Originally conceived by Microsoft and Userland software, it has
52 evolved through several generations; the current spec is version,
53 <a href="http://w3.org/TR/soap">SOAP 1.2</a>, though version1.1 is more
54 widespread. The W3C's <a href="http://www.w3.org/2000/xp/Group/">XML
55 Protocol working group</a> is in charge of the specification.
56 </p>
57 <p>SOAP is widely viewed as the backbone to a new generation of cross-platform
58 cross-language distributed computing applications, termed Web Services.
59 </p>
60 <h3>
61 What is Axis?</h3>
62 Axis is essentially a <i>SOAP engine</i> -- a framework for
63 constructing SOAP processors such as
64 clients, servers, gateways, etc.
65 The current version of Axis is written in Java, but
66 a C++ implementation of the client side of Axis is being developed.
67 <p>
68 But Axis isn't just a SOAP engine -- it also includes:
69 <ul>
70 <li> a simple stand-alone server,
71 <li> a server which plugs into servlet engines such as Tomcat,
72 <li> extensive support for the <i>Web Service Description Language (WSDL)</i>,
73 <li> emitter tooling that generates Java classes from WSDL.
74 <li> some sample programs, and
75 <li> a tool for monitoring TCP/IP packets.
76 </ul>
77 <p>
78 Axis is the third generation of Apache SOAP (which began at IBM as "SOAP4J").
79 In late 2000, the committers of Apache SOAP v2 began discussing
80 how to make the engine much more flexible, configurable, and able to handle
81 both SOAP and the upcoming XML Protocol specification from the W3C.
82 <p>After a little while, it became clear that a ground-up rearchitecture
83 was required. Several of the v2 committers proposed very similar designs,
84 all based around configurable "chains" of message "handlers" which would
85 implement small bits of functionality in a very flexible and composable
86 manner.
87 <p>After months of continued discussion and coding
88 effort in this direction, Axis now delivers the following key features:
89 <ul>
90 <li> <b>Speed.</b> Axis uses SAX (event-based) parsing to acheive significantly
91 greater speed than earlier versions of Apache SOAP.</li>
92 <li> <b>Flexibility.</b> The Axis architecture gives the developer complete
93 freedom to insert extensions into the engine for custom header processing,
94 system management, or anything else you can imagine.</li>
95 <li> <b>Stability.</b> Axis defines a set of <a href="#published interfaces">published
96 interfaces</a> which change relatively slowly compared to the rest of Axis.</li>
97 <li> <b>Component-oriented deployment.</b> You can easily define reusable networks
98 of Handlers to implement common patterns of processing for your applications,
99 or to distribute to partners.</li>
100 <li> <b>Transport framework.</b> We have a clean and simple abstraction for
101 designing transports (i.e., senders and listeners for SOAP over various protocols
102 such as SMTP, FTP, message-oriented middleware, etc), and the core of the
103 engine is completely transport-independent.</li>
104 <li><b>WSDL support.</b> Axis supports the <a href="http://www.w3.org/TR/wsdl">Web
105 Service Description Language</a>, version 1.1, which allows you to easily
106 build stubs to access remote services, and also to automatically export machine-readable
107 descriptions of your deployed services from Axis.</li>
108 </ul>
109 <p>
110 We hope you enjoy using Axis. Please note that this is an open-source effort
111 - if you feel the code could use some new features or fixes, please get
112 involved and lend a hand! The Axis developer community welcomes your
113 participation. And in case you're wondering what <i>Axis</i> stands for,
114 it's <b>A</b>pache E<b>X</b>tensible <b>I</b>nteraction <b>S</b>ystem -
115 a fancy way of implying it's a very configurable SOAP engine.
116 <h4>
117 <b>Let us know what you think!</b></h4>
118 Please send feedback about the package to "<a href="mailto:[email protected]">[email protected]</a>".
119 Also, Axis is registered in <a href="http://nagoya.apache.org/bugzilla">bugzilla</a>,
120 the Apache bug tracking and feature-request database.
121 <h3>
122 What's in this release?</h3>
123 This release includes the following features:
124 <ul>
125 <li> SOAP 1.1/1.2 compliant engine</li>
126 <li> Flexible configuration / deployment system</li>
127 <li> Support for "drop-in" deployment of SOAP services (JWS)</li>
128 <li> Support for all basic types, and a type mapping system for defining new
129 serializers/deserializers</li>
130 <li> Automatic serialization/deserialization of Java Beans, including customizable
131 mapping of fields to XML elements/attributes</li>
132 <li> Automatic two-way conversions between Java Collections and SOAP Arrays</li>
133 <li> Providers for RPC and message based SOAP services</li>
134 <li> Automatic WSDL generation from deployed services</li>
135 <li> WSDL2Java tool for building Java proxies and skeletons from WSDL documents</li>
136 <li> Java2WSDL tool for building WSDL from Java classes.</li>
137 <li> Preliminary security extensions, which can integrate with Servlet 2.2 security/roles</li>
138 <li>Support for session-oriented services, via HTTP cookies or transport-independent
139 SOAP headers</li>
140 <li>Preliminary support for the <b>SOAP with Attachments</b> specification</li>
141 <li> An EJB provider for accessing EJB's as Web Services</li>
142 <li> HTTP servlet-based transport</li>
143 <li> JMS based transport</li>
144 <li> Standalone version of the server (with HTTP support)</li>
145 <li> Examples, including a client and server for the SoapBuilders community
146 interoperability tests and experimental TCP, JMS, and file-based transports.</li>
147 </ul>
148
149 <h3> What's still to do?</h3>
150 <p>Please click for <a href="to-do.html">a list of what we think needs doing</a>
151 - and please consider helping out if you're interested &amp; able!</p>
152
153 <h2>
154 <a NAME="Installation"></a>Installing Axis and Using this Guide</h2>
155 See the <a href="install.html">Axis Installation Guide</a>
156 for instructions on installing Axis as a web application on your J2EE server.
157 <p>Before running the examples in this guide, you'll need to make sure
158 that your CLASSPATH includes
159 (Note: If you build Axis from a CVS checkout,
160 these will be in xml-axis/java/build/lib instead of axis-1_2/lib):
161 <ul>
162 <li>axis-1_2/lib/axis.jar</li>
163 <li>axis-1_2/lib/jaxrpc.jar</li>
164 <li>axis-1_2/lib/saaj.jar</li>
165 <li>axis-1_2/lib/commons-logging.jar</li>
166 <li>axis-1_2/lib/commons-discovery.jar</li>
167 <li>axis-1_2/lib/wsdl4j.jar</li>
168 <li>axis-1_2/ <i><font color="#9966FF">(for the sample code)</font></i></li>
169 <li>A JAXP-1.1 compliant XML parser such as Xerces or Crimson. We recommend
170 <A href="http://xml.apache.org/xerces2-j/">Xerces</A>, as it is the one
171 that the product has been tested against.</li>
172 </ul>
173 <h2>
174 <a NAME="ConsumingServices"></a>Consuming Web Services with Axis</h2>
175
176 <h3>
177 Basics - Getting Started</h3>
178 Let's take a look at an example Web Service client that will call the <b>echoString</b>
179 method on the public Axis server at Apache.
180 <pre class="example">1 import org.apache.axis.client.Call;
181 2 import org.apache.axis.client.Service;
182 3 import javax.xml.namespace.QName;
183 4
184 5 public class TestClient {
185 6 public static void main(String [] args) {
186 7 try {
187 8 String endpoint =
188 9 "http://nagoya.apache.org:5049/axis/services/echo";
189 10
190 11 Service service = new Service();
191 12 Call call = (Call) service.createCall();
192 13
193 14 call.setTargetEndpointAddress( new java.net.URL(endpoint) );
194 15 call.setOperationName(new QName("<font color="#009933">http://soapinterop.org/</font>", "<font color="#993333">echoString</font>"));
195 16
196 17 String ret = (String) call.invoke( new Object[] { "<font color="#CC00CC">Hello!</font>" } );
197 18
198 19 System.out.println("Sent 'Hello!', got '" + ret + "'");
199 20 } catch (Exception e) {
200 21 System.err.println(e.toString());
201 22 }
202 23 }
203 24 }</pre>
204 (You'll find this file in <a href="../samples/userguide/example1/TestClient.java">samples/userguide/example1/TestClient.java</a>)
205 <p>Assuming you have a network connection active, this program can be run
206 as follows:
207 <pre class="example">% java samples.userguide.example1.TestClient
208 Sent 'Hello!', got 'Hello!'
209 %</pre>
210 So what's happening here? On lines 11 and 12 we create new Service and
211 Call objects. These are the standard JAX-RPC objects that are used to store
212 metadata about the service to invoke. On line 14, we set up our endpoint
213 URL - this is the destination for our SOAP message. On line 15 we define
214 the operation (method) name of the Web Service. And on line 17 we actually invoke
215 the desired service, passing in an array of parameters - in this case just
216 one String.
217 <p>You can see what happens to the arguments by looking at the SOAP request that
218 goes out on the wire (look at the colored sections, and notice they match the
219 values in the call above):
220 <pre class="xml">&lt;?xml version="1.0" encoding="UTF-8"?>
221 &lt;SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
222 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
223 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
224 &lt;SOAP-ENV:Body>
225 &lt;ns1:<b><font color="#993333">echoString</font></b> xmlns:ns1="<b><font color="#009933">http://soapinterop.org/</font></b>">
226 &lt;arg0 xsi:type="xsd:string"><b><font color="#CC00CC">Hello!</font></b>&lt;/arg0>
227 &lt;/ns1:echoString>
228 &lt;/SOAP-ENV:Body>
229 &lt;/SOAP-ENV:Envelope></pre>
230 <p>The String argument is automatically serialized into XML, and the server
231 responds with an identical String, which we deserialize and print.</p>
232 <p><i>Note: To actually watch the XML flowing back and forth between a
233 SOAP client and server, you can use the included <a href="#tcpmon">tcpmon</a> tool or <a href="#soapmon">SOAP monitor</a> tool. See the appendix
234 for an overview.</i></p>
235 <h3>Naming Parameters</h3>
236 In the above example, you can see that Axis automatically names the XML-encoded
237 arguments in the SOAP message "arg0", "arg1", etc. (In this case there's just
238 &quot;arg0&quot;) If you want to change this, it's easy! Before calling <tt>invoke()</tt>
239 you need to call <tt>addParameter</tt> for each parameter and <tt>setReturnType</tt> for the return, like so:
240 <pre class="example"> call.addParameter("testParam",
241 org.apache.axis.Constants.XSD_STRING,
242 javax.xml.rpc.ParameterMode.IN);
243 call.setReturnType(org.apache.axis.Constants.XSD_STRING); </pre>
244 This will assign the name <b>testParam</b> to the 1st (and only) parameter
245 on the invoke call. This will also define the type of the parameter (<tt>org.apache.axis.Constants.XSD_STRING</tt>)
246 and whether it is an input, output or inout parameter - in this case its
247 an input parameter. Now when you run the program you'll get a message that
248 looks like this:
249 <pre class="xml">&lt;?xml version="1.0" encoding="UTF-8"?>
250 &lt;SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
251 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
252 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
253 &lt;SOAP-ENV:Body>
254 &lt;ns1:echoString xmlns:ns1="http://soapinterop.org/">
255 &lt;<font color="#CC00CC">testParam</font> xsi:type="xsd:string">Hello!&lt;/<font color="#CC00CC">testParam</font>>
256 &lt;/ns1:echoString>
257 &lt;/SOAP-ENV:Body>
258 &lt;/SOAP-ENV:Envelope></pre>
259 Note that the param is now named "testParam" as expected.
260 <h3>Interoperating with "untyped" servers</h3>
261 In the above examples, we've been casting the return type of invoke(),
262 which is Object, to the appropriate "real" type - for instance, we know
263 that the echoString method returns a String, so we expect to get one back
264 from client.invoke(). Let's take a moment and investigate how this happens,
265 which sheds light on a potential problem (to which, of course, we have
266 a solution - so don't fret :)).
267 <p>Here's what a typical response might look like to the echoString method: </p>
268 <pre class="xml">&lt;?xml version="1.0" encoding="UTF-8"?><br> &lt;SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
269 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
270 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
271 &lt;SOAP-ENV:Body>
272 &lt;ns1:echoStringResponse xmlns:ns1="http://soapinterop.org/">
273 &lt;result <font color="#FF0000">xsi:type="xsd:string"</font>>Hello!&lt;/result>
274 &lt;/ns1:echoStringResponse>
275 &lt;/SOAP-ENV:Body>
276 &lt;/SOAP-ENV:Envelope></pre>
277 <p>Take a look at the section which we've highlighted in <font color="#FF0000">red</font>
278 - that attribute is a schema <b>type declaration</b>, which Axis uses to figure
279 out that the contents of that element are, in this case, deserializable into a
280 Java String object. Many toolkits put this kind of explicit typing information
281 in the XML to make the message "self-describing". On the other hand, some toolkits
282 return responses that look like this: </p>
283 <pre class="xml">&lt;?xml version="1.0" encoding="UTF-8"?>
284 &lt;SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
285 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
286 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
287 &lt;SOAP-ENV:Body>
288 &lt;ns1:echoStringResponse xmlns:ns1="http://soapinterop.org/">
289 &lt;result>Hello, I'm a string!&lt;/result>
290 &lt;/ns1:echoStringResponse>
291 &lt;/SOAP-ENV:Body>
292 &lt;/SOAP-ENV:Envelope></pre>
293 <p>There's no type in the message, so how do we know what Java object we should
294 deserialize the &lt;result> element into? The answer is <b>metadata</b>
295 - data about data. In this case, we need a <b>description</b> of the service
296 that tells us what to expect as the return type. Here's how to do it on
297 the client side in Axis:</p>
298 <pre class="example"> call.setReturnType( org.apache.axis.Constants.XSD_STRING );</pre>
299 <p>This method will tell the Axis client that if the return element is not typed
300 then it should act as if the return value has an xsi:type attribute set to the
301 predefined SOAP String type. (You can see an example of this in action in the
302 interop echo-test client - samples/echo/TestClient.java.) </p>
303 <p>There is also a similar method which allows you to specify the Java class of
304 the expected return type:</p>
305 <pre class="example">call.setReturnClass(String.class);</pre>
306 <p>OK - so now you know the basics of accessing SOAP services as a client.
307 But how do you publish your own services?
308 <h2>
309 <a NAME="PublishingServices"></a>Publishing Web Services with Axis</h2>
310 Let's say we have a simple class like the following:
311 <pre class="example">public class Calculator {
312 public int add(int i1, int i2)
313 {
314 return i1 + i2;
315 }
316
317 public int subtract(int i1, int i2)
318 {
319 return i1 - i2;
320 }
321 }</pre>
322 (You'll find this very class in <a href="../samples/userguide/example2/Calculator.java">samples/userguide/example2/Calculator.java</a>.)
323 <p>How do we go about making this class available via SOAP? There are a
324 couple of answers to that question, but we'll start with the easiest way
325 Axis provides to do this, which takes almost no effort at all!
326 <h3>
327 JWS (Java Web Service) Files - Instant Deployment</h3>
328 OK, here's step 1 : copy the above .java file into your webapp directory,
329 and rename it "Calculator.jws". So you might do something like this:
330 <pre>% copy Calculator.java <i><font color="#0000FF">&lt;your-webapp-root></font></i>/axis/Calculator.jws</pre>
331 Now for step 2... hm, wait a minute. You're done! You should now be able
332 to access the service at the following URL (assuming your Axis web application
333 is on port 8080):
334 <p><a href="http://localhost:8080/axis/Calculator.jws">http://localhost:8080/axis/Calculator.jws</a>
335 <p>Axis automatically locates the file, compiles the class, and converts
336 SOAP calls correctly into Java invocations of your service class. Try it
337 out - there's a calculator client in samples/userguide/example2/CalcClient.java,
338 which you can use like this:
339 <pre class="example">% java samples.userguide.example2.CalcClient -p8080 add 2 5
340 Got result : 7
341 % java samples.userguide.example2.CalcClient -p8080 subtract 10 9
342 Got result : 1
343 %</pre>
344 (Note that you may need to replace the "-p8080" with whatever port your
345 J2EE server is running on)
346 <p>
347 <i><b>Important:</b></i> JWS web services are intended for simple web services.
348 You cannot use packages in the pages, and as the code is compiled at run
349 time you can not find out about errors until after deployment.
350 Production quality web services should use Java classes with custom
351 deployment.
352
353 <h3>
354 Custom Deployment - Introducing WSDD</h3>
355 JWS files are great quick ways to get your classes out there as Web Services,
356 but they're not always the best choice. For one thing, you need the source code
357 - there might be times when you want to expose a pre-existing class on your system
358 without source. Also, the amount of configuration you can do as to how the service
359 gets accessed is pretty limited - you can't specify custom type mappings, or control
360 which Handlers get invoked when people are using your service. <i>(Note for the
361 future : the Axis team, and the Java SOAP community at large, are thinking about
362 ways to be able to embed this sort of metadata into your source files if desired
363 - stay tuned!)</i>
364 <h4>
365 <a NAME="descriptors"></a>Deploying via descriptors</h4>
366 <p>To really use the flexibility available to you in Axis, you should get
367 familiar with the Axis <b>Web Service Deployment Descriptor (WSDD)</b>
368 format. A deployment descriptor contains a bunch of things you want to
369 "deploy" into Axis - i.e. make available to the Axis engine. The most common
370 thing to deploy is a Web Service, so let's start by taking a look at a
371 deployment descriptor for a basic service (this file is <a href="../samples/userguide/example3/deploy.wsdd">samples/userguide/example3/deploy.wsdd</a>):</p>
372 <pre class="example">&lt;deployment xmlns="http://xml.apache.org/axis/wsdd/"
373 xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
374 &lt;service name="MyService" provider="java:RPC">
375 &lt;parameter name="className" value="samples.userguide.example3.MyService"/>
376 &lt;parameter name="allowedMethods" value="*"/>
377 &lt;/service>
378 &lt;/deployment></pre>
379 Pretty simple, really - the outermost element tells the engine that this is a
380 WSDD deployment, and defines the "java" namespace. Then the service element actually
381 defines the service for us. A service is a <b>targeted chain</b> (see the <a href="architecture-guide.html">Architecture
382 Guide</a>), which means it may have any/all of: a request flow, a pivot Handler
383 (which for a service is called a "provider"), and a response flow. In this case,
384 our provider is "java:RPC", which is built into Axis, and indicates a Java RPC
385 service. The actual class which handles this is <b>org.apache.axis.providers.java.RPCProvider</b>.
386 We'll go into more detail later on the different styles of services and their
387 providers.
388 <p>We need to tell the RPCProvider that it should instantiate and call the correct
389 class (e.g. samples.userguide.example3.MyService), and we do so by including
390 &lt;parameter> tags, giving the service one parameter to configure the class
391 name, and another to tell the engine that any public method on that class may
392 be called via SOAP (that's what the "*" means; we could also have restricted
393 the SOAP-accessible methods by using a space or comma separated list of available
394 method names).
395 <h4>Advanced WSDD - specifying more options</h4>
396 <p>WSDD descriptors can also contain other information about services, and also
397 other pieces of Axis called &quot;Handlers&quot; which we'll cover in a later
398 section.
399 <h5>Scoped Services</h5>
400 <p>Axis supports scoping service objects (the actual Java objects which implement
401 your methods) three ways. &quot;Request&quot; scope, the default, will create
402 a new object each time a SOAP request comes in for your service. &quot;Application&quot;
403 scope will create a singleton shared object to service <b>all</b> requests.
404 &quot;Session&quot; scope will create a new object for each session-enabled
405 client who accesses your service. To specify the scope option, you add a &lt;parameter&gt;
406 to your service like this (where &quot;<i><font color="#FF0000">value</font></i>&quot;
407 is request, session, or application):</p>
408 <pre class="xml">&lt;service name=&quot;MyService&quot;...&gt;
409 &lt;parameter name=&quot;scope&quot; value=&quot;<font color="#FF0000"><i>value</i></font>&quot;/&gt;
410 ...
411 &lt;/service&gt;</pre>
412 <h4>Using the AdminClient</h4>
413 Once we have this file, we need to send it to an Axis server in order to actually
414 deploy the described service. We do this with the AdminClient, or the "org.apache.axis.client.AdminClient"
415 class. If you have deployed Axis on a server other than Tomcat, you may need to
416 use the -p <em>&lt;port&gt;</em> argument. The default port is 8080.
417 A typical invocation of the AdminClient looks like this:
418 <pre class="example">% java org.apache.axis.client.AdminClient deploy.wsdd
419 &lt;Admin>Done processing&lt;/Admin></pre>
420 This command has now made our service accessible via SOAP. Check it out
421 by running the Client class - it should look like this:
422 <pre class="example">% java samples.userguide.example3.Client -lhttp://localhost:8080/axis/services/MyService "test me!"
423 You typed : test me!
424 %</pre>
425 If you want to prove to yourself that the deployment really worked, try
426 undeploying the service and calling it again. There's an "undeploy.wsdd"
427 file in the example3/ directory which you can use just as you did the deploy.wsdd
428 file above. Run the AdminClient on that file, then try the service
429 Client again and see what happens.
430 <p>You can also use the AdminClient to get a listing of all the deployed
431 components in the server:
432 <pre class="example">% java org.apache.axis.client.AdminClient list
433 &lt;big XML document returned here></pre>
434 In there you'll see services, handlers, transports, etc. Note that this
435 listing is an exact copy of the server's "server-config.wsdd" file, which
436 we'll talk about in more detail a little later.
437 <h4>
438 More deployment - Handlers and Chains</h4>
439 Now let's start to explore some of the more powerful features of the Axis
440 engine. Let's say you want to track how many times your service has been
441 called. We've included a sample handler in the samples/log directory to
442 do just this. To use a handler class like this, you first need to deploy
443 the Handler itself, and then use the name that you give it in deploying
444 a service. Here's a sample deploy.wsdd file (this is example 4 in samples/userguide):
445 <pre class="example">&lt;deployment xmlns="http://xml.apache.org/axis/wsdd/"
446 xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
447 &lt;!-- define the logging handler configuration -->
448 &lt;handler name="track" type="java:samples.userguide.example4.LogHandler">
449 &lt;parameter name="filename" value="MyService.log"/>
450 &lt;/handler>
451
452 &lt;!-- define the service, using the log handler we just defined -->
453 &lt;service name="LogTestService"<b> </b>provider="java:RPC">
454 &lt;requestFlow>
455 &lt;handler type="track"/>
456 &lt;/requestFlow>
457
458 &lt;parameter name="className" value="samples.userguide.example4.Service"/>
459 &lt;parameter name="allowedMethods" value="*"/>
460 &lt;/service>
461 &lt;/deployment></pre>
462 <p>The first section defines a Handler called "track" that is implemented
463 by the class samples.userguide.example4.LogHandler. We give this Handler
464 an option to let it know which file to write its messages into.
465 <p>Then we define a service, LogTestService, which is an RPC service just
466 like we saw above in our first example. The difference is the &lt;requestFlow>
467 element inside the &lt;service> - this indicates a set of Handlers that
468 should be invoked when the service is invoked, before the provider. By
469 inserting a reference to "track", we ensure that the message will be logged
470 each time this service is invoked.
471 <h4>
472 Remote Administration</h4>
473 Note that by default, the Axis server is configured to only accept administration
474 requests from the machine on which it resides - if you wish to enable remote
475 administration, you must set the "enableRemoteAdmin" property of the AdminService
476 to <b>true</b>. To do this, find the "server-config.wsdd" file in your
477 webapp's WEB-INF directory. In it, you'll see a deployment for the AdminService.
478 Add an option as follows:
479 <pre class="xml">&lt;service name="AdminService" provider="java:MSG">
480 &lt;parameter name="className" value="org.apache.axis.util.Admin"/>
481 &lt;parameter name="allowedMethods" value="*"/>
482 <b>&lt;parameter name="enableRemoteAdmin" value="true"/>
483 </b>&lt;/service></pre>
484 <p><b>WARNING: enabling remote administration may give unauthorized parties
485 access to your machine. If you do this, please make sure to add security
486 to your configuration!</b>
487 <h3>Service Styles - RPC, Document, Wrapped, and Message</h3>
488 <p>There are four &quot;styles&quot; of service in Axis. <b>RPC</b> services
489 use the SOAP RPC conventions, and also the SOAP &quot;section 5&quot; encoding.
490 <b>Document</b> services do not use any encoding (so in particular, you won't
491 see multiref object serialization or SOAP-style arrays on the wire) but DO still
492 do XML&lt;-&gt;Java databinding. <b>Wrapped</b> services are just like document
493 services, except that rather than binding the entire SOAP body into one big
494 structure, they &quot;unwrap&quot; it into individual parameters. <b>Message</b>
495 services receive and return arbitrary XML in the SOAP Envelope without any type
496 mapping / data binding. If you want to work with the raw XML of the incoming
497 and outgoing SOAP Envelopes, write a message service.</p>
498 <h4>RPC services</h4>
499 RPC services are the default in Axis. They are what you get when you deploy services
500 with &lt;service ... provider=&quot;java:RPC&quot;&gt; or &lt;service ... style=&quot;RPC&quot;&gt;.
501 RPC services follow the SOAP RPC and encoding rules, which means that the XML
502 for an RPC service will look like the &quot;echoString&quot; example above - each
503 RPC invocation is modeled as an outer element which matches the operation name,
504 containing inner elements each of which maps to a parameter of the operation.
505 Axis will deserialize XML into Java objects which can be fed to your service,
506 and will serialize the returned Java object(s) from your service back into XML.
507 Since RPC services default to the soap section 5 encoding rules, objects will
508 be encoded via &quot;multi-ref&quot; serialization, which allows object graphs
509 to be encoded. (See the SOAP spec for more on multi-ref serialization.)
510 <h4>Document / Wrapped services </h4>
511 <p>Document services and wrapped services are similar in that neither uses the
512 SOAP encoding for data; it's just plain old XML schema. In both cases, however,
513 Axis still &quot;binds&quot; Java representations to the XML (see the <a href="#DataMapping">databinding</a>
514 section for more), so you end up dealing with Java objects, not directly with
515 XML constructs.</p>
516 <p>A good place to start in describing the difference between document and wrapped
517 services is with a sample SOAP message containing a purchase order:</p>
518 <pre class="xml">&lt;soap:Envelope xmlns="http://xml.apache.org/axis/wsdd/"
519 xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
520 &lt;soap:Body&gt;
521 &lt;myNS:PurchaseOrder xmlns:myNS=&quot;http://commerce.com/PO&quot;&gt;
522 &lt;item&gt;SK001&lt;/item&gt;
523 &lt;quantity&gt;1&lt;/quantity&gt;
524 &lt;description&gt;Sushi Knife&lt;/description&gt;
525 &lt;/myNS:PurchaseOrder&gt;
526 &lt;/soap:Body&gt;
527 &lt;/soap:Envelope&gt;
528 </pre>
529 <p>The relevant schema for the PurchaseOrder looks like this:</p>
530 <pre class="xml">&lt;schema targetNamespace=&quot;http://commerce.com/PO&quot;>
531 &lt;complexType name=&quot;POType&quot;&gt;
532 &lt;sequence&gt;
533 &lt;element name=&quot;item&quot; type=&quot;xsd:string&quot;/&gt;
534 &lt;element name=&quot;quantity&quot; type=&quot;xsd:int&quot;/&gt;
535 &lt;element name=&quot;description&quot; type=&quot;xsd:string&quot;/&gt;
536 &lt;/sequence&gt;
537 &lt;/complexType&gt;
538 &lt;element name=&quot;PurchaseOrder&quot; type=&quot;POType&quot;/&gt;
539 &lt;/deployment></pre>
540 <p>For a <b>document</b> style service, this would map to a method like this:</p>
541 <p class="example">public void method(PurchaseOrder po)</p>
542 <p>In other words, the ENTIRE &lt;PurchaseOrder&gt; element would be handed to
543 your method as a single bean with three fields inside it. On the other hand,
544 for a <b>wrapped</b> style service, it would map to a method like this:</p>
545 <p class="example">public void purchaseOrder(String item, int quantity, String
546 description)</p>
547 <p>Note that in the &quot;wrapped&quot; case, the &lt;PurchaseOrder&gt; element
548 is a &quot;wrapper&quot; (hence the name) which only serves to indicate the
549 correct operation. The arguments to our method are what we find when we &quot;unwrap&quot;
550 the outer element and take each of the inner ones as a parameter.</p>
551 <p>The document or wrapped style is indicated in WSDD as follows:</p>
552 <p><span class="example">&lt;service ... style=&quot;document&quot;&gt;</span>
553 for document style<br>
554 <span class="example">&lt;service ... style=&quot;wrapped&quot;&gt;</span> for
555 wrapped style</p>
556 <p>In most cases you won't need to worry about document or wrapped services if
557 you are starting from a WSDL document (<a href="#WSDL">see below</a>).</p>
558 <h4>Message services</h4>
559 <p>Finally, we arrive at &quot;Message&quot; style services, which should be used
560 when you want Axis to step back and let your code at the actual XML instead
561 of turning it into Java objects. There are four valid signatures for your message-style
562 service methods:</p>
563 <p><code>public Element [] method(Element [] bodies);</code><code><br>
564 public SOAPBodyElement [] method (SOAPBodyElement [] bodies);</code><code><br>
565 public Document method(Document body);<br>
566 public void method(SOAPEnvelope req, SOAPEnvelope resp);</code> </p>
567 <p>The first two will pass your method arrays of either DOM Elements or SOAPBodyElements
568 - the arrays will contain one element for each XML element inside the &lt;soap:body&gt;
569 in the envelope.</p>
570 <p>The third signature will pass you a DOM Document representing the &lt;soap:body&gt;,
571 and expects the same in return.</p>
572 <p>The fourth signature passes you two SOAPEnvelope objects representing the request
573 and response messages. This is the signature to use if you need to look at or
574 modify headers in your service method. Whatever you put into the response envelope
575 will automatically be sent back to the caller when you return. Note that the
576 response envelope may already contain headers which have been inserted by other
577 Handlers.</p>
578 <p><b>Message Example</b></p>
579 <p>A sample message service can be found in <a href="../samples/message/MessageService.java">samples/message/MessageService.java</a>.
580 The service class, <code>MessageService</code>, has one public method, <code>echoElements</code>,
581 which matches the first of the three method signatures above:</p>
582 <pre class="example">public Element[] echoElements(Element [] elems) </pre>
583 <p>The <code>MsgProvider</code> handler calls the method with an array<code></code>
584 of <code>org.w3c.dom.Element</code> objects that correspond to the immediate
585 children of the incoming message's SOAP Body. Often, this array will contain
586 a single Element (perhaps the root element of some XML document conforming to
587 some agreed-upon schema), but the SOAP Body can handle any number of children.
588 The method returns an <code>Element[]</code> array to be returned in the SOAP
589 body of the response message.</p>
590 <p>Message services must be deployed with a WSDD file. Here is the full WSDD for
591 the <code>MessageService</code> class:</p>
592 <pre class="XML">
593 &lt;deployment name=&quot;test&quot; xmlns=&quot;http://xml.apache.org/axis/wsdd/&quot;
594 xmlns:java=&quot;http://xml.apache.org/axis/wsdd/providers/java&quot;
595 xmlns:xsi=&quot;http://www.w3.org/2000/10/XMLSchema-instance&quot;&gt;
596 &lt;service name=&quot;MessageService&quot; <font color="#FF0000">style=&quot;message&quot;</font>&gt;
597 &lt;parameter name=&quot;className&quot; value=&quot;samples.message.MessageService&quot;/&gt;
598 &lt;parameter name=&quot;allowedMethods&quot; value=&quot;echoElements&quot;/&gt;
599 &lt;/service&gt;<br>&lt;/deployment&gt;</pre>
600 <p>Note that the &quot;style&quot; attribute is different from the RPC deployment
601 example. The &quot;message&quot; style tells Axis that this service is to be
602 handled by <code>org.apache.axis.providers.java.MsgProvider</code> rather than
603 <code>org.apache.axis.providers.java.RPCProvider</code>. </p>
604 <p>You can test this service by deploying it, then running samples.message.TestMsg
605 (look at the source to see what the test driver does).</p>
606 <h2><a NAME="DataMapping"></a>XML &lt;-> Java Data Mapping in Axis</h2>
607 <h3>How your Java types map to SOAP/XML types</h3>
608
609 Interoperability, <i>interop</i>, is an ongoing challenge
610 between SOAP implementations. If you want your service to work with other platforms
611 and implementations, you do need to understand the issues. There are some
612 <a href="reading.html#interop">external articles</a> on the subject that act
613 as a good starting place.
614
615 The basic mapping between Java types and WSDL/XSD/SOAP in Axis is determined by
616 the JAX-RPC specification. Read chapters 4 and 5 of the
617 <a href="http://java.sun.com/xml/jaxrpc/">
618 specification</a> to fully understand how things are converted. Here are
619 some of the salient points.
620
621
622 <h4>Standard mappings from WSDL to Java</h4>
623 <table>
624 <tr><td>xsd:base64Binary </td><td><tt>byte[]</tt></td></tr>
625 <tr><td>xsd:boolean </td><td><tt>boolean</tt></td></tr>
626 <tr><td>xsd:byte </td><td><tt>byte</tt></td></tr>
627 <tr><td>xsd:dateTime </td><td><tt>java.util.Calendar</tt></td></tr>
628 <tr><td>xsd:decimal </td><td><tt>java.math.BigDecimal</tt></td></tr>
629 <tr><td>xsd:double </td><td><tt>double</tt></td></tr>
630 <tr><td>xsd:float </td><td><tt>float</tt></td></tr>
631 <tr><td>xsd:hexBinary </td><td><tt>byte[]</tt></td></tr>
632 <tr><td>xsd:int</td><td><tt> int</tt></td></tr>
633 <tr><td>xsd:integer</td><td><tt>java.math.BigInteger</tt></td></tr>
634 <tr><td>xsd:long </td><td><tt>long</tt></td></tr>
635 <tr><td>xsd:QName </td><td><tt>javax.xml.namespace.QName</tt></td></tr>
636 <tr><td>xsd:short </td><td><tt>short</tt></td></tr>
637 <tr><td>xsd:string</td><td><tt>java.lang.String</tt></td></tr>
638 </table>
639 <p> If the WSDL says that an object can be <tt>nillable</tt>, that is the caller
640 may choose to return a value of <tt>nil</tt>, then the primitive data types
641 are replaced by their wrapper classes, such as Byte, Double, Boolean, etc.
642 <h4>SOAP Encoding Datatypes</h4>
643 <p> Alongside the XSD datatypes are the SOAP 'Section 5' datatypes that are all
644 nillable, and so only ever map to the wrapper classes. These types exist because
645 they all support the &quot;ID&quot; and &quot;HREF&quot; attributes, and so
646 will be used when in an RPC-encoded context to support multi-ref serialization.
647
648
649 <h3>Exceptions</h3>
650
651 This is an area which causes plenty of confusion, and indeed, the author
652 of this section is not entirely sure how everything works, especially
653 from an interop perspective. This means treat this section as
654 incomplete and potentially inaccurate. See also section 5.5.5 and
655 chapter 14 in the JAX-RPC specification
656
657 <h4>RemoteExceptions map to SOAP Faults</h4>
658
659 If the server method throws a <tt>java.rmi.RemoteException</tt> then
660 this will be mapped into a SOAP Fault. The <tt>faultcode</tt> of this will contain
661 the classname of the fault. The recipient is expected to deserialize the
662 body of the fault against the classname.
663
664 <p>
665
666 Obviously, if the recipient does not know how to create an instance of
667 the received fault, this mechanism does not work. Unless you include
668 information about the exception class in the WSDL description of the
669 service, or sender and receiver share the implementation,
670 you can only reliably throw <tt>java.rmi.RemoteException</tt>
671 instances, rather than subclasses.
672
673 <p>
674
675 When an implementation in another language receives such an exception,
676 it should see the name of the class as the faultCode, but still be left
677 to parse the body of the exception. You need to experiment to find out
678 what happens there.
679
680 <h4>Exceptions are represented as <tt>wsdl:fault</tt> elements</h4>
681
682 If a method is marked as throwing an <tt>Exception</tt> that is not
683 an instance or a subclass of <tt>java.rmi.RemoteException</tt>, then
684 things are subtly different. The exception is no longer a SOAP Fault, but
685 described as a <tt>wsdl:fault</tt> in the WSDL of the method.
686
687 According to the JAX-RPC specification, your subclass of Exception
688 must have accessor methods to access all the fields in the object to be
689 marshalled <i>and</i> a constructor that takes as parameters all the
690 same fields (i.e, arguments of the same name and type). This is a kind of
691 immutable variant of a normal <a href="http://java.sun.com/products/javabeans">JavaBean</a>. The fields in the object must be
692 of the datatypes that can be reliably mapped into WSDL.
693
694 <p>
695
696 If your exception meets this specification, then the WSDL describing the
697 method will describe the exception too, enabling callers to create stub
698 implementations of the exception, regardless of platform.
699
700 <p>
701
702 Again, to be sure of interoperability, you need to be experiment a bit.
703 Remember, the calling language may not have the notion of Exceptions, or
704 at least not be as rigorous as Java in the rules as to how exceptions
705 must be handled.
706
707 <h3>What Axis can send via SOAP with restricted Interoperability</h3>
708
709
710 <h5>Java Collections</h5>
711
712 Some of the Collection classes, such as <tt>Hashtable</tt>, do have
713 serializers, but there is no formal interoperability with other SOAP
714 implementations, and nothing in the SOAP specifications which covers
715 complex objects. The most reliable way to send aggregate objects is to
716 use arrays. In particular, .NET cannot handle them, though many Java SOAP
717 implementations can marshall and unmarshall hash tables.
718
719
720 <h3>What Axis can not send via SOAP</h3>
721
722
723 <h5>Arbitrary Objects without Pre-Registration</h5>
724
725 You cannot send arbitrary Java objects over the wire and expect them to
726 be understood at the far end. With RMI you can send and receive
727 <tt>Serializable</tt> Java objects, but that is because you are running
728 Java at both ends. <b>Axis will only send objects for which there is a
729 registered Axis serializer.</b> This document shows below how to use
730 the BeanSerializer to serialize any class that follows the JavaBean
731 pattern of accessor and mutator. To serve up objects you must either
732 register your classes with this BeanSerializer, or there must be
733 serialization support built in to Axis.
734
735
736 <h5>Remote References</h5>
737
738 Remote references are neither part of the SOAP specification, nor the JAX-RPC
739 specification. You cannot return some object reference and expect the
740 caller to be able to use it as an endpoint for SOAP calls or as a
741 parameter in other calls. Instead you must use some other reference
742 mechanism, such as storing them in a <tt>HashMap</tt> with numeric or
743 string keys that can be passed over the wire.
744
745
746 <h3>Encoding Your Beans - the BeanSerializer</h3>
747 Axis includes the ability to serialize/deserialize, without writing any
748 code, arbitrary Java classes which follow the standard <a href="http://java.sun.com/products/javabeans">JavaBean</a> pattern
749 of get/set accessors. All you need to do is tell Axis which Java classes
750 map to which XML Schema types. Configuring a bean mapping looks like this:
751 <pre class="xml">&lt;beanMapping qname="ns:local" xmlns:ns="someNamespace"
752 languageSpecificType="java:my.java.thingy"/></pre>
753 The &lt;beanMapping> tag maps a Java class (presumably a bean) to an XML
754 QName. You'll note that it has two important attributes, <b>qname</b> and
755 <b>languageSpecificType</b>.
756 So in this case, we'd be mapping the "my.java.thingy" class to the XML
757 QName [someNamespace]:[local].
758 <p>Let's take a look at how this works in practice. Go look at <a href="../samples/userguide/example5/BeanService.java">samples/userguide/example5/BeanService.java</a>. The key
759 thing to notice is that the argument to the service method is an Order
760 object. Since Order is not a basic type which Axis understands by default,
761 trying to run this service without a type mapping will result in a fault.
762 (If you want to try this for yourself, you can use the bad-deploy.wsdd
763 file in the example5 directory.) But if we put a beanMapping into our deployment,
764 all will be well. Here's how to run this example (from the example5 directory):
765 <pre class="example">% java org.apache.axis.client.AdminClient -llocal:///AdminService deploy.wsdd
766 &lt;Admin>Done processing&lt;/Admin>
767
768 % java samples.userguide.example5.Client -llocal://
769 Hi, Glen Daniels!
770
771 You seem to have ordered the following:
772
773 1 of item : mp3jukebox
774 4 of item : 1600mahBattery
775
776 If this had been a real order processing system, we'd probably have charged you about now.
777 %
778
779 </pre>
780
781 <h3>
782 When Beans Are Not Enough - Custom Serialization</h3>
783 Just as JWS deployment is sometimes not flexible enough to meet all needs,
784 the default bean serialization model isn't robust enough to handle every
785 case either. At times there will be non-bean Java classes (especially in
786 the case of pre-existing assets) which you need to map to/from XML, and
787 there also may be some custom XML schema types which you want to map into
788 Java in particular ways. Axis gives you the ability to write custom serializers/deserializers,
789 and some tools to help make your life easier when you do so.
790 <p><i><font color="#FF0000">TBD - this section will be expanded in a future
791 version! For now look at the DataSer/DataDeser
792 classes (in samples/encoding).
793 Also look at the BeanSerializer, BeanDeserializer, ArraySerializer, ArrayDeserializer and other classes in the org.apache.axis.encoding.ser package.
794 </font></i>
795 <h4>
796 Deploying custom mappings - the &lt;typeMapping> tag</h4>
797 Now that you've built your serializers and deserializers, you need to tell
798 Axis which types they should be used for. You do this with a typeMapping
799 tag in WSDD, which looks like this:
800 <pre class="xml">&lt;typeMapping qname="ns:local" xmlns:ns="someNamespace"
801 languageSpecificType="java:my.java.thingy"
802 serializer="my.java.Serializer"
803 deserializer="my.java.DeserializerFactory"
804 encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></pre>
805 <p>This looks a lot like the &lt;beanMapping> tag we saw earlier, but there
806 are three extra attributes. One, <b>serializer</b>, is the Java class name
807 of the Serializer <i>factory</i> which gets the serializer to
808 be used to marshal an object of the specified Java class
809 (i.e., my.java.thingy) into XML. Another, <b>deserializer</b>, is
810 the class name of a Deserializer <i>factory</i> that gets the deserializer
811 to be used to unmarshall XML into the correct Java class. The final attribute,
812 the <b>encodingStyle</b>, which is SOAP encoding.
813 <p>(The &lt;beanMapping> tag is really just shorthand for a &lt;typeMapping> tag
814 with <tt>serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"</tt>,
815 <tt>deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"</tt>,
816 and <tt>encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"</tt>, but clearly it
817 can save a lot of typing!)
818 <h4>Deploying array mappings - the &lt;arrayMapping> tag</h4>
819 Another variation around typeMapping is arrayMapping. The arrayMapping tag is useful
820 for advanced users wanting to exatly control how their arrays are serialized throught
821 the wire.
822 <pre class="xml">&lt;arrayMapping qname="ns:ArrayOfthingy" xmlns:ns="someNamespaceURI"
823 languageSpecificType="java:my.java.array.thingy[]"
824 innerType="ns2:thingy" xmlns:ns2="anotherNamespaceURI"
825 encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></pre>
826 No need here to specify a serializer/deserializer couple, the arrayMapping tag
827 is only about arrays (no List, ...). The added attribute (<i>innerType</i>) is used
828 to tell Axis what precisely is the item type of the Array.
829 <h2>
830 <a NAME="WSDL"></a>Using WSDL with Axis</h2>
831 The <a href="http://www.w3.org/TR/wsdl">Web Service Description Language</a>
832 is a specification authored by IBM and Microsoft, and supported by many
833 other organizations. WSDL serves to describe Web Services in a structured
834 way. A WSDL description of a service tells us, in a machine-understandable
835 way, the interface to the service, the data types it uses, and where the
836 service is located. Please see the spec (follow the link in the first sentence)
837 for details about WSDL's format and options.
838 <p>Axis supports WSDL in three ways:
839 <ol>
840 <li>
841 When you deploy a service in Axis, users may then access your service's
842 URL with a standard web browser and by appending "?WSDL" to the end of
843 the URL, they will obtain an automatically-generated WSDL document which
844 describes your service.</li>
845
846 <li>
847 We provide a "WSDL2Java" tool which will build Java proxies and skeletons
848 for services with WSDL descriptions.</li>
849
850 <li>
851 We provide a "Java2WSDL" tool which will build WSDL from Java classes.</li>
852 </ol>
853
854 <h3>
855 <a NAME="WSDL: Obtaining WSDL for deployed services"></a>?WSDL: Obtaining
856 WSDL for deployed services</h3>
857 When you make a service available using Axis, there is typically a unique
858 URL associated with that service. For JWS files, that URL is simply the
859 path to the JWS file itself. For non-JWS services, this is usually the
860 URL "http://&lt;host>/axis/services/&lt;service-name>".
861 <p>If you access the service URL in a browser, you'll see a message indicating
862 that the endpoint is an Axis service, and that you should usually access
863 it using SOAP. However, if you tack on "?wsdl" to the end of the URL, Axis
864 will automatically generate a service description for the deployed service,
865 and return it as XML in your browser (try it!). The resulting description
866 may be saved or used as input to proxy-generation, described next. You
867 can give the WSDL-generation URL to your online partners, and they'll be
868 able to use it to access your service with toolkits like .NET, SOAP::Lite,
869 or any other software which supports using WSDL.
870 <p>You can also generate WSDL files from existing Java classes (see <a href="#Java2WSDL: Building WSDL from Java">Java2WSDL:
871 Building WSDL from Java</a> ).
872 <br>
873 <h3><a NAME="WSDL2Java: Building stubs, skeletons, and data"></a>WSDL2Java:
874 Building stubs, skeletons, and data types from WSDL</h3>
875
876 <h4>Client-side bindings</h4>
877 <p>You'll find the Axis WSDL-to-Java tool in "org.apache.axis.wsdl.WSDL2Java".
878 The basic invocation form looks like this:</p>
879 <pre class="example">
880 % java org.apache.axis.wsdl.WSDL2Java (WSDL-file-URL)
881 </pre>
882
883 <p>This will generate only those bindings necessary for the client.
884 Axis follows the JAX-RPC specification when generating Java client bindings
885 from WSDL. For this discussion, assume we executed the following:</p>
886 <pre class="example">
887 % cd samples/addr
888 % java org.apache.axis.wsdl.WSDL2Java AddressBook.wsdl
889 </pre>
890 <p>The generated files will reside in the directory "AddressFetcher2".
891 They are put here because that is the target namespace from the WSDL and namespaces map to Java packages.
892 Namespaces will be discussed in detail later.</p>
893 <table BORDER COLS=2 WIDTH="100%" >
894 <tr>
895 <td><b>WSDL clause</b></td>
896
897 <td><b>Java class(es) generated</b></td>
898 </tr>
899
900 <tr>
901 <td>For each entry in the type section</td>
902
903 <td>A java class</td>
904 </tr>
905
906 <tr>
907 <td></td>
908
909 <td>A holder if this type is used as an inout/out parameter</td>
910 </tr>
911
912 <tr>
913 <td>For each portType</td>
914
915 <td>A java interface</td>
916 </tr>
917
918 <tr>
919 <td>For each binding</td>
920
921 <td>A stub class</td>
922 </tr>
923
924 <tr>
925 <td>For each service</td>
926
927 <td>A service interface</td>
928 </tr>
929
930 <tr>
931 <td></td>
932
933 <td>A service implementation (the locator)</td>
934 </tr>
935 </table>
936
937 There is an <a href="ant/axis-wsdl2java.html">Ant Task</a> to integrate this
938 action with an Ant based build process.
939
940 <h4>Types</h4>
941 <p>The Java class generated from a WSDL type will be named from the WSDL type.
942 This class will typically, though not always, be a bean. For example,
943 given the WSDL (the WSDL used throughout the WSDL2Java discussion is from
944 the <a href="../samples/addr/AddressBook.wsdl">Address Book sample</a>):</p>
945 <pre class="example">
946 &lt;xsd:complexType name="phone">
947 &lt;xsd:all>
948 &lt;xsd:element name="areaCode" type="xsd:int"/>
949 &lt;xsd:element name="exchange" type="xsd:string"/>
950 &lt;xsd:element name="number" type="xsd:string"/>
951 &lt;/xsd:all>
952 &lt;/xsd:complexType>
953 </pre>
954 <p>WSDL2Java will generate:
955 <pre class="example">
956 public class Phone implements java.io.Serializable {
957 public Phone() {...}
958 public int getAreaCode() {...}
959 public void setAreaCode(int areaCode) {...}
960 public java.lang.String getExchange() {...}
961 public void setExchange(java.lang.String exchange) {...}
962 public java.lang.String getNumber() {...}
963 public void setNumber(java.lang.String number) {...}
964 public boolean equals(Object obj) {...}
965 public int hashCode() {...}
966 }
967 </pre>
968 <h4>Mapping XML to Java types : Metadata</h4>
969 <p>Notice in the mapping above, the XML type name is &quot;phone&quot; and the
970 generated Java class is &quot;Phone&quot; - the capitalization of the first
971 letter has changed to match the Java coding convention that classes begin with
972 an uppercase letter. This sort of thing happens a lot, because the rules for
973 expressing XML names/identifiers are much less restrictive than those for Java.
974 For example, if one of the sub-elements in the &quot;phone&quot; type above
975 was named &quot;new&quot;, we couldn't just generate a Java field called &quot;new&quot;,
976 since that is a reserved word and the resultant source code would fail to compile.</p>
977 <p>To support this kind of mapping, and also to enable the serialization/deserialization
978 of XML attributes, we have a <b>type metadata</b> system which allows us to
979 associate Java data classes with descriptors which control these things.</p>
980 <p>When the WSDL2Java tool creates a data bean like the Phone class above, it
981 notices if the schema contains any attributes, or any names which do not map
982 directly to Java field/property names. If it finds any of these things, it will
983 generate a static piece of code to supply a <b>type descriptor</b> for the class.
984 The type descriptor is essentially a collection of <b>field descriptors</b>,
985 each of which maps a Java field/property to an XML element or attribute.</p>
986 <p>To see an example of this kind of metadata, look at the &quot;test.encoding.AttributeBean&quot;
987 class in the Axis source, or generate your own bean from XML which uses attributes
988 or names which would be illegal in Java.</p>
989 <h4>Holders</h4>
990 <p>This type may be used as an inout or out parameter. Java does not
991 have the concept of inout/out parameters. In order to achieve this
992 behavior, JAX-RPC specifies the use of holder classes. A holder class
993 is simply a class that contains an instance of its type. For example,
994 the holder for the Phone class would be:</p>
995 <pre class="example">
996 package samples.addr.holders;
997 public final class PhoneHolder implements javax.xml.rpc.holders.Holder {
998 public samples.addr.Phone value;
999
1000 public PhoneHolder()
1001 {
1002 }
1003
1004 public PhoneHolder(samples.addr.Phone value) {
1005 this.value = value;
1006 }
1007 }
1008 </pre>
1009 <p>A holder class is <b>only</b> generated for a type if that type is used as
1010 an inout or out parameter. Note that the holder class has the suffix "Holder"
1011 appended to the class name, and it is generated in a sub-package with the "holders". </p>
1012 <p>The holder classes for the primitive types can be found in javax.xml.rpc.holders.</p>
1013 <h4>PortTypes</h4>
1014 <p>The Service Definition Interface (SDI) is the interface that's derived
1015 from a WSDL's portType. This is the interface you use to access the
1016 operations on the service. For example, given the WSDL:</p>
1017 <pre class="example">
1018 &lt;message name="empty">
1019 &lt;message name="AddEntryRequest">
1020 &lt;part name="name" type="xsd:string"/>
1021 &lt;part name="address" type="typens:address"/>
1022 &lt;/message>
1023 &lt;portType name="AddressBook">
1024 &lt;operation name="addEntry">
1025 &lt;input message="tns:AddEntryRequest"/>
1026 &lt;output message="tns:empty"/>
1027 &lt;/operation>
1028 &lt;/portType>
1029 </pre>
1030 <p>WSDL2Java will generate:
1031 <pre class="example">
1032 public interface AddressBook extends java.rmi.Remote {
1033 public void addEntry(String name, Address address) throws java.rmi.RemoteException;
1034 }
1035 </pre>
1036
1037 <p>A note about the name of the SDI. The name of the SDI is typically the
1038 name of the portType. However, to construct the SDI, WSDL2Java needs
1039 information from both the portType <b>and</b> the binding.
1040 (This is unfortunate and is a topic of discussion for WSDL version 2.)
1041
1042
1043 <p>JAX-RPC says (section 4.3.3): "The name of the Java interface is mapped
1044 from the name attribute of the wsdl:portType element. ... If the mapping to
1045 a service definition interface uses elements of the wsdl:binding ..., then
1046 the name of the service definition interface is mapped from the name of the
1047 wsdl:binding element."
1048 <p>Note the name of the spec. It contains the string "RPC". So this spec,
1049 and WSDL2Java, assumes that the interface generated from the portType is an
1050 RPC interface. If information from the binding tells us otherwise (in
1051 other words, we use elements of the wsdl:binding), then the name of the
1052 interface is derived instead from the binding.
1053 <p>Why? We could have one portType - pt - and two bindings - bRPC and
1054 bDoc. Since document/literal changes what the interface looks like, we
1055 cannot use a single interface for both of these bindings, so we end up with
1056 two interfaces - one named pt and another named bDoc - and two stubs -
1057 bRPCStub (which implements pt) and bDocStub (which implements bDoc).
1058 <p>Ugly, isn't it? But you can see why it's necessary. Since
1059 document/literal changes what the interface looks like, and we could
1060 have more than one binding referring to a single portType, we have to
1061 create more than one interface, and each interface must have a unique name.
1062
1063 <h4>
1064 Bindings</h4>
1065
1066 A Stub class implements the SDI. Its name is the binding name with
1067 the suffix "Stub". It contains the code which turns the method invocations
1068 into SOAP calls using the Axis Service and Call objects. It stands
1069 in as a <b>proxy</b> (another term for the same idea) for the remote service,
1070 letting you call it exactly as if it were a local object. In other words,
1071 you don't need to deal with the endpoint URL, namespace, or parameter arrays
1072 which are involved in dynamic invocation via the Service and Call objects.
1073 The stub hides all that work for you.
1074 <p>Given the following WSDL snippet:
1075 <pre class="example">&lt;binding name="AddressBookSOAPBinding" type="tns:AddressBook">
1076 ...
1077 &lt;/binding></pre>
1078 <p>WSDL2Java will generate:
1079 <pre class="example">public class AddressBookSOAPBindingStub extends org.apache.axis.client.Stub
1080 implements AddressBook {
1081 public AddressBookSOAPBindingStub() throws org.apache.axis.AxisFault
1082 {...}
1083
1084 public AddressBookSOAPBindingStub(URL endpointURL,
1085 javax.xml.rpc.Service service)
1086 throws org.apache.axis.AxisFault
1087 {...}
1088 <br> public AddressBookSOAPBindingStub(javax.xml.rpc.Service service)
1089 throws org.apache.axis.AxisFault
1090 {...}
1091 <br> public void addEntry(String name, Address address) throws RemoteException
1092 {...}<br>}</pre>
1093 <h4>
1094 Services</h4>
1095 Normally, a client program would not instantiate a stub directly.
1096 It would instead instantiate a service locator and call a get method which
1097 returns a stub. This locator is derived from the service clause in
1098 the WSDL. WSDL2Java generates two objects from a service clause.
1099 For example, given the WSDL:
1100 <pre class="example">&lt;service name="AddressBookService">
1101 &lt;port name="AddressBook" binding="tns:AddressBookSOAPBinding">
1102 &lt;soap:address location="http://localhost:8080/axis/services/AddressBook"/>
1103 &lt;/port>
1104 &lt;/service></pre>
1105 <p>WSDL2Java will generate the service interface:
1106 <pre class="example">public interface AddressBookService extends javax.xml.rpc.Service {
1107 public String getAddressBookAddress();
1108 <br> public AddressBook getAddressBook() throws javax.xml.rpc.ServiceException;
1109 <br> public AddressBook getAddressBook(URL portAddress) throws javax.xml.rpc.ServiceException;
1110 }</pre>
1111 <p>WSDL2Java will also generate the locator which implements this interface:
1112 <pre class="example">public class AddressBookServiceLocator extends org.apache.axis.client.Service
1113 implements AddressBookService {
1114 ...
1115 }</pre>
1116 <p>The service interface defines a get method for each port listed in the
1117 service element of the WSDL. The locator is the implementation of this
1118 service interface. It implements these get methods. It serves as
1119 a locator for obtaining Stub instances. The Service class will by default
1120 make a Stub which points to the endpoint URL described in the WSDL file,
1121 but you may also specify a different URL when you ask for the PortType.
1122 <p>A typical usage of the stub classes would be as follows:
1123
1124 <pre class="example">public class Tester
1125 {
1126 public static void main(String [] args) throws Exception {
1127 // Make a service
1128 AddressBookService service = new AddressBookServiceLocator();
1129
1130 // Now use the service to get a stub which implements the SDI.
1131 AddressBook port = service.getAddressBook();
1132
1133 // Make the actual call
1134 Address address = new Address(...);
1135 port.addEntry("Russell Butek", address);
1136 }<br>}</pre>
1137
1138 <h4>
1139 Server-side bindings</h4>
1140 Just as a stub is the client side of a Web Service represented in Java,
1141 a <b>skeleton</b> is a Java framework for the server side. To make
1142 skeleton classes, you just specify the "--server-side --skeletonDeploy true" options
1143 to WSDL2Java.
1144 For instance, using the AddressBook.wsdl as we had above:
1145 <pre class="example">% java org.apache.axis.wsdl.WSDL2Java --server-side --skeletonDeploy true AddressBook.wsdl</pre>
1146 <p>You will see that WSDL2Java generates all the classes that were generated
1147 before for the client, but it generates a few new files:
1148 <br>
1149 <br>
1150 <table BORDER COLS=2 WIDTH="100%" >
1151 <tr>
1152 <td><b>WSDL clause</b></td>
1153
1154 <td><b>Java class(es) generated</b></td>
1155 </tr>
1156
1157 <tr>
1158 <td>For each binding</td>
1159
1160 <td>A skeleton class</td>
1161 </tr>
1162
1163 <tr>
1164 <td></td>
1165
1166 <td>An implementation template class</td>
1167 </tr>
1168
1169 <tr>
1170 <td>For all services</td>
1171
1172 <td>One deploy.wsdd file</td>
1173 </tr>
1174
1175 <tr>
1176 <td></td>
1177
1178 <td>One undeploy.wsdd file</td>
1179 </tr>
1180 </table>
1181
1182 <p>If you don't specify the "--skeletonDeploy true" option, a skeleton will not be
1183 generated. Instead, the generated deploy.wsdd will indicate that the implementation
1184 class is deployed directly. In such cases, the deploy.wsdd contains extra meta
1185 data describing the operations and parameters of the implementation class.
1186
1187 Here is how you run WSDL2Java to deploy directly to the implementation:
1188 <pre class="example">% java org.apache.axis.wsdl.WSDL2Java --server-side AddressBook.wsdl</pre>
1189 <p>And here are the server side files that are generated:
1190 <br>
1191 <br>
1192 <table BORDER COLS=2 WIDTH="100%" >
1193 <tr>
1194 <td><b>WSDL clause</b></td>
1195
1196 <td><b>Java class(es) generated</b></td>
1197 </tr>
1198
1199 <tr>
1200 <td>For each binding</td>
1201 <td>An implementation template class</td>
1202
1203 </tr>
1204
1205 <tr>
1206 <td>For all services</td>
1207
1208 <td>One deploy.wsdd file with operation meta data</td>
1209 </tr>
1210
1211 <tr>
1212 <td></td>
1213
1214 <td>One undeploy.wsdd file</td>
1215 </tr>
1216 </table>
1217
1218 <h4>
1219 Bindings</h4>
1220 <h5>
1221 Skeleton Description (for Skeleton Deployment) </h5>
1222 The skeleton class is the class that sits between the Axis engine and the
1223 actual service implementation. Its name is the binding name with
1224 suffix "Skeleton". For example, for the AddressBook binding, WSDL2Java
1225 will generate:
1226 <pre class="example">public class AddressBookSOAPBindingSkeleton implements AddressBook,
1227 org.apache.axis.wsdl.Skeleton {
1228 private AddressBook impl;
1229
1230 public AddressBookSOAPBindingSkeleton() {
1231 this.impl = new AddressBookSOAPBindingImpl();
1232 }
1233
1234 public AddressBookSOAPBindingSkeleton(AddressBook impl) {
1235 this.impl = impl;
1236 }
1237
1238 public void addEntry(java.lang.String name, Address address)
1239 throws java.rmi.RemoteException
1240 {
1241 impl.addEntry(name, address);
1242 }
1243 }</pre>
1244 <p>(The real skeleton is actually much richer. For brevity we just show
1245 you the basic skeleton.)
1246 <p>The skeleton contains an implementation of the AddressBook service.
1247 This implementation is either passed into the skeleton on construction,
1248 or an instance of the generated implementation is created. When the
1249 Axis engine calls the skeleton's addEntry method, it simply delegates the
1250 invocation to the real implementation's addEntry method.
1251 <h5>
1252 Implementation Template Description </h5>
1253 <p>WSDL2Java also generates an implementation template
1254 from the binding:
1255 <pre class="example">public class AddressBookSOAPBindingImpl implements AddressBook {
1256 <br> public void addEntry(String name, Address address)
1257 throws java.rmi.RemoteException {
1258 }
1259 }</pre>
1260 <p>This template could actually be used as a test implementation but, as
1261 you can see, it doesn't do anything. It is intended that the service
1262 writer fill out the implementation from this template.</p>
1263 <p>When WSDL2Java is asked to generate the implementation template (via the --server-side
1264 flag), it will ONLY generate it if it does not already exist. If this
1265 implementation already exists, it will not be overwritten.</p>
1266 <h4>Services</h4>
1267 <p>The tool also builds you a "deploy.wsdd" and an "undeploy.wsdd" for each
1268 service for use with the AdminClient. These files may be used to deploy
1269 the service once you've filled in the methods of the Implementation class,
1270 compiled the code, and made the classes available to your Axis engine.</p>
1271 <h3><a NAME="Java2WSDL: Building WSDL from Java"></a>Java2WSDL: Building WSDL
1272 from Java</h3>
1273 The Java2WSDL and WSDL2Java emitters make it easy to develop a new web service.
1274 The following sections describe the steps in building a web service from a Java interface.
1275 <br>
1276 <h4>
1277 Step 1: Provide a Java interface or class</h4>
1278 Write and compile a Java interface (or class) that describes the web service
1279 interface. Here is an example interface that describes a web services
1280 that can be used to set/query the price of widgets
1281 (<a href="../samples/userguide/example6/WidgetPrice.java">samples/userguide/example6/WidgetPrice.java</a>):
1282 <pre class="example">package samples.userguide.example6;
1283
1284 /**
1285 * Interface describing a web service to set and get Widget prices.
1286 **/
1287 public interface WidgetPrice {
1288 public void setWidgetPrice(String widgetName, String price);
1289 public String getWidgetPrice(String widgetName);
1290 }</pre>
1291 <p><b>Note: </b>If you compile your class with debug information, Java2WSDL
1292 will use the debug information to obtain the method parameter names.
1293 <h4>
1294 Step 2: Create WSDL using Java2WSDL</h4>
1295 Use the Java2WSDL tool to create a WSDL file from the interface above.
1296 <p>Here is an example invocation that produces the wsdl file (<tt>wp.wsdl</tt>)
1297 from the interface described in the previous section (entered all on one line):
1298 <pre class="example">% java org.apache.axis.wsdl.Java2WSDL -o wp.wsdl
1299 -l"http://localhost:8080/axis/services/WidgetPrice" -n "urn:Example6"
1300 -p"samples.userguide.example6" "urn:Example6" samples.userguide.example6.WidgetPrice</pre>
1301 <p>Where:
1302 <ul>
1303 <li>
1304 -o indicates the name of the <b><i>output WSDL</i></b> file</li>
1305
1306 <li>
1307 -l indicates the<b><i> location of the service</i></b></li>
1308
1309 <li>
1310 -n is the target <b><i>namespace</i></b> of the WSDL file</li>
1311
1312 <li>
1313 -p indicates a mapping from the <b><i>package to a namespace</i></b>.
1314 There may be multiple mappings.</li>
1315
1316 <li>
1317 the class specified contains the interface of the webservice.</li>
1318 </ul>
1319 The output WSDL document will contain the appropriate WSDL types, messages,
1320 portType, bindings and service descriptions to support a SOAP rpc, encoding
1321 web service. If your specified interface methods reference other
1322 classes, the Java2WSDL tool will generate the appropriate xml types to
1323 represent the classes and any nested/inherited types. The tool supports
1324 JAX-RPC complex types (bean classes), extension classes, enumeration classes,
1325 arrays and Holder classes.
1326 <p>The Java2WSDL tool has many additional options which are detailed in the <a href="reference.html#Java2WSDL">reference
1327 guide</a>.
1328
1329 There is an <a href="ant/axis-java2wsdl.html">Ant Task</a> to integrate this
1330 action with an Ant based build process.
1331
1332 <h4>
1333 Step 3: Create Bindings using WSDL2Java</h4>
1334
1335 Use the generated WSDL file to build the appropriate client/server bindings
1336 for the web service (see <a href="#WSDL2Java: Building stubs, skeletons, and data">WSDL2Java</a>):
1337 <pre class="example">% java org.apache.axis.wsdl.WSDL2Java -o . -d Session -s -S true -Nurn:Example6 samples.userguide.example6 wp.wsdl</pre>
1338 <p>This will generate the following files:
1339 <ul>
1340 <li> <b><tt>WidgetPriceSoapBindingImpl.java</tt></b> : Java file containing
1341 the default server implementation of the WidgetPrice web service.</li>
1342 <br>
1343 You will need to modify the *SoapBindingImpl file to add your implementation
1344 (see <a href="../samples/userguide/example6/WidgetPriceSoapBindingImpl.java">../samples/userguide/example6/WidgetPriceSoapBindingImpl.java</a>
1345 ).
1346 <li> <b><tt>WidgetPrice.java</tt></b>: New interface file that contains
1347 the appropriate <b><tt>java.rmi.Remote</tt></b> usages.</li>
1348 <li> <b><tt>WidgetPriceService.java</tt></b>: Java file containing the client
1349 side service interface.</li>
1350 <li> <b><tt>WidgetPriceServiceLocator.java</tt></b>: Java file containing the
1351 client side service implementation class.</li>
1352 <li> <b><tt>WidgetPriceSoapBindingSkeleton.java</tt></b>: Server side skeleton.</li>
1353 <li> <b><tt>WidgetPriceSoapBindingStub.java</tt></b>: Client side stub.</li>
1354 <li> <b><tt>deploy.wsdd</tt></b>: Deployment descriptor</li>
1355 <li> <b><tt>undeploy.wsdd</tt></b>: Undeployment descriptor</li>
1356 <li> (data types): Java files will be produced for all of the other types
1357 and holders necessary for the web service. There are no additional files
1358 for the WidgetPrice web service.</li>
1359 </ul>
1360 <p>Now you have all of the necessary files to build your client/server side code
1361 and deploy the web service!</p>
1362 <h2>
1363 <a NAME="published interfaces"></a>Published Axis Interfaces</h2>
1364
1365 Although you may use any of the interfaces and classes present in Axis, you need to
1366 be aware that some are more stable than others since there is a continuing
1367 need to refactor Axis to maintain and improve its modularity.
1368 <p>Hence certain interfaces are designated as <i>published</i>, which means
1369 that they are relatively stable. As Axis is refactored, the Axis developers
1370 will try to avoid changing published interfaces unnecessarily and will
1371 certainly consider the impact on users of any modifications.
1372 <p>So if you stick to using only published interfaces, you'll minimise
1373 the pain of migrating between releases of Axis. On the other hand, if you
1374 decide to use unpublished interfaces, migrating between releases could
1375 be an interesting exercise! If you would like an interface to be published,
1376 you should make the case for this on the
1377 <a href="mailto:[email protected]">axis-user</a>
1378 mailing list.
1379 <p>The current list of published interfaces is as follows:
1380 <ul>
1381 <li>
1382 JAX-RPC interfaces.
1383 These interfaces are from JAX-RPC 1.0 specification, and will change only when
1384 new versions of the specification are released.
1385 <ul>
1386 <li>javax.xml.messaging.Endpoint</li>
1387 <li>javax.xml.messaging.URLEndpoint</li>
1388 <li>javax.xml.rpc.Call</li>
1389 <li>javax.xml.rpc.FaultException</li>
1390 <li>javax.xml.rpc.JAXRPCException</li>
1391 <li>javax.xml.rpc.ParameterMode</li>
1392 <li>javax.xml.rpc.Service</li>
1393 <li>javax.xml.rpc.ServiceException</li>
1394 <li>javax.xml.rpc.ServiceFactory</li>
1395 <li>javax.xml.rpc.Stub</li>
1396 <li>javax.xml.rpc.encoding.DeserializationContext</li>
1397 <li>javax.xml.rpc.encoding.Deserializer</li>
1398 <li>javax.xml.rpc.encoding.DeserializerFactory</li>
1399 <li>javax.xml.rpc.encoding.SerializationContext</li>
1400 <li>javax.xml.rpc.encoding.Serializer</li>
1401 <li>javax.xml.rpc.encoding.SerializerFactory</li>
1402 <li>javax.xml.rpc.encoding.TypeMapping</li>
1403 <li>javax.xml.rpc.encoding.TypeMappingRegistry</li>
1404 <li>javax.xml.rpc.handler.Handler</li>
1405 <li>javax.xml.rpc.handler.HandlerChain</li>
1406 <li>javax.xml.rpc.handler.HandlerInfo</li>
1407 <li>javax.xml.rpc.handler.HandlerRegistry</li>
1408 <li>javax.xml.rpc.handler.MessageContext</li>
1409 <li>javax.xml.rpc.handler.soap.SOAPMessageContext</li>
1410 <li>javax.xml.rpc.holders.BigDecimalHolder</li>
1411 <li>javax.xml.rpc.holders.BigIntegerHolder</li>
1412 <li>javax.xml.rpc.holders.BooleanHolder</li>
1413 <li>javax.xml.rpc.holders.BooleanWrapperHolder</li>
1414 <li>javax.xml.rpc.holders.ByteArrayHolder</li>
1415 <li>javax.xml.rpc.holders.ByteHolder</li>
1416 <li>javax.xml.rpc.holders.ByteWrapperArrayHolder</li>
1417 <li>javax.xml.rpc.holders.ByteWrapperHolder</li>
1418 <li>javax.xml.rpc.holders.CalendarHolder</li>
1419 <li>javax.xml.rpc.holders.DateHolder</li>
1420 <li>javax.xml.rpc.holders.DoubleHolder</li>
1421 <li>javax.xml.rpc.holders.DoubleWrapperHolder</li>
1422 <li>javax.xml.rpc.holders.FloatHolder</li>
1423 <li>javax.xml.rpc.holders.FloatWrapperHolder</li>
1424 <li>javax.xml.rpc.holders.Holder</li>
1425 <li>javax.xml.rpc.holders.IntHolder</li>
1426 <li>javax.xml.rpc.holders.IntegerWrapperHolder</li>
1427 <li>javax.xml.rpc.holders.LongHolder</li>
1428 <li>javax.xml.rpc.holders.LongWrapperHolder</li>
1429 <li>javax.xml.rpc.holders.ObjectHolder</li>
1430 <li>javax.xml.rpc.holders.QNameHolder</li>
1431 <li>javax.xml.rpc.holders.ShortHolder</li>
1432 <li>javax.xml.rpc.holders.ShortWrapperHolder</li>
1433 <li>javax.xml.rpc.holders.StringHolder</li>
1434 <li>javax.xml.rpc.namespace.QName</li>
1435 <li>javax.xml.rpc.server.ServiceLifecycle</li>
1436 <li>javax.xml.rpc.soap.SOAPFault</li>
1437 <li>javax.xml.rpc.soap.SOAPHeaderFault</li>
1438 <li>javax.xml.transform.Source</li>
1439 </ul>
1440 </li>
1441 <li>Axis interfaces. These have less guarantees of stability:
1442 <ul>
1443 <li>org.apache.axis.AxisFault</li>
1444 <li>org.apache.axis.Handler</li>
1445 <li>org.apache.axis.DefaultEngineConfigurationFactory</li>
1446 <li>org.apache.axis.EngineConfiguration</li>
1447 <li>org.apache.axis.EngineConfigurationFactory</li>
1448 <li>org.apache.axis.Message</li>
1449 <li>org.apache.axis.MessageContext</li>
1450 <li>org.apache.axis.SOAPPart</li>
1451 <li>org.apache.axis.client.Call</li>
1452 <li>org.apache.axis.client.Service</li>
1453 <li>org.apache.axis.client.ServiceFactory</li>
1454 <li>org.apache.axis.client.Stub</li>
1455 <li>org.apache.axis.client.Transport</li>
1456 <li>org.apache.axis.description.TypeDesc</li>
1457 <li>org.apache.axis.description.AttributeDesc</li>
1458 <li>org.apache.aixs.description.ElementDesc</li>
1459 <li>org.apache.axis.encoding.DeserializationContext</li>
1460 <li>org.apache.axis.encoding.Deserializer</li>
1461 <li>org.apache.axis.encoding.DeserializerFactory</li>
1462 <li>org.apache.axis.encoding.DeserializerTarget</li>
1463 <li>org.apache.axis.encoding.FieldTarget</li>
1464 <li>org.apache.axis.encoding.MethodTarget</li>
1465 <li>org.apache.axis.encoding.SerializationContext</li>
1466 <li>org.apache.axis.encoding.Serializer</li>
1467 <li>org.apache.axis.encoding.SerializerFactory</li>
1468 <li>org.apache.axis.encoding.SimpleType</li>
1469 <li>org.apache.axis.encoding.Target</li>
1470 <li>org.apache.axis.encoding.TypeMapping</li>
1471 <li>org.apache.axis.encoding.TypeMappingRegistry</li>
1472 <li>org.apache.axis.encoding.ser.BaseDeserializerFactory</li>
1473 <li>org.apache.axis.encoding.ser.BaseSerializerFactory</li>
1474 <li>org.apache.axis.encoding.ser.BeanPropertyTarget</li>
1475 <li>org.apache.axis.encoding.ser.SimpleSerializer</li>
1476 <li>org.apache.axis.encoding.ser.SimpleDeserializer</li>
1477 <li>org.apache.axis.session.Session</li>
1478 <li>org.apache.axis.transport.http.SimpleAxisServer</li>
1479 <li>org.apache.axis.transport.jms.SimpleJMSListener</li>
1480 <li>org.apache.axis.utils.BeanProperty</li>
1481 <li>org.apache.axis.wsdl.WSDL2Java</li>
1482 <li>org.apache.axis.wsdl.Java2WSDL</li>
1483 </ul>
1484 </ul>
1485 <h2><a name="newbie"></a>Newbie Tips: Finding Your Way Around</h2>
1486 <p>So you've skimmed the User's Guide and written your first .jws service,
1487 and everything went perfectly! Now it's time to get to work on a real project,
1488 and you have something specific you need to do that the User's Guide didn't
1489 cover.
1490 It's a simple thing, and you know it must be in Axis <em>somewhere</em>, but
1491 you don't know what it's called or how to get at it. This section is meant to
1492 give you some starting points for your search.</p>
1493 <h3>Places to Look for Clues</h3>
1494 <p>Here are the big categories.</p>
1495 <ul>
1496 <li><a href="../samples/"><b>The samples.</b></a> These examples are
1497 complete with deployment descriptors and often contain both client and
1498 server code.
1499 </li>
1500 <li><b>The Javadocs.</b> Full Javadocs are included with the binary
1501 distribution.
1502 The Javadocs can be intimidating at first, but once you know the major user
1503 classes, they are one of the fastest ways to an answer.</li>
1504 <li><b><a href="http://ws.apache.org/axis/mail.html">The mailing list
1505 archives.</a></b>
1506 If you know what you want but don't know what it's called in Axis, this is
1507 the best place to look. Chances are someone has wanted the same thing and
1508 someone else has used (or developed) Axis long enough know the name.</li>
1509
1510 <li> Consult the <A HREF="http://ws.apache.org/axis">Axis web site</a> for updated documentation and the
1511 <a href="http://nagoya.apache.org/wiki/apachewiki.cgi?AxisProjectPages">Axis Wiki</a>
1512 for its Frequently Asked Questions (FAQ), installation notes,
1513 interoperability issues lists, and other useful information.
1514 </li>
1515
1516 <li> <b>WSDL2Java.</b> Point WSDL2Java at a known webservice that does some
1517 of the things you want to do. See what comes out. This is useful even if
1518 you
1519 will be writing the actual service or client from scratch. If you want
1520 nice,
1521 human-readable descriptions of existing web services, try
1522 <a href="http://www.xmethods.net">http://www.xmethods.net</a>.</li>
1523 </ul>
1524 <h3>Classes to Know</h3>
1525 <h4>org.apache.axis.MessageContext</h4>
1526 <p>The answer to most &quot;where do I find...&quot; questions for an Axis web
1527 service is &quot;in the MessageContext.&quot; Essentially everything Axis
1528 knows
1529 about a given request/response can be retrieved via the MessageContext. Here
1530 Axis stores:</p>
1531 <ul>
1532 <li>A reference to the AxisEngine</li>
1533 <li>The request and response messages (<code>org.apache.axis.Message</code>
1534 objects available via getter and setter methods)</li>
1535 <li>Information about statefulness and service scope (whether the service is
1536 maintaining session information, etc.)</li>
1537 <li>The current status of processing (whether or not the &quot;pivot&quot;
1538 has
1539 been passed, which determines whether the request or response is the
1540 current
1541 message)</li>
1542 <li>Authentication information (username and password, which can be provided
1543 by a servlet container or other means)</li>
1544 <li>Properties galore. Almost anything you would want to know about the
1545 message
1546 can be retrieved via <code>MessageContext.getProperty()</code>.
1547 You only need
1548 to know the name of the property. This can be tricky, but it is usually a
1549 constant, like those defined in
1550 <code>org.apache.axis.transport.http.HTTPConstants</code>.
1551 So, for example, to retrieve the ServletContext for the Axis Servlet, you
1552 would want: <code>((HttpServlet)msgC.getProperty(HTTPConstants.MC_HTTP_SERVLET)).getServletContext();</code><br>
1553 </li>
1554 </ul>
1555 <p>From within your service, the current MessageContext object is always
1556 available
1557 via the static method <code>MessageContext.getCurrentContext()</code>. This
1558 allows you to do any needed customization of the request and response
1559 methods,
1560 even from within an RPC service that has no explicit reference to the
1561 MessageContext.</p>
1562 <h4>org.apache.axis.Message</h4>
1563 <p>An <code>org.apache.axis.Message</code> object is Axis's representation of
1564 a SOAP message. The request and response messages can be retrieved from the
1565 MessageContext as described above. A Message has:</p>
1566 <ul>
1567 <li>MIME headers (if the message itself has MIME information)</li>
1568 <li>Attachments (if the message itself has attachments)</li>
1569 <li>A SOAPPart (and a convenience method for quick retrieval of the
1570 SOAPPart's
1571 SOAPEnvelope). The SOAPPart gives you access to the SOAP &quot;guts&quot;
1572 of the message (everything inside the &lt;soap:Envelope&gt; tags)</li>
1573 </ul>
1574 <h4>org.apache.axis.SOAPEnvelope</h4>
1575 <p>As you can see, starting with the MessageContext lets you work your way
1576 down
1577 through the API, discovering all the information available to you about a
1578 single
1579 request/response exchange. A MessageContext has two Messages, which each
1580 have
1581 a SOAPPart that contains a SOAPEnvelope. The SOAPEnvelope, in turn, holds
1582 a full representation of the SOAP Envelope that is sent over the wire. From
1583 here you can get and set the contents of the SOAP Header and the SOAP Body.
1584 See the Javadocs for a full list of the properties available.</p>
1585 <h2> <a NAME="tcpmon"></a>Appendix : Using the Axis TCP Monitor (tcpmon)</h2>
1586 The included "tcpmon" utility can be found in the org.apache.axis.utils
1587 package. To run it from the command line:
1588 <pre>% java org.apache.axis.utils.tcpmon [listenPort targetHost targetPort]</pre>
1589 Without any of the optional arguments, you will get a gui which looks like
1590 this:
1591 <center>
1592 <p><img SRC="images/tcpmon1.jpg" height=599 width=599></center>
1593
1594 <p>To use the program, you should select a local port which tcpmon will
1595 monitor for incoming connections, a target host where it will forward such
1596 connections, and the port number on the target machine which should be
1597 "tunneled" to. Then click "add". You should then notice another tab appearing
1598 in the window for your new tunneled connection. Looking at that panel,
1599 you'll see something like this:
1600 <center>
1601 <p><img SRC="images/tcpmon2.jpg" height=600 width=599></center>
1602
1603 <p>Now each time a SOAP connection is made to the local port, you will
1604 see the request appear in the "Request" panel, and the response from the
1605 server in the "Response" panel. Tcpmon keeps a log of all request/response
1606 pairs, and allows you to view any particular pair by selecting an entry
1607 in the top panel. You may also remove selected entries, or all of them,
1608 or choose to save to a file for later viewing.
1609 <p>The "resend" button will resend the request you are currently viewing, and
1610 record a new response. This is particularly handy in that you can edit the XML
1611 in the request window before resending - so you can use this as a great tool
1612 for testing the effects of different XML on SOAP servers. Note that you may
1613 need to change the content-length HTTP header value before resending an edited
1614 request.
1615
1616 <h2> <a NAME="soapmon"></a>Appendix: Using the SOAP Monitor </h2>
1617 Web service developers often have the need to see the SOAP messages
1618 being used to invoke web services along with the results of those
1619 messages. The goal of the SOAP Monitor utility is to provide
1620 a way for these developers to monitor the SOAP messages being used
1621 without requiring any special configuration or restarting of the
1622 server.
1623 <p>
1624 In this utility, a handler has been written and added to the global
1625 handler chain. As SOAP requests and responses are received, the SOAP
1626 message information is forwarded to a SOAP monitor service where it
1627 can be displayed using a web browser interface.
1628 <p>
1629 The SOAP message information is accessed with a web browser by going
1630 to http://localhost:&lt;port&gt;/axis/SOAPMonitor (where
1631 &lt;port&gt; is the port number where the application server is
1632 running).
1633 <p>
1634 The SOAP message information is displayed through a web browser
1635 by using an applet that opens a socket connection to the SOAP
1636 monitor service. This applet requires a Java plug-in 1.3 or
1637 higher to be installed in your browser. If you do not have a
1638 correct plug-in, the browser should prompt you to install one.
1639 <p>
1640 The port used by the SOAP monitor service to comminicate with
1641 applets is configurable. Edit the web.xml file for the Axis
1642 web application to change the port to be used.
1643
1644 <b>Note: The SOAP Monitor is NOT enabled by default for security reasons.</b>
1645 To enable it, read <a href="install.html#soapmon">Enabling the
1646 SOAP Monitor</a> in the Installation instructions.
1647
1648 <a NAME="Glossary">
1649 <h2>Glossary</h2></a>
1650
1651 <dl>
1652 <dt> <i>Handler</i></dt>
1653 <dd> A reusable class which is responsible for processing a MessageContext in
1654 some custom way. The Axis engine invokes a series of Handlers whenever a request
1655 comes in from a client or a transport listener.</dd>
1656 <dt> <i>SOAP</i></dt>
1657 <dd> The Simple Object Access Protocol (yes, despite the fact that it sometimes
1658 doesn't seem so simple, and doesn't have anything to do with objects... :)).
1659 You can read the SOAP 1.1 specification at <a href="http://www.w3.org/TR/SOAP">http://www.w3.org/TR/SOAP</a>.
1660 The W3C is currently in the midst of work on SOAP 1.2, under the auspices
1661 of the <a href="http://www.w3.org/2000/xp/Group/">XML Protocol Group</a>.</dd>
1662 <dt> <i>Provider</i></dt>
1663 <dd> A provider is the &quot;back-end&quot; Handler which is responsible for
1664 actually performing the &quot;meat&quot; of the desired SOAP operation. Typically
1665 this means calling a method on some back-end service object. The two commonly
1666 used providers are RPCProvider and MsgProvider, both in the org.apache.axis.providers.java
1667 package.</dd>
1668
1669 </dl>
1670
1671 </body>
1672 </html>