To develop a simple Spring service, you have to provide a Spring
context.xml file, which has a .jar file containing the bean classes. Given below is an example of a simple Spring
context.xml file specifying a particular bean with an ID and a class name found in the .jar file.
The Echo Bean for this example is shown below. It can contain any type of service implementation.
For more information, refer to http://axis.apache.org/axis2/java/core/docs/spring.html
Deploying Spring Services
Follow the instructions below to deploy a Spring service to a running WSO2 AS instance.
- Log on to the product's management console and select Main -> Service -> Add -> Spring Service.
In the Add Spring Service window that appears, specify the relevant files and click Upload. For example,
Specifying a service hierarchy is optional. It allows you to customize your service endpoint reference. If the business logic of the same service changes over time, you can maintain multiple versions of the service by using service hierarchy at deployment.
For example, consider a service named "SpringTest". If the service hierarchy is not mentioned, then the service endpoint reference is ../services/SpringTest. With service hierarchy specified, for example as 1.0.0, the endpoint reference is ../services/1.0.0/SpringTest. Specifying a hierarchy is important if you want to manage services separately.
If the files are not faulty, the Select Beans to Deploy page appears.
If the beans specified in the spring
context.xmlfile are mentioned in the .jar file, they will be displayed on this page.
- Select the Include check box associated with the the beans you want to expose as Web services and click Generate.
- If the generation is successful, a message appears prompting you to refresh the page. Click OK.
- Refresh the Deployed Services page in your product's management console to view the newly added services listed.
If your service implementation depends on any third-party libraries, you can copy them to the
<AS_HOME>/repository/components/extensions directory and restart the server to get your service started.