This sample demonstrates how you can use the Mail transport in WSO2 Application Server to invoke Web Services. You can find the sample discussed here in <AS_HOME>/samples/Mail directory.
In this sample, a client sends a message to a mailbox in a mail server and the service listens to that mailbox and receives the message. Before deploying a service which uses the Mail transport, you have to enable transports for receiving and sending messages using <AS_HOME>/repository/conf/axis2/axis.xml file. By default, the Mail transport receiver and sender are disabled.
Mail transport Sender
Mail transport Receiver
The services.xml of the service should contain the following parameters to receive messages through the mail transport.
You have to set the following parameters to your ServiceClient to receive messages, if your service has In-Out operations.
Your client axis2.xml file should also contain the transport receiver and sender as explained above.
You can see how above configurations are used in the sample by going through the source code and the configuration files provided in <AS_HOME>/samples/Mail directory.
If the WSO2 Application Server is running, shut down the server. Open <AS_HOME>/repository/conf/axis2/axis2.xml and uncomment "mailto" transportReceiver and transportSender. This sample can be run with the default values set for the parameters.
1. In a command prompt, switch to the sample directory.
For example, cd <AS_HOME>\samples\Mail
2. From there, type ant.
3. This creates the "Mail Test service" (MailTestService.aar file) in the <AS_HOME>/repository/deployment/server/axis2services directory.
If you start the Application Server and access the AS Management Console, you should see the "MailTestService" service under deployed services.
4. Click on the service name in the deployed services page. This will open up the dashboard of the service "MailTestService".
5. Refer to the service's mail transport endpoint under the "Endpoints" section of the dashboard. It should be as follows:
6. You can find the mail transport endpoints in the service's WSDL file as well.You can view the WSDL for the service at:
To run the sample client for the service, go to <AS_HOME>/samples/Mail directory and type:sh run-client.sh (in linux). Check the server console and you will see the message printed from the service on the message receival. Log in the to the ‘[email protected]’ by using the password ‘mailpassword’, and verify that a mail has been received which has the subject ‘SOAPAction: urn:ping’