BassemE/mulesoft-documentation-embeddings huggingface dataset:
Transform XML to JSON | MuleSoft Documentation
# Transform XML to JSON
These simple DataWeave examples change the XML input to JSON output. Note that more complex transformations usually require the use of the `map` or `mapObject` function.
The following DataWeave script maps the names (or keys) for the output fields to values of the input fields. The input fields are specified with selector expressions without any functions. The script also changes the order and names of some of the fields.
DataWeave Script:
```
%dw 2.0
output application/json
---
{
    address1: payload.order.buyer.address,
    city: payload.order.buyer.city,
    country: payload.order.buyer.nationality,
    email: payload.order.buyer.email,
    name: payload.order.buyer.name,
    postalCode: payload.order.buyer.postCode,
    stateOrProvince: payload.order.buyer.state
}
```

Input XML Payload:
```
<?xml version='1.0' encoding='UTF-8'?>
<order>
 <product>
  <price>5</price>
  <model>MuleSoft Connect 2016</model>
 </product>
 <item_amount>3</item_amount>
 <payment>
  <payment-type>credit-card</payment-type>
  <currency>USD</currency>
  <installments>1</installments>
 </payment>
 <buyer>
  <email>mike@hotmail.com</email>
  <name>Michael</name>
  <address>Koala Boulevard 314</address>
  <city>San Diego</city>
  <state>CA</state>
  <postCode>1345</postCode>
  <nationality>USA</nationality>
 </buyer>
 <shop>main branch</shop>
 <salesperson>Mathew Chow</salesperson>
</order>
```

Output JSON:
```
{
 "address1": "Koala Boulevard 314",
 "city": "San Diego",
 "country": "USA",
 "email": "mike@hotmail.com",
 "name": "Michael",
 "postalCode": "1345",
 "stateOrProvince": "CA"
}
```

In the following example, the DataWeave script transforms the XML containing multiple XML nodes with the same key into a valid JSON creating an array instead of creating JSON nodes with the same key.
DataWeave Script:
```
%dw 2.0
output application/json duplicateKeyAsArray=true
---
payload
```

Input XML Payload:
```
<order>
 <product-lineitems>
	<product-lineitem>
	  <net-price>100.0</net-price>
	</product-lineitem>
	<product-lineitem>
	   <net-price>498.00</net-price>
	</product-lineitem>
 </product-lineitems>
</order>
```

Output JSON:
```
{
 "order": {
  "product-lineitems": {
   "product-lineitem": [
   {
    "net-price": "100.0"
   },
   {
    "net-price": "498.00"
   }
   ]
  }
 }
}
```

## Related Examples
  *   * Map Data with DataWeave
  * 

## See Also
  *   * DataWeave Selectors
  *
Azure Service Bus Connector 3.3 | MuleSoft Documentation
# Azure Service Bus Connector 3.3
Anypoint Connector for Azure Service Bus (Azure Service Bus Connector) makes it easy to build integrations that send messages to and receive messages from Azure Service Bus, which is an asynchronous messaging cloud platform. This connector supports communication with queues and topics and can perform actions such as:
  * Send to queue
  * Send to topic
  * Receive from queue
  * Receive from subscription


To use the Azure management API for CRUD operations of queues, topics, subscriptions, and rules, use Anypoint Connector for Azure Service Bus Management (Azure Service Bus Management Connector).
This connector supports integrations with Azure Service Bus (cloud). It does not work with Microsoft Service Bus (on-premises). To connect with Microsoft Service Bus on-premises, use Anypoint Connector for Microsoft Service Bus. This connector does not work with Event Hubs.  
---  
For compatibility information and fixed issues, see the release notes.
## Before You Begin
To use this connector, you must be familiar with:
  * The Azure Service Bus APIs
  * Anypoint connectors
  * Mule runtime engine (Mule)
  * Elements and global elements in a Mule flow
  * How to create a Mule app using Anypoint Studio


Before creating an app, you must have:
  * Access to the Azure target resource
  * OpenJDK 8
  * Anypoint Studio 7.1.0 or later
  * Mule Runtime 4.2.x EE or later


## Audience
  * New user
To create your Mule app, see:
  *   * Examples, which provides one or more use cases for the connector.
  * Advanced user
  * Read the following:
  * XML and Maven Support
  * Examples topics


## Authentication Types
Azure Service Bus Connector supports the following connection types to connect to Azure:
  * Shared Access Signature (SAS)
  * Azure Active Directory (AAD)


For information about configuring these authentication types, see Using Anypoint Studio to Configure Azure Service Bus Connector.
## Next Step
After you complete the prerequisites and experiment with templates and examples, you are ready to create an app and configure the connector using Anypoint Studio.
## See Also
  * Introduction to Anypoint Connectors
  * Use Exchange to Discover Connectors, Templates, and Examples
  * Azure Service Bus Connector Release Notes
  * Azure Service Bus Management Connector
  * Azure Service Bus Connector on Exchange
  * MuleSoft Help Center
isRangeType | MuleSoft Documentation
# isRangeType
## isRangeType(t: Type): Boolean
Returns `true` if the input is the Range type.
_Introduced in DataWeave version 2.3.0._
### Parameters
Name | Description  
---|---  
The type to check.  
### Example
This example shows how `isRangeType` behaves with different inputs.
#### Source
```
%dw 2.0
import * from dw::core::Types
type ARange = Range
output application/json
---
{
  a: isRangeType(ARange),
  b: isRangeType(Range),
  c: isRangeType(String),
}
```

