com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_link3' is unknown.

Using Mail transport to Invoke Web Services

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.

Configuration

Mail transport Sender

<transportSender name="mailto">
          <parameter name="mail.smtp.from">synapse.demo.0@gmail.com</parameter>
          <parameter name="mail.smtp.user">synapse.demo.0</parameter>
          <parameter name="mail.smtp.password">mailpassword</parameter>
          <parameter name="mail.smtp.host">smtp.gmail.com</parameter>
          <parameter name="mail.smtp.port">587</parameter>
          <parameter name="mail.smtp.starttls.enable">true</parameter>
          <parameter name="mail.smtp.auth">true</parameter>
</transportSender>

Mail transport Receiver

<transportReceiver name="mailto">

</transportReceiver>

The services.xml of the service should contain the following parameters to receive messages through the mail transport.

<parameter name="transport.mail.Address">synapse.demo.1@gmail.com</parameter>
<parameter name="transport.mail.Protocol">pop3</parameter>
<parameter name="transport.PollInterval">5</parameter>
<parameter name="mail.pop3.host">pop.gmail.com</parameter>
<parameter name="mail.pop3.port">995</parameter>
<parameter name="mail.pop3.user">synapse.demo.1</parameter>
<parameter name="mail.pop3.password">mailpassword</parameter>
<parameter name="mail.pop3.socketFactory.class">javax.net.ssl.SSLSocketFactory</parameter>
<parameter name="mail.pop3.socketFactory.fallback">false</parameter>
<parameter name="mail.pop3.socketFactory.port">995</parameter>
<parameter name="transport.mail.ContentType">text/xml</parameter>

You have to set the following parameters to your ServiceClient to receive messages, if your service has In-Out operations.

serviceClient.getAxisService().addParameter("transport.mail.Address", "synapse.demo.0@gmail.com");
serviceClient.getAxisService().addParameter("transport.mail.Protocol", "pop3");
serviceClient.getAxisService().addParameter("transport.PollInterval", "5");
serviceClient.getAxisService().addParameter("mail.pop3.host", "pop.gmail.com");
serviceClient.getAxisService().addParameter("mail.pop3.user", "synapse.demo.0");
serviceClient.getAxisService().addParameter("mail.pop3.password", "mailpassword");
serviceClient.getAxisService().addParameter("mail.pop3.port", "995");

serviceClient.getAxisService().addParameter("mail.pop3.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
serviceClient.getAxisService().addParameter("mail.pop3.socketFactory.fallback", "false");
serviceClient.getAxisService().addParameter("mail.pop3.socketFactory.port", "995");
serviceClient.getAxisService().addParameter("transport.mail.ContentType", "text/xml");

Your client axis2.xml file should also contain the transport receiver and sender as explained above.

Note:
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.

Building the Service

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:

http://<host>:<port>/services/MailTestService?wsdl

Running the Client

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 ‘synapse.demo.1@gmail.com’ by using the password  ‘mailpassword’, and verify that a mail has been received which has the subject ‘SOAPAction: urn:ping’

com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.