java:EJB
beanJndiName
: name used in Axis lookup. (a java:comp/env
name can be set here if ejb-ref or ejb-local-ref is added in the web-app
descriptor)homeInterfaceName
: EJB Home interface fully-qualified
class nameremoteInterfaceName
: EJB Remote interface
fully-qualified class namelocalHomeInterfaceName
: Local EJB Home interface
fully-qualified class namelocalInterfaceName
: Local EJB interface fully-qualified
class nameallowedMethods
: comma-separated list of method names
accessible via the web servicejava:RPC
className
: the fully-qualified name of the class to be
exposed as a 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 different objects:
EJB, normal classes, CORBA objects, ...style
: defines global format of the SOAP Messageuse
: 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 no enclosing operation name element, but the parameters are encoded using SOAP encoding This mode is not (well?) supported by Axis. |
<parameter>
is the tag used to configure a service. It is
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. (a java:comp/env
name can be set here if ejb-ref or ejb-local-ref is added in the web-app
descriptor)localHomeInterfaceName
: Local EJB Home interface
fully-qualified class namelocalInterfaceName
: Local EJB interface fully-qualified
class namehomeInterfaceName
: EJB Home interface fully-qualified
class nameremoteInterfaceName
: Remote EJB interface fully-qualified
class nameallowedMethods
: 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). The
developer can handle the namespace value with this tag.http://ws.servlets.wssample.objectweb.org
(for a JAX-RPC class
named org.objectweb.wssample.servlets.ws
). The developer can
write a more concise namespace as desired: for example,
urn:JaxRpcWsSample
.operation
: used to describe the operation exposed (avoid
Axis to use reflection to discover the service interface). Refer to the
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