#### Output
```
{
 "a": true,
 "b": true,
 "c": false
}
```
Microsoft Excel Online Connector 1.1 | MuleSoft Documentation
# Microsoft Excel Online Connector 1.1
Anypoint Connector for Microsoft Excel Online (Excel Online Connector) gives you access to the Excel platform. This connector exposes the most commonly used operations provided by the Microsoft Excel Online API.
For compatibility information and fixed issues, see the Microsoft Excel Online Connector Release Notes.
## Before You Begin
To use this connector, you must be familiar with:
  * The Microsoft Excel Online API
  * Anypoint Connectors
  * Mule runtime engine (Mule)
  * Elements and global elements in a Mule flow
  * Creating a Mule app using Anypoint Studio (Studio)


Before creating an app, you must have:
  * Credentials to access the Excel target resource
  * Anypoint Studio version 7.3.5 or later


## Common Use Cases for the Connector
Some possible uses for this connector include:
  * Sales
    * Organize your company’s sales in a spreadsheet to perform cost studies, inventory management, or production scheduling.
    * Create a chart of your company’s inventory and analyze that data to encourage your customers to buy certain items.
  * Data
    * Visualize and share data regarding your customers, subscriptions, orders, charges, refunds, and events.


## Authentication Type
Microsoft Excel Online Connector uses the OAuth 2.0 authentication type, which delegates user authentication to the service hosting the user account.
## Next Step
After you complete the prerequisites, you are ready to create your own app and configure the connector using Anypoint Studio.
## See Also
  * Introduction to Anypoint Connectors
  * Use Exchange to Discover Connectors, Templates, and Examples
  * MuleSoft Help Center
X12 EDI Connector 2.14 | MuleSoft Documentation
# X12 EDI Connector 2.14
Support Category: Premium
Anypoint Connector for X12 EDI (X12 EDI Connector) enables you to convert X12 messages to and from DataWeave-compatible representations by using lists and maps. All of the schema definitions you need for supported X12 standard transaction sets are included. For complete information about schemas, see X12 EDI Schema Language Reference.
Many Health Insurance Portability and Accountability Act (HIPAA) document versions are also supported, as listed separately in the Supported HIPAA Versions. For more information about HIPAA usage, refer to Connector HIPAA Standards.
## Prerequisites
To use this connector, you must be familiar with:
  * Anypoint Connectors
  * Mule runtime engine (Mule)
  * Elements and global elements in a Mule flow
  * Creating a Mule app using Anypoint Studio (Studio)


Before creating an app, you must have:
  * Purchased a MuleSoft license for X12 EDI Connector.
Contact your Account Representative about purchasing a license.
  * Anypoint Studio 7.0 or later


X12 EDI Connector supports files of up to 15 MB in size, and the memory requirement is approximately 40 to 1. For example, a 1 MB file requires up to 40 MB of memory to process, so it’s important to consider this memory requirement in conjunction with your Transactions Per Second (TPS) needs for large X12 files. This is not an exact figure; the value varies according to the complexity of the mapping instructions.   
---  
## Exchange Templates and Examples
Anypoint Exchange provides templates that you can use as starting points for your apps and examples that illustrate a complete solution.
### X12 EDI Connector Templates in Exchange
X12 EDI Connector templates provide starting points that help you:
  * Map application messages to outbound X12 transactions 
  * Map inbound X12 transactions to the application message format
  * Set up your Partner Manager content storage


### X12 EDI Connector Examples in Exchange
X12 EDI Connector examples in Exchange enable you to:
  * Customize an X12 EDI schema for B2B integrations
  * Transform outbound purchase order XML messages to X12 850 transactions
  * Transform inbound X12 850 transactions to JSON purchase orders
  * Transform outbound XML messages into X12 purchase orders, inbound X12 purchase orders into JSON, and generate a functional acknowledgement
  * Implement an end-to-end order to cash workflow from the perspective of a seller
  * Implement an end-to-end B2B procure to pay workflow from the perspective of a buyer


## Next Step
After you complete the prerequisites, you are ready to create your own app and configure the connector using Anypoint Studio.
## See Also
Introduction to Anypoint Connectors
Use Exchange to Discover Connectors, Templates, and Examples
MuleSoft Help Center
Securing Flex Gateway APIs with Policies | MuleSoft Documentation
# Securing Flex Gateway APIs with Policies
Policies enforce rules when Flex Gateway processes requests, enabling you to secure and govern your Flex Gateway APIs.
MuleSoft provides policies that you can apply to your APIs via Anypoint Platform or declarative configuration files. The provided policies include rate limiting, caching, authentication, authorization, threat protection, monitoring, and logging. For more information about MuleSoft-provided policies, see the Inbound Policies Directory and Outbound Policies Directory.
To extend existing functionality or define new functionality, create custom policies based on your specific business requirements and apply them to APIs. For information about creating custom policies, see Flex Gateway Policy Development Kit (PDK) Overview.
Automated policies enable your API instance to comply with common security and logging requirements by automatically applying the same set of policies to all APIs running in Flex Gateway. See Automated Policies for more information.
To apply a policy for Managed Flex Gateway or Connected Mode, see Applying Policies for Managed Flex Gateways and Connected Mode.
To apply a policy in Local Mode, see Applying Policies in Local Mode.
For information about policy reordering, see Ordering Policies.
For information about DataWeave support, see DataWeave Support in Flex Gateway Policies.
## See Also
  * Flex Gateway Overview
  * Getting Started with Flex Gateway
Configuring Kubernetes for Runtime Fabric | MuleSoft Documentation
# Configuring Kubernetes for Runtime Fabric
To configure Kubernetes for Anypoint Runtime Fabric, review the following topics:
  * Kubernetes (K8s) Best Practices for Runtime Fabric Review scalability benchmarks and cluster configurations best practices.
  * Kubernetes Hardening Guide Review security opportunities associated with setting up and securing a Kubernetes cluster based on the Kubernetes Hardening Guide.
  * Customizing Mule Apps Kubernetes Resources Customize your Mule app Kubernetes resources through the custom resource `kubernetestemplates.rtf.mulesoft.com` template.
  * Runtime Fabric Kubernetes Permissions Configure Kubernetes permissions for Runtime Fabric.


## See Also
  * Hardening Runtime Fabric
HL7 MLLP Connector 2.2 | MuleSoft Documentation
# HL7 MLLP Connector 2.2
Anypoint Connector HL7 Minimal Lower-Layer Protocol (MLLP) Connector (HL7 MLLP Connector) provides connectivity and parsing functionality for HL7 MLLP messages.
For compatibility information and fixed issues, see the HL7 MLLP Connector Release Notes.
## Before You Begin
To use this connector, you must be familiar with:
  * Anypoint Connectors
  * Mule runtime engine (Mule)
  * Elements and global elements in a Mule flow
  * Creating a Mule app using Anypoint Studio (Studio)
  * HL7 MLLP Connector


To use HL7 MLLP Connector, you must have:
  * Purchased a MuleSoft license for HL7. Contact your Account Representative about purchasing a license.
  * Anypoint Studio 7.0 or later
  * Java 8


## See Also
  * HL7 MLLP Connector Release Notes
  * HL7 MLLP Connector in Anypoint Exchange
collapse | MuleSoft Documentation
# collapse
## collapse(text: String): Array<String>
Collapses the string into substrings of equal characters.
Each substring contains a single character or identical characters that are adjacent to one another in the input string. Empty spaces are treated as characters.
_Introduced in DataWeave version 2.4.0._
### Parameters
Name | Description  
---|---  
The string to collapse.  
### Example
This example shows how the function collapses characters. Notice that the empty space (" ") is treated as a character.
#### Source
```
%dw 2.0
import collapse from dw::core::Strings
output application/json
---
collapse("a b babb a")
```

#### Output
```
["a", " ", "b", " ", "b", "a", "bb", " ", "a"]
```

## collapse(text: Null): Null
Helper function that enables `collapse` to work with a `null` value.
_Introduced in DataWeave version 2.4.0._
Troubleshooting the Scripting Module | MuleSoft Documentation
# Troubleshooting the Scripting Module
To troubleshoot the Scripting Module, become familiar with the information about enabling verbose logging and interpreting commonly thrown messages.
## Enable Verbose Logging
To get a better understanding of why an application’s interaction with the Scripting module is failing, temporarily enable verbose logging for the module.
Remember to always disable the enhanced verbosity after troubleshooting, because it affects your Mule application performance.
To enable verbose logging in the configuration file:
  1. Access Anypoint Studio and navigate to the **Package Explorer** view.
  2. Open your application’s project name.
  3. Open the `src/main/resources` path folder.
  4. Open the `log4j2.xml` file inside the folder.
  5. Add an `<AsyncLogger>` tag inside the `<Loggers>` tag:
```
			<Loggers>
				...
				<AsyncLogger name="org.mule.plugin.scripting" level="DEBUG"/>
				...
			</Loggers>
```

  6. Save your application changes.
  7. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**.


## Troubleshoot External Libraries for the Scripting Engine
When upgrading the Scripting module version 2.0.1 to 2.0.2, you can receive a `SCRIPTING:UNKNOWN_ENGINE` throw message at runtime if you did not specify a scripting language engine external library. To avoid receiving such a throw message, you must specify a compliant `jsr-223` scripting language engine.
For instructions on how to configure the scripting language engine, refer to Add the Execute Operation to the Flow.
## Understand Common Throws
Here is a list of common throw messages and how to interpret them:
  * SCRIPTING:COMPILATION
```
The content of the property code had problems in the compilation stage. Check that your code is valid and export the classes used with the Scripting module.
```

  * SCRIPTING:UNKNOWN_ENGINE
```
The engine name provided in the engine parameter is unknown.
```

  * SCRIPTING:EXECUTION
```
An exception occurred during the execution stage. Set the log level in DEBUG mode and find more information in the log file.
```



## See Also
  * Scripting Module Reference
  * MuleSoft Help Center
  *
Amazon SNS Connector 4.6 - Get Started | MuleSoft Documentation
# Amazon SNS Connector 4.6 - Get Started
Anypoint Connector for Amazon SNS (Amazon SNS Connector) provides connectivity to the Amazon Simple Notification Service (Amazon SNS) API, enabling you to build distributed web-enabled applications. Mule apps can use Amazon SNS Connector to easily push real-time notification messages to interested subscribers over multiple delivery protocols.
Release Notes: Amazon SNS Connector Release Notes Exchange: Amazon SNS Connector in Anypoint Exchange
This connector does not support the use of FIFO queues. It allows publishing only to standard queues.   
---  
## About Connectors
Anypoint Connectors are Mule runtime engine extensions that enable you to connect to APIs and resources on external systems, such as Salesforce, Amazon SNS, ServiceNow, and Twitter.
## Before You Begin
Before creating an app, you must:
  * Have access to the Amazon SNS target resource and Anypoint Platform.
  * Understand how to create a Mule app using Anypoint Studio.
  * Have AWS Identity and Access Management (IAM) credentials.


### Compatibility
Amazon SNS connector is compatible with:
Application/Service | Version  
---|---  
Mule Runtime  
AWS SDK for Java  
Anypoint Studio |  7.0 or higher  
## Audience
  * Starting user
To create your Mule app, see Studio Configuration. See Additional Configuration Information to see what permissions AWS Identity and Access Management (IAM) users must have to use Amazon SNS Connector.
The Examples topic provides one or more use cases for using this connector.
  * Power user
Read the XML and Maven Support, Additional Configuration Information, and Examples topics.


## Next Step
After you have met the prerequisites, you are ready to create an app with Anypoint Studio.
## See Also
  * Introduction to Anypoint Connectors
  * Use Exchange to Discover Connectors, Templates, and Examples
  * MuleSoft Help Center
Create Folder | MuleSoft Documentation
# Create Folder
Use this action step to create an empty folder in the specified directory path.
## Properties
  * **Common**
See Common Properties for a description.
  * **Folder Operations Settings**
    * **Directory Path**
Path to the directory where to create the folder.
    * **Force error if folder exists**
Causes the workflow to enter an error state and stop its execution if the folder exists.


## Inbound Variables
  * **Force error if folder exists**
  * **Directory Path**


## Outbound Variables
  * **Directory Path**
  * **IsCreated**


## See Also
  *
Getting Started with Managing an API | MuleSoft Documentation
# Getting Started with Managing an API
You can use API Manager to apply policies and to add contracts, alerts, and SLA tiers to your API instance. Additionally, you can configure a runtime for your API that runs in CloudHub or CloudHub 2.0. Although you can also deploy your API runtime using Mule runtime engine (Mule) and Hybrid, deploying your API proxy directly to CloudHub is the fastest and easiest.
If you are running an API with a standalone server, use the classic API creation flows to manage your API.   
---  
You can manage your API using the following steps:
  1. Create an API asset in Exchange
You can create an REST, HTTP, or SOAP API asset in Exchange and manage it as an API instance in API Manager.
  2. Add an API Instance in API Manager
An API instance is a proxy of an API that serves the upstream. API instances support the application of policies and can be deployed to an API gateway.
  3. Apply a Policy in API Manager
A policy extends the functionality of an API and enforces certain capabilities such as security. A policy can control access and traffic. For example, a policy can generally control authentication, access, allotted consumption, and service level access (SLA).


## See Also
  * Learn about SLA Tiers
  * Learn about granting access to an API
  * More on API proxies
Configuring Image Generation Operations | MuleSoft Documentation
# Configuring Image Generation Operations
## Configure the Image Read Operation
The **Image read** operation reads and interprets an image based on a prompt. Currently, MuleSoft AI Chain Connector supports only OpenAI Image Models.
To configure the **Image read** operation:
  1. Select the operation on the Anypoint Code Builder or Studio canvas.
  2. In the **General** properties tab for the operation, enter these values:
     * **Data**
Contains the prompt for the operation.
     * **ContextUrl**
Contains the URL to the image file to read.


This is the XML configuration for this operation:
```
<ms-aichain:image-read
 doc:name="Image read"
 doc:id="16cac2ce-def9-41e2-aaff-0f9c33d622f1"
 config-ref="MuleSoft_AI_Chain_Config"
 contextURL="#[payload.imageUrl]">
 <ms-aichain:data><![CDATA[#[payload.prompt]]]></ms-aichain:data>
</ms-aichain:image-read>
```

### Output Configuration
This operation responds with a JSON payload containing the main LLM response. Additionally, attributes such as token usage are included as part of the metadata (attributes), but not within the main payload.
This is an example response of the JSON payload:
```
{
 "response": "The image depicts a group of men in what appears to be a stadium or arena setting. They are standing in the stands, with some looking agitated or engaged in a discussion."
}
```

Along with the JSON payload, the operation also returns attributes, which include information about token usage, for example:
```
{
 "attributes": {
   "tokenUsage": {
     "outputCount": 87,
     "totalCount": 187,
     "inputCount": 100
   },
   "additionalAttributes": {}
 }
}
```

## Configure the Image Generate Operation
The **Image generate** operation generates an image based on a prompt sent to the LLM. Currently, MuleSoft AI Chain Connector supports only OpenAI Image Models.
To configure the **Image generate** operation:
  1. Select the operation on the Studio canvas.
  2. In the **General** properties section, configure the **Data** field with the prompt for generating the image, for example, `payload.prompt`.


This is the XML configuration for this operation:
```
<ms-aichain:image-generate
 doc:name="Image generate"
 doc:id="a057ad09-533f-42e9-bfd6-00014db6cec8"
 config-ref="MuleSoft_AI_Chain_Config">
 <ms-aichain:data><![CDATA[#[payload.prompt]]]></ms-aichain:data>
</ms-aichain:image-generate>
```

### Output Configuration
This operation responds with a JSON payload containing the URL of the generated image, for example:
```
{
 "response": "https://oaidalleapiprodscus.blob.core.windows.net/private/org-dP8odnP25FlwTi1fOMr1X7vO/user-Jyi0vNlYu4mjEBZl9Mu1lXBW/img-bEO12CWIRI7CkGUjfz5ajAlS.png"
}
```

## See Also
  * Using Anypoint Code Builder to Configure a Connector
  * Using Studio to Configure a Connector
  * MuleSoft AI Chain Connector Overview
  * MuleSoft AI Chain Connector Reference
  * MuleSoft Help Center
Configuring CloudHub 1.0 Deployment Settings | MuleSoft Documentation
# Configuring CloudHub 1.0 Deployment Settings
To configure settings for deploying Anypoint Partner Manager to CloudHub 1.0, access the business unit and environment for which you want to deploy Partner Manager and then follow these steps:
  1. From the access management **Configure a Partner Manager environment** window, enter the following general settings:
Setting | Description | Default  
---|---|---  
Deployment Target Type | Target type for your Partner Manager deployment. Select **CloudHub 1.0**. | CloudHub 1.0  
Runtime Version | Mule runtime engine version to run Partner Manager applications.  
Min Mule Version override | Minimum Mule runtime version required to deploy the runtime applications. Configuring the Min Mule version enables you to apply a feature flagging mechanism for Partner Manager-deployed Mule runtime applications. If you process cXML messages with <DOCTYPE> tags, you must set the `minMuleVersion` to 4.5.0 or higher. If you’re migrating from an earlier version, you must perform end-to-end regression testing on your existing workflows before changing the `minMuleVersion`. |  |  If you select `None`, Partner Manager defaults to using `4.3.0` as the Min Mule version.   
---  
CloudHub Region | Region in CloudHub to which you want to deploy Partner Manager runtime applications. You can’t change the region if active message flows are deployed to the existing region. To change the region in this case, you must undeploy the message flows. You can redeploy the message flows after you change the region. | Retrieved from the business group’s Runtime Manager setting  
Anypoint MQ Region | This value is automatically assigned based on the specified CloudHub region and you can’t change it.  
Automatically restart app when not responding | Directs CloudHub to automatically restart your application when the monitoring system discovers an issue. | Selected  
  2. Select **Applications** and enter the following application settings:
Setting | Description | Default  
---|---|---  
Each B2B endpoint | Reserved CPU space, CPU space limit, and memory capacity for each Partner Manager endpoint. Partner Manager deploys a generic Mule app to the runtime for each endpoint protocol and direction (receive or send) combination.  
B2B API Replication Service | Reserved CPU space, CPU space limit, and memory capacity for the B2B API Replication Service. | 0.2 vCores  
B2B Document Processing Service | Reserved CPU space, CPU space limit, and memory capacity for the B2B Document Processing Service. | 0.2 vCores  
Deploy HTTP/AS2 apps to private port | Directs CloudHub to automatically deploy newly created AS2, HTTP, and HTTPS endpoints to a private port. | Selected  
For help with sizing, contact your MuleSoft Account Team.
  3. Click **Save**.


## See Also
Deploying Partner Manager Runtime Apps
Migrating the Scripting Component | MuleSoft Documentation
# Migrating the Scripting Component
The `<scripting>` component in Mule 3 is replaced with a new `<scripting>` module. This new module is pretty similar in functionality, with just some syntax changes:
Mule 3 Example: Scripting
```
 <flow name="greedy">
  <choice>
    <when expression="#[flowVars['currency'] == 'USD']">
      <scripting:component>
        <scripting:script file="greedy.groovy">
          <property key="currency" value="USD"/>
        </scripting:script>
      </scripting:component>
      </when>
    <when expression="#[flowVars['currency'] == 'GBP']">
      <scripting:component>
        <scripting:script file="greedy.py">
          <property key="currency" value="GBP"/>
        </scripting:script>
      </scripting:component>
      </when>
  </choice>
</flow>
```

Mule 4 Example: Scripting
```
 <flow name="greedy">
  <scripting:execute engine="groovy">
    <scripting:code>${file::greedy.groovy}</scripting:code>
    <scripting:parameters>
      #[{currency: vars.currency}]
    </scripting:parameters>
  </scripting:execute>
</flow>
```

As you can see, the main difference here is that now you can use DataWeave to generate the input parameters.
## Accessing Variables from the Script
The previous example uses a variable to show how to pass parameters into the script, it’s best to keep the script decoupled from the rest of the flow, so that changes to the Mule applications don’t require changes to the script.
However, you can still access the variables from the script using the `vars` keyword. For example:
Mule 4 Example: Accessing variables directly
```
<flow name="greedy">
  <scripting:execute engine="groovy">
    <scripting:code>return "currency is " + vars.currency</scripting:code>
  </scripting:execute>
</flow>
```

To use the Scripting Module, simply add it to your application using the Studio palette or add the following dependency in your `pom.xml` file:
```
<dependency>
 <groupId>org.mule.modules</groupId>
 <artifactId>mule-scripting-module</artifactId>
 <version>1.1.0</version> <!-- or newer -->
 <classifier>mule-plugin</classifier>
</dependency>
```

## See Also
  * Scripting Module Documentation
Deploy MQTT Connector Apps in a Cluster | MuleSoft Documentation
# Deploy MQTT Connector Apps in a Cluster
MQTT broker establishes a connection with a client using its client ID. For example, if the broker establishes a connection with a client whose client ID is `smart-bentley-123`, and then the broker receives a new connection with the same client ID, the broker closes the previous connection (assuming it is stale) and accepts the new connection. This mechanism is known as a client takeover. MQTT brokers employ this mechanism to prevent situations such as TCP connections reaching a half-open or invalid state due to a crash in one of the communication ends, which is undesirable.
Because of client takeover, Mule runtime engine (Mule) applications that use MQTT Connector deployed in a cluster must include a unique client ID for each active node in the cluster. To avoid client takeovers in this kind of scenario, you can supply these unique IDs either by using the application-provided client ID generators or by providing your own client ID generator.
## See Also
  * Set a Client ID with MQTT Connector
  * MQTT Connector Examples
  * MuleSoft Help Center
