Contact Us 1-800-596-4880

Anypoint Connector Development

DevKit is compatible only with Studio 6 and Mule 3. To build Mule 4 connectors, see the Mule SDK documentation.

This document quickly walks you through the decisions to make and the steps to take to get an Anypoint Connector development project started, get the connector working, and enhance it with the functionality you need. You can use this as a roadmap for your connector development effort.

Prerequisites

This document assumes you are familiar with the Anypoint Connector DevKit and have installed the appropriate versions of DevKit, JDK, the Anypoint DevKit Plugin and Maven as specified in Setting Up Your Development Environment.

Outline of the Connector Development Process

When you develop a connector using DevKit, your use cases drive a series of decisions about authentication, connectivity, and how to call operations on your target and pass data to the external application or other resource. These choices, in turn, drive what you develop. Where a choice presents itself, this document provides information to help you make a decision and provides links to the get more details.

Step 1 - Setting Up Your API Access

  1. Prepare a test environment for your connector. Details vary greatly based on the target system.

  2. SaaS – For some SaaS applications, the sandbox may be a separate account from the production account, or may answer at a different endpoint.

  3. On-premises – For some on-premises systems or Web services, you may simply have a separate standalone installation with dummy data instead of production data.

  4. Acquire any existing documentation for your target system, such as API documentation.

Refer to Setting Up API Access for detailed instructions.

Step 2 - Creating an Anypoint Connector Project

  1. Follow the process in Creating a Java SDK-Based Connector to start a connector development project in your development environment.

  2. Add any required Java libraries for your target system, such as client libraries or class libraries provided for the target system.

When finished, you should have a scaffold project, containing a Java class with the most basic functionality for a connector in place.

Step 3 - Authentication

If your API requires authentication, understand the authentication methods your API uses and select those that your connector supports. Based on your use case, select an authentication method from the table below. For more details, read Authentication which introduces all of the supported methods.

Authentication Method Notes

Connection Management

The simplest mode of authentication used for any non-OAuth protocols such as SAML, Kerberos, LDAP, NTLM, or to create a custom connection.

OAuth V1

Popular among RESTful Web services and cloud applications.

OAuth V2

Popular among RESTful Web services and cloud applications.

Step 4 - Defining Attributes, Operations, and a Data Model

Most of the Java code you write for your connector relates to how you call your API inside the connector’s operations and how the connector must pass data between those operations and Mule. This is the area that varies most among connectors, based on your API.

Use the table below to select an approach for building your connector based on the style of your API:

API Example Notes

Java Client Library

If an official or well-known third party library is available, this is generally the simplest connector style to implement, and is recommended. Most client libraries are actually wrappers for SOAP or RESTful APIs.

SOAP API

The defacto standard library for building and consuming SOAP Web services, this style handles client logic and Java object mapping to XML. In Anypoint Studio, the WSDL you indicate builds a connector automatically.

For more details, refer to Connector Attributes and Operations.

Step 5 - Building Unit and Functional Tests

A production-ready connector must have a suite of unit and functional tests; connectors use the standard JUnit framework. In practice, build your unit tests as you implement your connector’s operations. Most successful connector implementations use a test-driven approach to development.

  1. Develop one or more Mule flows that use the connector.

  2. Create an instance of FunctionalTestCase to run the test. For DevKit testing, run Mule inside a JUnit test case. Each test case you build extends the class FunctionalTestCase (a subclass of JUnit). The test case manages the lifecycle of a Mule runtime instance and calls flows to carry out the test.

  3. Programmatically examine the results of each test case to determine success or failure.

Before releasing the connector to the world, run a thorough test suite that covers all operations and exercises each major code path. The Maven-generated project contains one sample test case under the src/test/java directory to get you started.

Refer to Developing DevKit Connector Tests for details on how to implement connector test cases using JUnit.

Step 6 - Documenting Your Connector

A full-featured connector should have documentation. DevKit enables the creation of complete reference documentation including code samples.

  • Each time you add an operation to a connector, DevKit adds sample XML code snippets in comments in the source code. These snippets appear in the auto-generated connector documentation.

  • Review the auto-generated documentation to determine if you want to expand upon it, offering more than information than the simple documentation of individual operations.

Refer to Connector Reference Documentation for further details.

Step 7 - Packaging and Releasing Your Connector

When your connector is ready for release to a broad audience, take the following additional steps to ensure user success:

  1. Before releasing a connector, ensure your license agreement is in place.

  2. If your connector is intended only for internal use, you can share it as an Eclipse Update Site.

  3. To share your connector with the community, see Anypoint Exchange.

Refer to Packaging Your Connector for Release for full details.