Create Custom Connector using Mule XML SDK

Published on
April 2, 2021
Author
MuleSoft Integration Team
Create Custom Connector using Mule XML SDK

MuleSoft creates a great opportunity of reusing the readily available connectors but in some cases, the connector might not be available for connecting to a particular system. We need to write custom logic like spring beans/Java code to connect to it. However, if we don’t want to include the same logic in every API integration which implements the requirement, we can create a custom connector. There are broadly two types of custom connectors:

  1. Java SDK
  2. XML SDK.

This article will look at the XML SDK , which provides an easier learning curve than Java SDK and is more like developing a Mule application.

Anatomy of XML SDK

  1. Operations – An operation in XML SDK is relatable to a Java method with a set number of arguments required (can have zero arguments as well), a body to process, and an output.
  2. Properties – To define a global configuration, we can use properties inside a connector. When specified, a user can create a global configuration with defined properties.

Creating a custom connector

The first step while creating a custom connector is to generate a skeleton project.

Run the below command in the command prompt.

mvn archetype:generate -DarchetypeGroupId=org.mule.extensions -

DarchetypeArtifactId=mule-extensions-xml-archetype -

DarchetypeVersion=1.2.0 -DgroupId=demo-connector -DartifactId=demo-

connector -DmuleConnectorName=demo-connector
Argument Description
-DarchetypeGroupId Group ID of Archetype in the Mule repository
-DarchetypeArtifactId Artifact ID of the Archetype in the Mule repository
-DarchetypeVersion Version of the aerchetype
-DgroupId Group ID of the user’s Mule application
-DartifactId Artifact Id for user’s application/module
-DmuleConnectorName Name of the connector

Once generated, import it in MuleSoft Anypoint Studio. The structure looks like below:

xml-sdk-structure

module-Hello.xml contains the main logic implemented by the connector.

Here, we will write a simple connector with two operations. One to modify the incoming query parameter and second to return the sum of two numbers which will further pass in the parameters.

Operation to get sum of two numbers

<operation name="Get-Sum" doc:description="Return the sum of two incoming paramters">
		<parameters>
			<parameter name="num1" type="number" use="REQUIRED"/>
			<parameter name="num2" type="number" use="REQUIRED"/>
		</parameters>
		<body>
			<mule:set-payload
				value="#[vars.num1 + vars.num2]" />
		</body>
		<output type="number" />
	</operation>

Operation to modify the query param

<operation name="Modify-query-parameter"
		doc:description="Modifies the incoming query paramter">
		<parameters>
			<parameter name="qParam" type="string" use="REQUIRED"/>
		</parameters>
		<body>
			<mule:set-payload value="#['Hello ' ++ vars.qParam]" />
		</body>
		<output type="string" />
	</operation>

To install the connector locally, run mvn clean install

To use the connector in project, add the dependency

<dependency>
	<groupId>{group id of connector}</groupId>
	<artifactId>{artifact id of connector}</artifactId>
	<version>{version of connector}</version>
	<classifier>mule-plugin</classifier>
</dependency>

Once done, the connector will be available in the Mule palette.

xml-sdk-pallette-view.

Add the operations in the flow as required. Below is the property view for each operation.

xml-sdk-operation-1xml-sdk-operation-2

Conclusion

Mule XML-based SDK is a straightforward and efficient way to create a custom connector and fulfill any ad hoc requirements.

Find more MuleSoft Technical guides at Caelius Consulting MuleSoft Resource Centre.

Recent Blogs

Boost LWC Performance with Debouncing
BlogSep 18, 2025

Boost LWC Performance with Debouncing

Introduction Lightning Web Components (LWC) is a modern framework for building fast and dynamic user interfaces on the Salesforce platform. However, one common challenge in web development, including LWC, is efficiently handling user input, especially when dealing with rapid or repetitive events, such as typing in a search field. This is where debouncing becomes an… Continue reading Boost LWC Performance with Debouncing

Read More
Blog
7 min read

Boost LWC Performance with Debouncing

Introduction Lightning Web Components (LWC) is a modern framework for building fast and dynamic user interfaces on the Salesforce platform. However, one common challenge in web development, including LWC, is efficiently handling user input, especially when dealing with rapid or repetitive events, such as typing in a search field. This is where debouncing becomes an… Continue reading Boost LWC Performance with Debouncing

Read More
Salesforce Pricing Automation: Boost Efficiency And Accuracy with Apex Triggers
BlogSep 9, 2025

Salesforce Pricing Automation: Boost Efficiency And Accuracy with Apex Triggers

Introduction In order to succeed in today’s fast-paced business landscape, precision and speed define competitive advantage. For businesses, especially those managing complex product catalogs, ensuring accurate pricing on sales orders or custom lines can be a time-consuming and error-prone task. To overcome this challenge, Salesforce trigger handlers offer a powerful solution to automate the entire… Continue reading Salesforce Pricing Automation: Boost Efficiency And Accuracy with Apex Triggers

Read More
Blog
6 min read

Salesforce Pricing Automation: Boost Efficiency And Accuracy with Apex Triggers

Introduction In order to succeed in today’s fast-paced business landscape, precision and speed define competitive advantage. For businesses, especially those managing complex product catalogs, ensuring accurate pricing on sales orders or custom lines can be a time-consuming and error-prone task. To overcome this challenge, Salesforce trigger handlers offer a powerful solution to automate the entire… Continue reading Salesforce Pricing Automation: Boost Efficiency And Accuracy with Apex Triggers

Read More
Connecting MuleSoft and Azure SQL with Entra ID
BlogJul 14, 2025

Connecting MuleSoft and Azure SQL with Entra ID

Introduction Establishing a secure connection between MuleSoft and Azure SQL Database can be challenging, especially if you are using Entra ID (formerly known as Azure Active Directory) for authentication. This blog walks through a fully working configuration for connecting to Azure SQL using ActiveDirectoryServicePrincipal in Mule runtime 4.7.4 with Java 8 — addressing driver setup,… Continue reading Connecting MuleSoft and Azure SQL with Entra ID

Read More
Blog
2 min read

Connecting MuleSoft and Azure SQL with Entra ID

Introduction Establishing a secure connection between MuleSoft and Azure SQL Database can be challenging, especially if you are using Entra ID (formerly known as Azure Active Directory) for authentication. This blog walks through a fully working configuration for connecting to Azure SQL using ActiveDirectoryServicePrincipal in Mule runtime 4.7.4 with Java 8 — addressing driver setup,… Continue reading Connecting MuleSoft and Azure SQL with Entra ID

Read More
Understanding Salesforce Flow Approval Processes
BlogJun 30, 2025

Understanding Salesforce Flow Approval Processes

Introduction: Salesforce introduced Flow Approval Processes in the Spring '25 release. This is an evolved version of the classic approval process model, powered by Flow Orchestrator. The new approach brings unprecedented flexibility, enabling the creation of dynamic, multi-level, and logic-driven approval workflows that are entirely declarative. Continue reading the blog to get a deeper understanding… Continue reading Understanding Salesforce Flow Approval Processes

Read More
Blog
5 min read

Understanding Salesforce Flow Approval Processes

Introduction: Salesforce introduced Flow Approval Processes in the Spring '25 release. This is an evolved version of the classic approval process model, powered by Flow Orchestrator. The new approach brings unprecedented flexibility, enabling the creation of dynamic, multi-level, and logic-driven approval workflows that are entirely declarative. Continue reading the blog to get a deeper understanding… Continue reading Understanding Salesforce Flow Approval Processes

Read More