Troubleshooting FTP Connector | MuleSoft Documentation
# Troubleshooting FTP Connector
To troubleshoot Anypoint Connector for FTP (FTP Connector), become familiar with the information about troubleshooting Mule application issues.
## Troubleshoot Mule Application Issues
Sometimes you are not sure why the application is failing and you require a better understanding of what is going on in the app’s interaction with the FTP server.
To resolve this error:
  * Use the configuration file to increase the logging level on the server side.
  * Try to replicate the issue using an FTP client, for example, Cyberduck or Filezilla. If the issue also occurs with these clients, then it is likely that the issue is not related to the Mule app.
  * Get better and more detailed logs on the Mule app side by enabling verbose logging for FTP Connector and for the JSCH driver:
    1. Access Anypoint Studio and navigate to the **Package Explorer** view.
    2. Open your application’s project name.
    3. Open the `src/main/resources` path folder.
    4. Open the `log4j2.xml` file inside the folder.
    5. If the following line is already in the `log4j2.xml` file, uncomment it to enable it; otherwise, add it:
```
  <AsyncLogger name="org.mule.extension.ftp" level="TRACE"/>
  <AsyncLogger name="org.apache.commons.net" level="DEBUG"/>
```

    6. Add the following argument to your run configuration:
```
`-M-Djavax.net.debug=ssl,handshake`
```

  * Try to minimize or remove unnecessary DataWeave data transformations (you could even use hard-coded data) to minimize the app’s complexity and determine whether the issue is with the interaction between the app and the FTP server.


For additional information about enabling verbose logging for SDK components in your Mule application, see the troubleshoot SDK components documentation.
## Understand Common Throws
Here is a list of common throw messages and how to interpret them.
  * FTP:ACCESS_DENIED


An FTP Connector operation attempted to access an FTP server path and performed an action for which the user does not have permission.
  * FTP:CONNECTIVITY


The connection to the FTP server was interrupted.
  * FTP:FILE_ALREADY_EXISTS


An attempt was made to create a file with the same location and name as an existing file.
  * FTP:FILE_LOCK


An attempt to lock a file was unsuccessful.
  * FTP:ILLEGAL_CONTENT


The **Write** operation received invalid content to write.
  * FTP:ILLEGAL_PATH


The specified path is invalid because, for example, it does not exist.
  * FTP:RETRY_EXHAUSTED


Retries of an execution block are exhausted.
## See Also
  * FTP Connector Reference
  * MuleSoft Help Center
  *
Multipart Types (dw::module::Multipart) | MuleSoft Documentation
# Multipart Types (dw::module::Multipart)
Type | Definition | Description  
---|---|---  
Multipart |  `type Multipart = { preamble?: String, parts: { _?: MultipartPart } }` |  `MultiPart` type, a data structure for a complete `Multipart` format. See the output example for the Multipart `form` function documentation.  
MultipartPart |  `type MultipartPart = { headers?: { "Content-Disposition"?: { name: String, filename?: String }, "Content-Type"?: String }, content: Any }` |  `MultipartPart` type, a data structure for a part within a `MultiPart` format. See the output examples for the Multipart `field` function documentation.
floor | MuleSoft Documentation
# floor
## floor(number: Number): Number
Rounds a number down to the nearest whole number.
### Parameters
Name | Description  
---|---  
The number to evaluate.  
### Example
This example rounds numbers down to the nearest whole numbers. Notice that `1.5` rounds down to `1`.
#### Source
```
%dw 2.0
output application/json
---
[ floor(1.5), floor(2.2), floor(3) ]
```

#### Output
Troubleshoot Agentforce for Anypoint Code Builder | MuleSoft Documentation
# Troubleshoot Agentforce for Anypoint Code Builder
The following errors sometimes occur when you use Agentforce for Anypoint Code Builder.
## Unexpected Query Results When Using the Agentforce Generative Flow Feature
If the generative flow doesn’t return accurate and useful results for the messages you enter, rewrite your message and follow the guidelines to craft an effective message.
## Troubleshoot Agentforce Access Errors
If you can’t access Agentforce, contact your Anypoint Platform organization administrator. If you’re the organization administrator, check these considerations:
  * You accepted the terms and conditions and enabled Einstein for Anypoint Code Builder for your organization.
  * The Salesforce organization you are connected to for Agentforce requests has Generative AI enabled. For more information, see Set Up Einstein Generative AI.
  * The Salesforce organization you are connected to for Agentforce requests has an established a tenant relationship with your Anypoint Platform organization, and the connection is enabled.
  * The Salesforce organization you are connected to for Agentforce requests is valid. For example, verify that it’s not expired or otherwise disabled.


## Troubleshoot Anypoint Platform Authorization Errors
If you receive an authorization error, contact your Anypoint Platform organization administrator. If you are the organization administrator, check the following:
  * The user has the **Mule Developer Generative AI User** permission assigned in Anypoint Platform access management.
  * You accepted the terms and conditions to enable Einstein for your organization.
  * Your Anypoint Platform organization is current and active.


