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:
- Java SDK
- 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
- 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.
- 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:

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.

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


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

AI-Driven PDF Parsing in Salesforce
Introduction For the current digital ecosystem, data is an important aspect for decision-making. Yet, for many organizations, a significant portion of this valuable data remains locked away in unstructured formats. Organizations handle thousands of PDF documents daily — ranging from contracts and invoices to lab reports, quotations, and service agreements. Traditionally, extracting structured data from… Continue reading AI-Driven PDF Parsing in Salesforce
AI-Driven PDF Parsing in Salesforce
Introduction For the current digital ecosystem, data is an important aspect for decision-making. Yet, for many organizations, a significant portion of this valuable data remains locked away in unstructured formats. Organizations handle thousands of PDF documents daily — ranging from contracts and invoices to lab reports, quotations, and service agreements. Traditionally, extracting structured data from… Continue reading AI-Driven PDF Parsing in Salesforce

Compression Namespace in Apex: A Powerful New Salesforce Feature
Introduction Working with documents inside Salesforce has always challenged developers because of the platform’s multitenant constraints. Previously, packaging and sending files in a compact form required external services, like an AWS Lambda function, that retrieved files via API and then compressed them. With the introduction of the Compression Namespace and the powerful pre-defined Apex functions,… Continue reading Compression Namespace in Apex: A Powerful New Salesforce Feature
Compression Namespace in Apex: A Powerful New Salesforce Feature
Introduction Working with documents inside Salesforce has always challenged developers because of the platform’s multitenant constraints. Previously, packaging and sending files in a compact form required external services, like an AWS Lambda function, that retrieved files via API and then compressed them. With the introduction of the Compression Namespace and the powerful pre-defined Apex functions,… Continue reading Compression Namespace in Apex: A Powerful New Salesforce Feature

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
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

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
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