This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit

WSO2 ESB Connectors

The connectors listed in this section are older versions of WSO2 ESB connectors. To find the documentation relevant to the version you are using, select the connector from the WSO2 Connector Store and click Documentation.

A WSO2 connector allows you to interact with the functionality and data of a third-party product from your WSO2 ESB message flow. Thus it enables you to connect to and interact with the APIs of services such as Twitter, Salesforce, JIRA etc. For example, if you have enabled the Twitter and Google Spreadsheet connectors in your ESB instance, your message flow can receive requests containing a user's Twitter name and password, log into the user's Twitter account, get a list of the user's followers, and write that information to a Google spreadsheet. You can use one or more connectors in order to manage generic use cases related to a business scenario that you may need to address.

Each connector provides a set of  operations , which you call from your proxy services, sequences, and APIs to interact with that product. For example, the Twitter connector provides operations that call the Twitter APIs to get and send direct messages, retrieve IDs of friends and followers, update status, retweet other users' status, and more. If you want your configuration to send a direct message to a Twitter user, you could call the  twitter.sendDirectMessage  operation and pass in the Twitter user's ID and the direct message text.

Types of Connectors

WSO2 ESB connectors are components that encapsulate third-party API calls.

Before you start writing a connector, you need to research the APIs provided by the service for which you want to write the connector. For example, if you are writing a connector for JIRA, you will see that JIRA provides a REST API and Java API. If you choose the REST API, you can create your connector and operations entirely from XML configuration files. If you choose a Java API, you can create XML configuration files that define your connector and point to your Java classes that define the operations.

This section describes the different types of connectors in detail so that you can decide on the API you are going to use to write the connector.

SOAP-based connectors

If you are writing a SOAP API based connector, you can write the entire connector with Synapse configurations. You can create a maven project in your preferred IDE with a directory structure as described in Creating the Maven project template.

Following is an example of a SOAP-based connector that is written for Salesforce to execute the query method of the API:


Here the required payload is created using the PayloadFactory Mediator and the request is sent using the Call Mediator.

REST-based connectors

You can write a REST-based connector in a manner very much similar to how you write a SOAP-based connector. The only difference is the underlying communication mechanism. You can basically write a REST-based connector by using synapse configurations similar to SOAP-based connector.

Following is an example of a SOAP-based connector calling the Twitter rest API:

<template xmlns = "" name = "search">
  <parameter name = "search"/>
  <parameter name = "accessToken"/>
    <property name = "" expression = "$func:search"/>
    <property name = "Authorization" expression = "$func:accessToken" scope = "transport"/>
    <property name = "messageType" value = "application/x-www-form-urlencoded" scope = "axis2"/>
    <payloadFactory media-type = "xml">
     <format >
                 = "">
     <http method = "GET" uri-template = "{}"/>

Java API-based connectors

If you are writing a Java API-based connector, you have to use a custom class mediator to implement it. You need to extend the AbstractConnector class and implement its connect method. All the required logic must be done within this method. Once you have implemented this method, you can call the method using the synapse configuration, which is in the .xml file.

Following is an example of a connector Java class written for Twilio to send an SMS:

import java.util.HashMap;
import java.util.Map;

import org.apache.synapse.MessageContext;
import org.apache.synapse.SynapseException;
import org.apache.synapse.SynapseLog;

import org.wso2.carbon.connector.core.AbstractConnector;
import org.wso2.carbon.connector.core.util.ConnectorUtils;
import org.wso2.carbon.connector.twilio.util.TwilioUtil;

import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.resource.factory.SmsFactory;
import com.twilio.sdk.resource.instance.Sms;

public class SendSms extends AbstractConnector {
    public void connect(MessageContext messageContext) {

        SynapseLog log = getLog(messageContext);
        log.auditLog("Start: send SMS");

        String to = (String) ConnectorUtils.lookupTemplateParamater(messageContext, TwilioUtil.PARAM_TO);
        String from = (String) ConnectorUtils.lookupTemplateParamater(messageContext, TwilioUtil.PARAM_FROM);
        String body = (String) ConnectorUtils.lookupTemplateParamater(messageContext, TwilioUtil.PARAM_BODY);
        String statusCallBackUrl = (String) ConnectorUtils.lookupTemplateParamater(messageContext,
        String applicationSid = (String) ConnectorUtils.lookupTemplateParamater(messageContext,
        Map<string, string> params = new HashMap<string, string>();

        params.put(TwilioUtil.TWILIO_TO, to);
        params.put(TwilioUtil.TWILIO_FROM, from);
        params.put(TwilioUtil.TWILIO_BODY, body);

        if (applicationSid != null) {
            params.put(TwilioUtil.TWILIO_APPLICATION_SID, applicationSid);
        if (statusCallBackUrl != null) {
            params.put(TwilioUtil.TWILIO_STATUS_CALLBACK, statusCallBackUrl);

        try {
            TwilioRestClient twilioRestClient = TwilioUtil.getTwilioRestClient(messageContext);
            SmsFactory messageFactory = twilioRestClient.getAccount().getSmsFactory();
            Sms message = messageFactory.create(params);
            OMElement omResponse = TwilioUtil.parseResponse("sms.create.success");

            TwilioUtil.addElement(omResponse, TwilioUtil.PARAM_MESSAGE_SID, message.getSid());
            TwilioUtil.addElement(omResponse, TwilioUtil.PARAM_STATUS, message.getStatus());
            TwilioUtil.preparePayload(messageContext, omResponse);
        } catch (Exception e) {

            messageContext.setProperty(SynapseConstants.ERROR_EXCEPTION, e);
            messageContext.setProperty(SynapseConstants.ERROR_MESSAGE, e.getMessage());
            messageContext.setProperty(SynapseConstants.ERROR_CODE, "0007");

            throw new SynapseException(e);

        log.auditLog("End: send SMS");

Following is the associated sendSms.xml that calls the class mediator:

<template name = "sendSms" xmlns = "">
  <parameter name = "body"/>
  <parameter name = "to"/>
  <parameter name = "from"/>
  <parameter name = "statusCallBackUrl"/>
  <parameter name = "applicationSid"/>
   <class name = "org.wso2.carbon.connector.twilio.sms.SendSms"/>

Now that you understand the possible types of connectors, you can decide on the API you are going to use to write the connector. The complete list of WSO2 ESB connectors is as follows: