Understanding Service xml file Web Service
Full description of the services are specified using services.xml file. Each web service archive file needs to have one services.xml in order to be valid service. It should be available, if you have war distribution this will be ../WEB-INF/services inside servlet container.
<service name="name of the service" scope="name of the scope" class="fully qualified name the service lifecycle class" targetNamespace="target namespace for the service"> <Description> The description of the service </Description> <transports> <transport>HTTP</transport> </transports> <schema schemaNamespace="schema namespace"/> <messageReceivers> <messageReceiver mep="http://www.w3.org/ns/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/> </messageReceivers> <parameter name="ServiceClass" locked="xsd:false">org.apache.axis2.sample.echo.EchoImpl</parameter> <operation name="echoString" mep="operation MEP"> <actionMapping>Mapping to action</actionMapping> <module ref=" a module name "/> <messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/> </operation> </service>
- name: Service name will be name of archive file if .aar file contains only one service otherwise name of the service will be name given by the name attribute
- scope: (Optional) Time period during which runtime information of a deployed services will be available. Scope are application, soapsession, transportsession, request. The default value is “request”
- class: (Optional) Fully qualified name of the service life-cycle implementation class. Service Life-Cycle class is useful when you want to do some tasks when system starts and when it shuts down
- targetNamespace: (Optional) Target name space of a service. This is used when generating the WSDL. Default value value will be calculated from package name of service impl class
- Description: (Optional) This is again to display any description about the service through Axis2 web admin module then its needed
- transports : (Optional) Transports through which service is going to be exposed. If this element is not present, it will not be exposed in all transports available in system. Transport child element specifies transport prefix (It’s specified in axis2.xml)
- parameters: services.xml can contain number of top level parameters, all specified parameters will be transformed into service properties in the corresponding AxisService. Compulsory parameter in services.xml called ServiceClass which specifies Java class which performs above transformation
- operations : If Service impl class is Java then all public methods in that service will be exposed. To override it, you have to add the “operation” tag and override it. Although in non Java scenario OR if you do not have service class then all operations which user wants to expose by service has to be indicated in services.xml
<operation name="echoString"> <module ref=" a module name "/> <messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/> </operation>
Reference: