java:EJB
beanJndiName
: name used in Axis lookup. (you can
set here a java:comp/env name if you add ejb-ref or ejb-local-ref in
the web-app descriptor).homeInterfaceName
: EJB Home interface fully
qualified class name.remoteInterfaceName
: EJB Remote interface
fully qualified class name.localHomeInterfaceName
: Local EJB Home interface
fully qualified class name.localInterfaceName
: Local EJB interface fully
qualified class name.allowedMethods
: comma separated list of method
names accessible via the web service.java:RPC
className
: the fully qualified name of the class
you want to expose as web service.allowedMethods
: comma separated list of method
names accessible via the web service.org.apache.axis.wsdl.
WSDL2Java
tool.jclient org.apache.axis.wsdl.WSDL2Java
--output <destination directory> --NStoPkg
<namespace>=<package> <wsdl url>
--NStoPkg
option is used to place generated classes in a
convenient package according to the namespace of the WSDL Definition
and the namespace(s) of the XML Schema(s). <taskdef name="axis-wsdl2java"
classname="org.apache.axis.tools.ant.wsdl.Wsdl2javaAntTask">
<!-- classpath holds jonas.jar,
webservices_axis.jar, ... -->
<classpath refid="base.classpath"/>
</taskdef>
<axis-wsdl2java url="${ws.google.wsdl}/GoogleSearch.wsdl"
output="${src.dir}">
<mapping namespace="urn:GoogleSearch"
package="org.objectweb.wssample.gen.google"/>
</axis-wsdl2java>
code :import
path.to.your.generated.classes.*; |
import javax.xml.rpc.Call; // configure mappings if web service use Complex
types TypeMappingRegistry
tmr = service.getTypeMappingRegistry(); new QName("namespace-of-complex-type",
"complex-type-name"); TypeMapping
tm = tmr.getDefaultTypeMapping(); BeanSerializerFactory( your.java.Type.class,
xmlType ), BeanDeserializerFactory( your.java.Type.class,
xmlType ) ); setTargetEndpointAddress("url-address-of-the-endpoint");
// now, we can invoke the web service
with its parameters String result = call.invoke(new Object[] {"Hello,
World!"}); |
<service>
is the tag used to declare a web service.name
: unique name of the serviceprovider
: bridge used by Axis to invoke differents
objects : EJB, normal classes, CORBA objects, ...style
: Defines global format of the SOAP Message.use
: SOAP encoded message or message enclosing
classic XML Elements (depends on the style attributes)Description of the different styles <soap:body> style=RPC, use=literal First element of the SOAP body is the operation. The operation contains elements describing the parameters, which are serialized as encoded (no multi-ref)\ <soap:body> style=document, use=literal Elements of the SOAP body are the names of the parameters (there is no wrapper operation...no multi-ref) <soap:body> style=wrapped Special case of DOCLIT where there is only one parameter and it has the same qname as the operation. In such cases, there is no actual type with the name...the elements are treated as parameters to the operation <soap:body> style=document, use=encoded There is not an enclosing operation name element, but the parmeters are encoded using SOAP encoding This mode is not (well?) supported by Axis. |
<parameter>
is the tag used to configure a service.
It's basically a name-value pair.name
: parameter name (key)value
: parameter valueclassName
: fully qualified class name of service
class (only used for provider RPC & MSG)beanJndiName
: name used in Axis lookup. (you can
set here a java:comp/env name if you add ejb-ref or ejb-local-ref in
the web-app descriptor).localHomeInterfaceName
: Local EJB Home interface
fully
qualified class name.localInterfaceName
: Local EJB interface fully
qualified class name.homeInterfaceName
: EJB Home interface fully
qualified class name.remoteInterfaceName
: Remote EJB interface fully
qualified class name.allowedMethods
: comma separated list of method
names accessible via the web service (for all providers)scope
: scope of the web service (Request
:
create a new Object for each request, Session
: keep the
same Object for a given Session ID, Application
: keep
the same Object for the entire application run)wsdlFile
: specify the static wsdl file to be served
when a ?WSDL request comes to the endpointnamespace
: specify the web service namespace
(override default namespace created from URL location of the service).
With this tag the developer can handle the namespace value :http://ws.servlets.wssample.objectweb.org
(for an JAX-RPC class named
org.objectweb.wssample.servlets.ws
) ! The developer can
write a shorter
and better namespace as he wish: urn:JaxRpcWsSample
for
example.operation
: used to describe the operation exposed
(avoid Axis to use reflection to discover the service interface). See
Axis doc for details.
<typeMapping xmlns:ns="urn:my.namespace"
serializer="your.java.serializer.factory"
deserializer="
your.java.deserializer.factory
"
qname="
ns:my-xml-type-name
"
type="
java:your.java.classname
"
encodingStyle="encoding-namespace"/>
Notes :
type value must be a qname in java prefixed namespace (java:XXX.YYY)
by default encodingStyle is set to
http://schemas.xmlsoap.org/soap/encoding/ (SOAP 1.1 Encoding)
When Arrays of Complex Types are serialized and/or
deserailized the factories to be used are :
org.apache.axis.encoding.ser.ArraySerializerFactory
org.apache.axis.encoding.ser.ArrayDeserializerFactory
<beanMapping xmlns:ns="urn:my.namespace"
languageSpecificType="java:your.java.classname"
qname="ns:my-xml-type-name"/>
Notes :
serializer and deserializer are automatically set to
BeanSerializerFactory and BeanDeserializerFactory
encodingStyle is automatically set to null (cannot be overridden)
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<!-- ... services definitions here ... -->
</deployment>
Deploy Created Web Service
jclient org.apache.axis.client.AdminClient
-lhttp://<hostname>:<port>/<web-app-context>/<servlet-mapping-to-Axis-Servlet>
<your-deploy>.wsdd