Java(TM) API for XML-based RPC (JAX-RPC) Tools
Revised: 7 October, 2003
Contents
wscompile
The
wscompile
tool generates stubs, ties, serializers, and WSDL files used in JAX-RPC clients and services. The tool reads a configuration file, which specifies either a WSDL file, a model file, or a compiled service endpoint interface.Syntax
By convention, the configuration file is named
config.xml
, but this is not a requirement. The following table lists the wscompile options. Note that exactly one of the-import
,-define
, or-gen
options must be specified.
The following table lists the features (delimited by commas) that may follow the
-f
option. The wscompile tool reads as input either a WSDL file, compiled service endpoint interface (SEI), or model file. The Type of File column indicates which of these files can be used with a particular feature.
Configuration File
The
wscompile
tool reads the configuration file (config.xml
), which contains information that describes the web service. The basic structure ofconfig.xml
follows:<?xml version="1.0" encoding="UTF-8"?> <configuration xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config"> <service> or <wsdl> or <modelfile> </configuration>The
<configuration>
element may contain exactly one<service>
,<wsdl>
, or<modelfile>
element.The <service> Element
If you specify this element, wscompile reads the service endpoint interface that describes the service and generates a WSDL file. In the
<interface>
subelement, the name attribute specifies the service endpoint interface, and theservantName
attribute specifies the class that implements the interface. For example:<service name="CollectionIF_Service" targetNamespace="http://echoservice.org/wsdl" typeNamespace="http://echoservice.org/types" packageName="stub_tie_generator_test"> <interface name="stub_tie_generator_test.CollectionIF" servantName="stub_tie_generator_test.CollectionImpl"/> </service>The <wsdl> Element
If you specify this element,
wscompile
reads the service's WSDL file and generates the service endpoint interface. The location attribute specifies the URL of the WSDL file, and thepackageName
attribute specifies the package of the classes generated bywscompile
. For example:The <modelfile> Element
This element is for advanced users.
If
config.xml
contains a<service>
or<wsdl>
element,wscompile
generates a model file that contains the internal data structures that describe the service. If you've already generated a model file in this manner, then you can reuse it the next time you runwscompile
. For example:wsdeploy
The
wsdeploy
tool reads a WAR file and thejaxrpc-ri.xml
file and then generates another WAR file that is ready for deployment. Behind the scenes,wsdeploy
runswscompile
with the-gen:server
option. Thewscompile
command generates classes and a WSDL file thatwsdeploy
includes in the generated WAR file.On JWSDP, the
wsdeploy
tool must be run. However, on J2EE you don't have to runwsdeploy
because the functions it performs are done automatically when you deploy a WAR withdeploytool
orasadmin
.Syntax
The syntax for wsdeploy follows:
The following table lists the tool's options. Note that the
-o
option is required.
The Input WAR File
Typically, you create the input WAR file with a GUI development tool or with the
ant
war
task. Here are the contents of a simple input WAR file:META-INF/MANIFEST.MF WEB-INF/classes/hello/HelloIF.class WEB-INF/classes/hello/HelloImpl.class WEB-INF/jaxrpc-ri.xml WEB-INF/web.xmlIn this example,
HelloIF
is the service endpoint interface andHelloImpl
is the class that implements the interface. Theweb.xml
file is the deployment descriptor of a web component. Thejaxrpc-ri.xml
file is described in the next section.The jaxrpc-ri.xml File
The listing that follows shows a
jaxrpc-ri.xml
file for a simpleHelloWorld
service.<?xml version="1.0" encoding="UTF-8"?> <webServices xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/dd" version="1.0" targetNamespaceBase="http://com.test/wsdl" typeNamespaceBase="http://com.test/types" urlPatternBase="/ws"> <endpoint name="MyHello" displayName="HelloWorld Service" description="A simple web service" wsdl="/WEB-INF/<wsdlame> interface="hello.HelloIF" implementation="hello.HelloImpl"/> <endpointMapping endpointName="MyHello" urlPattern="/hello"/> </webServices>The
<webServices>
element must contain one or more<endpoint>
elements. In this example, note that the interface and implementation attributes of<endpoint>
specify the service's interface and implementation class. The<endpointMapping>
element associates the service name with a URL.Advanced Topics
This section is for developers who are familiar with WSDL, SOAP, and the JAX-RPC specifications.
Namespace Mappings
For the below
namespaceMappingRegistry
element in theconfig.xml
file,wscompile
behaves as follows. When going from WSDL types to Java types, for all types defined in thehttp://echoservice.org/types
namespace,wscompile
will generate Java classes in theechoservice.org.types
package. Likewise, for all schema types defined in thehttp://echoservice.org/types2
namespace,wscompile
generate Java classes in theechoservice.org.types2
package.<namespaceMappingRegistry> <namespaceMapping namespace="http://echoservice.org/types" packageName="echoservice.org.types"/> <namespaceMapping namespace="http://echoservice.org/types2" packageName="echoservice.org.types2"/> </namespaceMappingRegistry>Handlers
A handler accesses a SOAP message that represents an RPC request or response. A handler class must implement the
javax.xml.rpc.handler
interface. Because it accesses a SOAP message, a handler can manipulate the message with the APIs of thejavax.xml.soap
package.A handler chain is a list of handlers. You may specify one handler chain for the server and one for the client. On the server, you include the
<handlerChains>
element in thejaxrpc-ri.xml
file. On the client , you include this element in theconfig.xml
file. Here is an example of the<handlerChains>
element inconfig.xml
:<handlerChains> <chain runAt="server" roles= "http://acme.org/auditing http://acme.org/morphing" xmlns:ns1="http://foo/foo-1"> <handler className="acme.MyHandler" headers ="ns1:foo ns1:bar"/> <property name="property" value="xyz"/> </handler> </chain> </handlerChains>For more information on handlers, see the SOAP Message Handlers chapter of the JAX-RPC specifications.
Copyright © 2003 Sun Microsystems, Inc. All rights reserved.