## Agentforce Doesn’t Appear for EU Cloud Users on the Desktop IDE
If you are signed in to your Anypoint Platform account on the EU Cloud and Agentforce doesn’t appear in the UI, verify the following:
  * You completed the Set the Desktop IDE to the EU or US Cloud procedure.
  * You are signed in to Anypoint Platform through the Anypoint Code Builder app.
  * You have the required permissions.


## See Also
  * Trusted Salesforce Organizations
  * Enabling or Disabling Einstein for Anypoint Platform
  * Log in to Anypoint Platform from the IDE
  * Anypoint Code Builder Permissions
Control | MuleSoft Documentation
# Control
Control action steps enable you to interact with the system where the automation is running by sending certain instructions and input signals.
  * This action step tries to clear any open window from the screen.
  * This action step emulates keyboard inputs and accepts text transferred from a previously executed action step.
  * This action step emulates keyboard inputs.
  * The Mouse Actions action step emulates mouse moves and clicks.
  * This action step is used to run a program by directly calling its executable file.
  * This action step causes the Workflow to be paused for the specified duration.
  * This action step allows you to change the state of a specific window.
Lifecycle of a Message Source | MuleSoft Documentation
# Lifecycle of a Message Source
Unlike operations, where the lifecycle is tied to the owning Flow, sources can be started or stopped separately through Runtime Manager.
To support that, the `Source` class forces you to implement the `onStart()` and `onStop()` methods.
## On Start
This example from the VM connector shows the `onStart()` method:
```
@Override
public void onStart(SourceCallback<Serializable, VMMessageAttributes> sourceCallback) throws MuleException {
}
```

In this method, you have to initialize all the resources (such as threads, schedulers, connections, and so on) that you need so that you can produce messages. If an exception or error condition is found trying to do that, then you have to:
  * Release any resources you did got to allocate.
  * Throw an exception with a meaningful message.


If the source fails to start, the app that contains it will fail to start.
All of the source parameters values that defined through the `@Parameter` annotation are resolved and available at this point.   
---  
### SourceCallback
The method receives a SourceCallback object. The `SourceCallback` is arguably the most important piece of the Source, since it is involved in pretty much every aspect of the source’s functionality. We will elaborate on the uses and responsibilities of the `SourceCallback` as this documentation progresses, but in a nutshell, the `SourceCallback` is what the source uses to communicate with the runtime. It is used for:
  * Pushing messages into the Flow
  * Communicating connection issues and triggering reconnection
  * Passing state between the push phase of the Source into the response handling part


Because the `SourceCallback` plays such an important role, it is very important that the provided instance is always available. Depending on how your source’s complexity and code organization, you may accomplish this by simply holding it as a method argument. More complex sources might need to keep a reference to it through an instance field. If you decide to do this, then you need to make sure that the reference is cleared when the `onStop()` method is executed
## On Stop
This method will be invoked by the runtime to make the source stop producing messages. **This method should not fail**. Any exceptions found during the stop process should be logged and correctly handled by the source, but after invoking this method the source must:
  * Stop producing messages
  * Free any allocated resources
  * Be capable of being restarted


## Next step
  * Obtain configuration and connections from a Message source
to | MuleSoft Documentation
# to
## to(from: Number, to: Number): Range
Returns a range with the specified boundaries.
The upper boundary is inclusive.
### Parameters
Name | Description  
---|---  
`Number` value that starts the range. The output includes the `from` value.  
`Number` value that ends the range. The output includes the `from` value.  
### Example
This example lists a range of numbers from 1 to 10.
#### Source
```
%dw 2.0
output application/json
---
{ "myRange": 1 to 10 }
```

#### Output
```
{ "myRange": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] }
```

### Example
DataWeave treats a string as an array of characters. This example applies `to` to a string.
#### Source
```
%dw 2.0
var myVar = "Hello World!"
output application/json
---
{
 indices2to6 : myVar[2 to 6],
 indicesFromEnd : myVar[6 to -1],
 reversal : myVar[11 to -0]
}
```

#### Output
```
{
 "indices2to6": "llo W",
 "indicesFromEnd": "World!",
 "reversal": "!dlroW olleH"
}
```
Limits in API Manager | MuleSoft Documentation
# Limits in API Manager
## API Group Limits
API Manager limits the number of features allowed for each business group.
Limit | Value | Notes  
---|---|---  
API Groups per business group  
API Group Versions per business group  
API Group Instances per business group  
## Upstream Service Limits
API Manager limits the number of upstream services you can expose through a single consumer endpoint.
Limit | Value | Notes  
---|---|---  
Upstreams per API  
Routes per API  
Upstreams per route  
## API Alert Limits
Feature | Gold | Platinum | Titanium | Integration Starter | Intergration Advanced  
---|---|---|---|---|---  
Documented in Runtime Manager | Documented in Runtime Manager | You receive additional storage that is 10% of the size of purchased storage for indexes for searchable logs. Occupies space per subscription. | Documented in Runtime Manager | Your logs can occupy as much space as you receive with your pricing package.  
**Searchable Logs** | Not available | Not available | You receive additional storage that is 10% of the size of purchased storage for indexes for searchable logs. | Not available | You receive additional storage that is 10% of the size of purchased storage for indexes for searchable logs.  
**Application Metrics Retention** | 365 days | 365 days  
**Enhanced API Metrics Retention** | 30 days. The limit for data in the **Client Applications** tab is 1 hour. | 30 days. The limit for data in the **Client Applications** tab is 1 hour. | 30 days. Data in the **Client Applications** tab is limited to 1 hour. Data from `api_path_metric` and `api_client_ip_metric` tables in advanced mode of custom dashboards is limited to 1 hour. | 30 days. The limit for data in the **Client Applications** tab is 1 hour. | 30 days. Data in the **Client Applications** tab is limited to 1 hour. Data from `api_path_metric` and `api_client_ip_metric` tables in advanced mode of custom dashboards is limited to 1 hour.  
**Custom Metrics Retention** | Not available | Not available | 365 days in production environments | Not available | 365 days in production environments  
**Basic Alerts for Servers and Mule apps** | 50 alerts | 50 alerts | 50 times the number of production vCores in your organization plus 100 | 6 alerts per server or app | 10 alerts per server or app  
**Basic alerts for APIs** | 6 alerts per API instance | 6 alerts per API instance | 10 alerts per API instance | 6 alerts per API instance | 10 alerts per API instance  
**Advanced Alerts** | Not available | Not available | 20 alerts per parent organization | Not available | 10 alerts per app or API instance  
**Telemetry Exporter Connections** | Not available | Not available | 10 connections per organization | Not available | 10 connections per organization  
**Log Truncation** | Maximum of 8 KB per line | Maximum of 8 KB per line | Maximum of 8 KB per line | Maximum of 8 KB per line | Maximum of 8 KB per line  
Use a minimum screen resolution of 1024 by 768 pixels.   
---
Preparation Checklist for Composer | MuleSoft Documentation
# Preparation Checklist for Composer
Before you build a flow, assemble the information you need:
  * The username, password, and the URL where you send these credentials for every data source or data target. This user must have access to the data you plan to work with.
  * The trigger for your flow: an event like "a Google Sheet row is updated when I add a new Salesforce contact," or a time period like "every fifteen minutes."
  * An ordered list of all the steps and all the logic required to move and transform your data:
    * Which records, rows, or other data do you need to access?
    * What are you trying to do? For example:
      * Pull changes and copy them
      * Transform the structure or type of the data
      * Add information from one source to information in another
    * Will you filter out some records based on criteria such as "owned by," or "updated after"?


Of course, if you aren’t certain of some of this information, you can still use Composer. Flows, the main building block of process automation, don’t start working until you activate them. You can change them as you create them, so feel free to experiment.
## See Also
  * Mulesoft Composer: Overview
  * MuleSoft Composer: Getting Started
  * Composer Connector Reference
  * Knowledge Articles
Web Service Consumer Connector | MuleSoft Documentation
# Web Service Consumer Connector
Web Service Consumer Connector Version 1.5
Anypoint Connector for Web Service Consumer (Web Service Consumer Connector) consumes a SOAP Web service to acquire data from an external source. In many cases, you can use an existing MuleSoft connector, such as Workday or ServiceNow, to connect to a service provider. When no connector is available for a specific Web service, the easiest way to consume the service from a Mule app is to use the Web Service Consumer Connector.
The main features of this connector include:
  * Consuming DOC Literal Web services.
  * SOAP multipart messages.
  * SOAP Headers.
  * DataSense support for SOAP Headers, SOAP Body, and Attachment.
  * Embedded DataWeave transformations inside the operation.
  * Support and Unified experience for SOAP with attachments and MTOM handling.
  * Custom HTTP configuration as transport (runtime and design time).
  * Web Service Security (WS Security) support.


RPC WSDLs are not supported by the Web Service Consumer.   
---  
Release Notes: Web Service Consumer Release Notes Exchange: Web Service Consumer Connector
## POM File Information
```
<dependency>
 <groupId>org.mule.connectors</groupId>
 <artifactId>mule-wsc-connector</artifactId>
 <version>x.x.x</version>
 <classifier>mule-plugin</classifier>
</dependency>
```

Replace `x.x.x` with the version that corresponds to the connector you are using. To specify a version, view Anypoint Exchange and click **Dependency Snippets**.
## See Also
  * Web Service Consumer Technical Reference
  *   *
Execute DDL Statements Example | MuleSoft Documentation
# Execute DDL Statements Example
Anypoint Connector for Database (Database Connector) **Execute DDL** operation enables to execute DDL queries against a database. Data Definition Language (DDL) statements, are special types of SQL statements that do not directly access or modify data. Instead, they create, modify, or destroy data structures, stored procedures, and so on. You can also use DDL statements to create or modify data within tables or other data structures.
## Configure the Execute DDL Operation in Studio
The following example shows how to configure the **Execute DDL** operation that creates a new table named `electronic` with columns named `id`, `name`, `description`, `price`, and `discount`:
  1. In the **Mule Palette** view, search for `database` and select the **Execute DDL** operation.
  2. Drag the **Execute DDL** operation onto the Studio canvas. The operation creates a table and returns `0` unless there is an error.
  3. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields.
  4. Specify the database connection information and click **OK**.
  5. Set the **SQL Query Text** field to the SQL query to execute, for example:


```
CREATE TABLE electronic(
  id INT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(100),
  description VARCHAR(255),
  price SMALLINT,
  discount TINYINT
```

The following screenshot shows the configuration in Studio:
Figure 1. Execute DDL configuration
In the XML editor, the `<db:execute-ddl>` configuration looks like this:
```
<db:execute-ddl config-ref="dbConfig">
  <db:sql>
    CREATE TABLE electronic(
      id INT AUTO_INCREMENT PRIMARY KEY,
      name VARCHAR(100),
      description VARCHAR(255),
      price SMALLINT,
      discount TINYINT
    )
  </db:sql>
</db:execute-ddl>
```

## See Also
  * Database Connector Examples
  * MuleSoft Help Center