BassemE/mulesoft-documentation-embeddings huggingface dataset:
Create a Directory Using FTP Connector Example | MuleSoft Documentation
# Create a Directory Using FTP Connector Example
Anypoint Connector for FTP (FTP Connector) provides a **Create directory** operation that enables you to create a directory of a given name.
If the reason for creating the directory is to immediately write, copy, or move content to the directory, then use the **Write** , **Copy** , or **Move** operations with the **Create parent directories** field set to **TRUE**.
## Configure the Create Directory Operation in Studio
To add and configure the **Create directory** operation in Studio, follow these steps:
  1. In the **Mule Palette** view, search for `ftp` and select the **Create directory** operation.
  2. Drag the **Create directory** operation onto the Studio canvas.
  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 connection information and click **OK**.
  5. Set **Directory path** to the new directory’s path name, for example, `~/newFolder`.


In the **Configuration XML** editor, the `<ftp:create-directory>` configuration looks like this:
```
<ftp:create-directory doc:name="Create directory" config-ref="FTP_Config" directoryPath="~/newFolder"/>
```

## See Also
  * FTP Connector Examples
  * MuleSoft Help Center
attr | MuleSoft Documentation
# attr
## attr(namespace: Namespace | Null = null, name: String): PathElement
This function creates a `PathElement` to use for selecting an XML attribute and populates the type’s `selector` field with the given string.
Some versions of the `update` and `mask` functions accept a `PathElement` as an argument.
_Introduced in DataWeave version 2.2.2._
### Parameters
Name | Description  
---|---  
`namespace` | The namespace of the attribute to select. If not specified, a null value is set.  
The string that names the attribute to select.  
### Example
This example creates an attribute selector for a specified namespace (`ns0`) and sets the selector’s value to `"myAttr"`. In the output, also note that the value of the `"kind"` key is `"Attribute"`.
#### Source
```
%dw 2.0
output application/json
import * from dw::util::Values
ns ns0 http://acme.com/fo
---
attr(ns0 , "myAttr")
```

#### Output
```
{
  "kind": "Attribute",
  "namespace": "http://acme.com/foo",
  "selector": "myAttr"
 }
```
toBinary | MuleSoft Documentation
# toBinary
## toBinary(str: String, encoding: String): Binary
Transform a `String` value into a `Binary` value using the specified encoding.
_Introduced in DataWeave version 2.4.0._
### Parameters
Name | Description  
---|---  
The `String` value to transform into a `Binary` value.  
The encoding to apply to the `String` value. Accepts encodings that are supported by your JDK. For example, `encoding` accepts Java canonical names and aliases for the basic and extended encoding sets in Oracle JDK 8 and JDK 11.  
### Example
This example shows how `toBinary` behaves with different inputs. It produces output in the `application/dw` format.
#### Source
```
%dw 2.0
import * from dw::util::Coercions
output application/dw
---
{
 'UTF-16Ex': toBinary("DW", "UTF-16"),
 'utf16Ex': toBinary("DW", "utf16"),
 'UnicodeBigEx': toBinary("DW", "UnicodeBig"),
 'UTF-32Ex': toBinary("DW", "UTF-32"),
 'UTF_32Ex': toBinary("DW", "UTF_32")
}
```

#### Output
```
{
 "UTF-16Ex": "/v8ARABX" as Binary {base: "64"},
 utf16Ex: "/v8ARABX" as Binary {base: "64"},
 UnicodeBigEx: "/v8ARABX" as Binary {base: "64"},
 "UTF-32Ex": "AAAARAAAAFc=" as Binary {base: "64"},
 UTF_32Ex: "AAAARAAAAFc=" as Binary {base: "64"}
}
```
Configure Security Parameters of SSH Connection | MuleSoft Documentation
# Configure Security Parameters of SSH Connection
The following example shows how to configure the Anypoint Connector for SFTP (SFTP Connector) to override security parameters using Anypoint Studio.
## Create a Configuration Override File
Follow these steps to create the file:
  1. Navigate to your `src/main/resources` folder.
  2. Create a config file, for example, `mule_sshd_config` with the following SSHD content. The file follows the format of an `sshd_config` file:
```
KexAlgorithms ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group18-sha512,diffie-hellman-group17-sha512,diffie-hellman-group16-sha512,diffie-hellman-group14-sha256
Ciphers aes128-cbc,aes128-ctr,aes192-cbc,aes192-ctr,aes256-cbc,aes256-ctr
HostKeyAlgorithms ssh-rsa,rsa-sha2-256,rsa-sha2-512
MACs hmac-sha1,hmac-sha2-256,hmac-sha2-512
```



  3. Configure the keys and values accordingly. If you do not provide a key, then default values are used.


The following example shows the location of the config file within the `src/main/resources` folder:
## Configure the Override File in Anypoint Studio
Follow these steps to configure the override file:
  1. In Studio, navigate to the **Global Elements** tab.
  2. In the Choose Global Type window, type `sftp` in the search bar.
  3. Select **SFTP Config**.
  4. Click **OK**.
  5. Go to the **Advanced** tab.
  6. Under **Security Configuration** , enter `ssh config override file`.
  7. Enter the path to the file, for example: `${app.home}/mule_sshd_config`.
  8. Complete the remaining connection fields.
  9. Click **Test Connection…​**.
  10. Click **OK**.


In the **Configuration XML** editor window, the configuration looks like this:
```
<sftp:config name="SFTP_Config" doc:name="SFTP Config" >
  <sftp:connection host="localhost" sshConfigOverride="${app.home}/mule_sshd_config">
  </sftp:connection>
</sftp:config>
```

## Verify the Override File Creation
Consider the following points when verifying the file creation:
  * Search for the log `Read the config file` and verify that the filename and the configuration values fetched from the file are valid.
  * Find ignored configs with the log line `Config keys found but ignored`.
  * Check that if the connector is unable to locate the file, then it logs `Couldn’t locate config file`.


## See Also
  * SFTP Connector Examples
RPA Manager Overview | MuleSoft Documentation
# RPA Manager Overview
This topic is affected by the Anypoint Platform integration.
RPA Manager is the cloud-based control plane for the automations that is integrated into Anypoint Platform.
RPA Manager enables you to do the following:
  * Manage user access and permissions.
  * Evaluate the viability and financial benefits of implementing an automation.
  * Design and document RPA processes.
  * Test and deploy automations.
  * Manage and monitor deployed automations.


To access RPA Manager, navigate to , where `<tenant>` represents your organization’s instance. If you are not sure about this value, contact your organization’s administrator.
Ensure that access to this URL is possible from your organization.
RPA Builder, RPA Bot, and RPA Recorder use this URL to connect to your RPA Manager instance.
## Anypoint Platform Integration
MuleSoft RPA is integrating with Anypoint Platform to unify the login experience and provide support for external identity providers (IdPs).
Refer to Anypoint Platform Integration Overview for an overview of the changes and requirements.
If you are unsure whether your org is integrated, open the **Home** module in RPA Manager:
  * If you are using an RPA account for login, there is a quick link to Composer:
  * If you are using an Anypoint account for login, there is a quick link to Access Management:


## See Also
  * Anypoint Platform Integration Overview
  *   * What to Do if You Forgot Your Password
joinBy | MuleSoft Documentation
# joinBy
## joinBy(@StreamCapable elements: Array<StringCoerceable>, separator: String): String
Merges an array into a single string value and uses the provided string as a separator between each item in the list.
Note that `joinBy` performs the opposite task of `splitBy`.
### Parameters
Name | Description  
---|---  
The input array.  
`separator` | A `String` used to join elements in the list.  
### Example
This example joins the elements with a hyphen (`-`).
#### Source
```
%dw 2.0
output application/json
---
{ "hyphenate" : ["a","b","c"] joinBy "-" }
```

#### Output
```
{ "hyphenate": "a-b-c" }
```

## joinBy(n: Null, separator: Any): Null
Helper function that enables `joinBy` to work with a `null` value.
_Introduced in DataWeave version 2.4.0._
Registering for Access to a Portal | MuleSoft Documentation
# Registering for Access to a Portal
Users who access an API portal without logging in can’t perform most actions in the portal, like requesting access to APIs to use them. Becoming a member gives you access to more APIs and functionality. New users can sign up for an account to become a member. After signing up, API Experience Hub sends a welcome email that contains a link to set up the account and password.
To register for an account:
  1. In a browser window, enter the URL of the portal.
  2. Click **Log in**.
  3. Click **Not a Member?**.
  4. Enter your first name, last name, and email address.
  5. Click **Sign Up**.
  6. Follow the instructions in the welcome email to set up your account.


## See Also
  *   *
Coercions (dw::util::Coercions) | MuleSoft Documentation
# Coercions (dw::util::Coercions)
This utility module assists with type coercions.
To use this module, you must import it to your DataWeave code, for example, by adding the line `import * from dw::util::Coercions` to the header of your DataWeave script.
_Introduced in DataWeave version 2.4.0._
## Functions
Name | Description  
---|---  
Splits a `String` value into an `Array` of characters.  
Transform a `String` value into a `Binary` value using the specified encoding.  
Transform a `String` value into a `Boolean` value.  
Transforms a `String` value into a `Date` value using the first `Formatter` that matches with the given value to transform.  
| Transforms a `String` value into a `Date` value using the first `Formatter` that matches with the given value to transform.  
Transforms a `String` value into a `DateTime` value using the first `Formatter` that matches with the given value to transform.  
| Transforms a `String` value into a `DateTime` value using the first `Formatter` that matches with the given value to transform.  
| Transforms a `String` value into a `LocalDateTime` value using the first `Formatter` that matches with the given value to transform.  
| Transforms a `String` value into a `LocalDateTime` value using the first `Formatter` that matches with the given value to transform.  
Transforms a `String` value into a `LocalTime` value using the first `Formatter` that matches with the given value to transform.  
| Transforms a `String` value into a `LocalTime` value using the first `Formatter` that matches with the given value to transform.  
Transforms a `String` value into a `Number` value using the first `Formatter` that matches with the given value to transform.  
| Transforms a `String` value into a `Number` value using the first `Formatter` that matches with the given value to transform.  
Transform a `String` value into a `Period` value.  
Transforms a `String` value into a `Regex` value.  
A variant of `toString` that transforms a `Number` value (whole or decimal) into a `String` value and accepts a format, locale, and rounding mode value.  
Transforms a `String` value into a `Time` value using the first `Formatter` that matches with the given value to transform.  
| Transforms a `String` value into a `Time` value using the first `Formatter` that matches with the given value to transform.  
Transform a `String` value into a `TimeZone` value.  
Transforms a `String` value into a `Uri` value.  
## Types
  *
typeOf | MuleSoft Documentation
# typeOf
## typeOf<T>(value: T): Type<T>
Returns the primitive data type of a value, such as `String`.
A value’s type is taken from its runtime representation and is never one of the arithmetic types (intersection, union, `Any`, or `Nothing`) nor a type alias. If present, metadata of a value is included in the result of `typeOf` (see metadataOf).
### Parameters
Name | Description  
---|---  
Input value to evaluate.  
### Example
This example identifies the type of several input values.
#### Source
```
%dw 2.0
output application/json
---
[ typeOf("A b"), typeOf([1,2]), typeOf(34), typeOf(true), typeOf({ a : 5 }) ]
```

#### Output
```
[ "String", "Array", "Number", "Boolean", "Object" ]
```

### Example
This example shows that the type of a value is independent of the type with which it is declared.
#### Source
```
%dw 2.0
output application/json
var x: String | Number = "clearly a string"
var y: "because" = "because"
---
[typeOf(x), typeOf(y)]
```

#### Output
```
["String", "String"]
```
unzip | MuleSoft Documentation
# unzip
## unzip<T>(items: Array<Array<T>>): Array<Array<T>>
Performs the opposite of `zip`. It takes an array of arrays as input.
The function groups the values of the input sub-arrays by matching indices, and it outputs new sub-arrays with the values of those matching indices. No sub-arrays are produced for unmatching indices. For example, if one input sub-array contains four elements (indices 0-3) and another only contains three (indices 0-2), the function will not produce a sub-array for the value at index 3.
### Parameters
Name | Description  
---|---  
The input array of arrays.  
### Example
This example unzips an array of arrays. It outputs the first index of each sub-array into one array `[ 0, 1, 2, 3 ]`, and the second index of each into another `[ "a", "b", "c", "d" ]`.
#### Source
```
%dw 2.0
output application/json
---
unzip([ [0,"a"], [1,"b"], [2,"c"],[ 3,"d"] ])
```

#### Output
```
[ [ 0, 1, 2, 3 ], [ "a", "b", "c", "d" ] ]
```

### Example
This example unzips an array of arrays. Notice that the number of elements in the input arrays is not all the same. The function creates only as many full sub-arrays as it can, in this case, just one.
#### Source
```
%dw 2.0
output application/json
---
unzip([ [0,"a"], [1,"a","foo"], [2], [3,"a"] ])
```

#### Output
filterObject | MuleSoft Documentation
# filterObject
## filterObject<K, V>(@StreamCapable value: { (K)?: V }, criteria: (value: V, key: K, index: Number) -> Boolean): { (K)?: V }
Iterates a list of key-value pairs in an object and applies an expression that returns only matching objects, filtering out the rest from the output.
The expression must return `true` or `false`. If the expression returns `true` for a key, value, or index of an object, the object gets captured in the output. If it returns `false` for any of them, the object gets filtered out of the output. If there are no matches, the output array will be empty.
### Parameters
Name | Description  
---|---  
The source object to evaluate.  
Boolean expression that selects a `value`, `key`, or `index` of the object.  
### Example
This example outputs an object if its value equals `"apple"`.
#### Source
```
%dw 2.0
output application/json
---
{"a" : "apple", "b" : "banana"} filterObject ((value) -> value == "apple")
```

#### Output
```
{ "a": "apple" }
```

### Example
This example only outputs an object if the key starts with "letter". The DataWeave `startsWith` function returns `true` or `false`. Note that you can use the anonymous parameter for the key to write the expression `((value, key) → key startsWith "letter")`: ($$ startsWith "letter")`
#### Source
```
%dw 2.0
output application/json
---
{"letter1": "a", "letter2": "b", "id": 1} filterObject ((value, key) -> key startsWith "letter")
```

#### Output
```
{ "letter1": "a", "letter2": "b" }
```

### Example
This example only outputs an object if the index of the object in the array is less than 1, which is always true of the first object. Note that you can use the anonymous parameter for the index to write the expression `((value, key, index) → index < 1)`: `($$$ < 1)`
#### Source
```
%dw 2.0
output application/json
---
{ "1": "a", "2": "b", "3": "c"} filterObject ((value, key, index) -> index < 1)
```

#### Output
### Example
This example outputs an object that contains only the values that are not `null` in the input JSON object.
#### Source
```
%dw 2.0
output application/json
var myObject = {
  str1 : "String 1",
  str2 : "String 2",
  str3 : null,
  str4 : "String 4",
}
---
myObject filterObject $ != null
```

#### Output
```
{
 "str1": "String 1",
 "str2": "String 2",
 "str4": "String 4"
}
```

## filterObject(value: Null, criteria: (value: Nothing, key: Nothing, index: Nothing) -> Any): Null
Helper function that enables `filterObject` to work with a `null` value.
encodeURIComponent | MuleSoft Documentation
# encodeURIComponent
## encodeURIComponent(text: String): String
Escapes certain characters in a URI component using UTF-8 encoding.
There can be only four escape sequences for characters composed of two "surrogate" * characters. `encodeURIComponent` escapes all characters _except the following_ : alphabetic, decimal digits, `- _ . ! ~ * ' ( )`. Note that `encodeURIComponent` differs from `encodeURI` in that it encodes reserved characters and the Number sign `#` of `encodeURI`:
Reserved characters  
---  
Unescaped characters | alphabetic, decimal digits, - _ . ! ~ * ' ( )  
### Parameters
Name | Description  
---|---  
URI component string.  
### Example
This example encodes a variety of URI components.
#### Source
```
%dw 2.0
import * from dw::core::URL
output application/json
---
{
 "comparing_encode_functions_output" : {
 	"encodeURIComponent" : encodeURI(" PATH/ TO /ENCODE "),
 	"encodeURI" : encodeURI(" PATH/ TO /ENCODE "),
 	"encodeURIComponent_to_hex" : encodeURIComponent(";,/?:@&="),
 	"encodeURI_not_to_hex" : encodeURI(";,/?:@&="),
 	"encodeURIComponent_not_encoded" : encodeURIComponent("-_.!~*'()"),
 	"encodeURI_not_encoded" : encodeURI("-_.!~*'()")
 }
}
```

#### Output
```
{
 "comparing_encode_functions_output": {
  "encodeURIComponent": "%20PATH/%20TO%20/ENCODE%20",
  "encodeURI": "%20PATH/%20TO%20/ENCODE%20",
  "encodeURIComponent_to_hex": "%3B%2C%2F%3F%3A%40%26%3D",
  "encodeURI_not_to_hex": ";,/?:@&=",
  "encodeURIComponent_not_encoded": "-_.!~*'()",
  "encodeURI_not_encoded": "-_.!~*'()"
 }
}
```
atBeginningOfDay | MuleSoft Documentation
# atBeginningOfDay
## atBeginningOfDay(dateTime: DateTime): DateTime
Returns a new `DateTime` value that changes the `Time` value in the input to the beginning of the specified _day_.
The hours, minutes, and seconds in the input change to `00:00:00`.
_Introduced in DataWeave version 2.4.0._
### Parameters
Name | Description  
---|---  
The `DateTime` value to reference.  
### Example
This example changes the `Time` value within the `DateTime` input to the beginning of the specified day.
#### Source
```
%dw 2.0
import * from dw::core::Dates
output application/json
---
{
 "atBeginningOfDayDateTime": atBeginningOfDay(|2020-10-06T18:23:20.351-03:00|)
}
```

#### Output
```
{
 "atBeginningOfDayDateTime": "2020-10-06T00:00:00-03:00"
}
```

## atBeginningOfDay(localDateTime: LocalDateTime): LocalDateTime
Returns a new `LocalDateTime` value that changes the `Time` value within the input to the start of the specified _day_.
The hours, minutes, and seconds in the input change to `00:00:00`.
_Introduced in DataWeave version 2.4.0._
### Parameters
Name | Description  
---|---  
`localDateTime` |  The `LocalDateTime` value to reference.  
### Example
This example changes the `Time` value within the `LocalDateTime` input to the beginning of the specified day.
#### Source
```
%dw 2.0
import * from dw::core::Dates
output application/json
---
{
 "atBeginningOfDayLocalDateTime": atBeginningOfDay(|2020-10-06T18:23:20.351|)
}
```

#### Output
```
{
 "atBeginningOfDayLocalDateTime": "2020-10-06T00:00:00"
}
```
isHandledBy | MuleSoft Documentation
# isHandledBy
## isHandledBy(base: MimeType, other: MimeType): Boolean
Returns `true` if the given `MimeType` value is handled by the base `MimeType` value.
_Introduced in DataWeave version 2.7.0._
### Parameters
Name | Type | Description  
---|---|---  
The MIME type value used as baseline.  
The MIME type value to be validated.  
### Example
This example tests how MIME types handles several validations.
#### Source
```
%dw 2.0
import * from dw::module::Mime
output application/json
var JSON = {'type': "application", subtype: "json", parameters: {}}
var MULTIPART = {'type': "multipart", subtype: "form-data", parameters: {boundary: "my-boundary"}}
var ALL = {'type': "*", subtype: "*", parameters: {}}
---
{
 a: isHandledBy(JSON, JSON),
 b: isHandledBy({'type': "*", subtype: "json", parameters: {}}, JSON),
 c: isHandledBy({'type': "application", subtype: "*", parameters: {}}, JSON),
 d: isHandledBy(ALL, MULTIPART),
 e: isHandledBy(MULTIPART, ALL),
 f: isHandledBy(JSON, MULTIPART),
 g: isHandledBy(
  {'type': "application", subtype: "*+xml", parameters: {}},
  {'type': "application", subtype: "soap+xml", parameters: {}})
}
```

#### Output
```
{
 "a": true,
 "b": true,
 "c": true,
 "d": true,
 "e": false,
 "f": false,
 "g": true
}
```
Hadoop (HDFS) Connector - XML and Maven Support | MuleSoft Documentation
# Hadoop (HDFS) Connector - XML and Maven Support
If you manually code a Mule app in XML, either from the Anypoint Studio XML editor or from a text editor, configure access to the connector in your app by adding reference namespace statements to your XML Mule flow and a dependency in the Apache Maven POM file.
You can avoid this manual process by using Anypoint Studio. When you add the connector in Studio, Studio automatically populates the XML code with the connector’s namespace and schema location, and adds a dependency to the `pom.xml` file.  
---  
## Add a Reference Namespace Statement for the Connector
Paste the following code inside the `mule` tag of the header of your configuration XML:
```
http://www.mulesoft.org/schema/mule/hdfs
http://www.mulesoft.org/schema/mule/hdfs/current/mule-hdfs.xsd
```

This example shows how the namespace statements are placed in the XML:
```
<mule xmlns:hdfs="http://www.mulesoft.org/schema/mule/hdfs"
	xmlns="http://www.mulesoft.org/schema/mule/core"
	xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core
	http://www.mulesoft.org/schema/mule/core/current/mule.xsd
	http://www.mulesoft.org/schema/mule/hdfs
	http://www.mulesoft.org/schema/mule/hdfs/current/mule-hdfs.xsd">
```

## Add a POM File Dependency
The Apache Maven `pom.xml` file generated by Anypoint Studio contains Mule app connector dependencies. When you code a Mule app manually, include this XML snippet in your POM file to enable access to this connector:
```
<dependency>
	<groupId>org.mule.connectors</groupId>
  <artifactId>mule-hdfs-connector</artifactId>
  <version>6.0.3</version>
  <classifier>mule-plugin</classifier>
</dependency>
```

Verify that the connector `version` corresponds to the one you are using.
To obtain the most up-to-date `pom.xml` file information:
  1. Go to Anypoint Exchange.
  2. In Exchange, click **Login** and supply your Anypoint Platform username and password.
  3. In Exchange, search for `hdfs`.
  4. Click **Dependency Snippets**.


## See Also
MuleSoft Help Center
isLocalTimeType | MuleSoft Documentation
# isLocalTimeType
## isLocalTimeType(t: Type): Boolean
Returns `true` if the input is the LocalTime type.
_Introduced in DataWeave version 2.3.0._
### Parameters
Name | Description  
---|---  
The type to check.  
### Example
This example shows how `isLocalTimeType` behaves with different inputs.
#### Source
```
%dw 2.0
import * from dw::core::Types
type ALocalTime = LocalTime
output application/json
---
{
  a: isLocalTimeType(ALocalTime),
  b: isLocalTimeType(LocalTime),
  c: isLocalTimeType(String),
}
```

#### Output
```
{
 "a": true,
 "b": true,
 "c": false
}
```
Set a SOAP Header | MuleSoft Documentation
# Set a SOAP Header
Use APIkit to set headers to your application’s response based on the WSDL declarations.
To follow this example, you must download the `tshirt2.wsdl` API definition, and create a Mule application based on it. See prerequisites for Using APIkit for SOAP and create an APIkit for SOAP project for more information.
In this example, you add the `APIUsageInformation` header to the response of your application:
  1. In Anypoint Studio, open `tshirt2.wsdl` in `src/main/resources/api` and scroll to the `APIUsageInformation` element, which is the element expected by the contract.
  2. On the canvas, select `Transform Message` in the `OrderTshirt:/soapkit-config` flow.
The following DataWeave code is available:
```
{
	body : {
		ns0#OrderTshirtResponse: {
			orderId: "I got a request from "
			++ payload.body.ns0#OrderTshirt.name
			++ " using the following auth header "
			++ (payload.headers["AuthenticationHeader"].ns0#AuthenticationHeader.apiKey default "")
		}
	} write "application/xml"
}
```

  3. Add the following `APIUsageInformation` header declaration:
```
{
	body : {
		ns0#OrderTshirtResponse: {
			orderId: "I got a request from "
			++ payload.body.ns0#OrderTshirt.name
			++ " using the following auth header "
			++ (payload.headers["AuthenticationHeader"].ns0#AuthenticationHeader.apiKey default "")
		}
	} write "application/xml",
	headers: { **(1)**
		header: {
			ns0#APIUsageInformation: {
			}
		} write "application/xml"
	}
}
```

This DataWeave code adds headers to the output of the `Transform Message` component.  
---  
  4. Add the `apiCallsRemaining` header to the `APIUsageInformation` element:
```
{
	body : {
		ns0#OrderTshirtResponse: {
			orderId: "I got a request from "
			++ payload.body.ns0#OrderTshirt.name
			++ " using the following auth header "
			++ (payload.headers["AuthenticationHeader"].ns0#AuthenticationHeader.apiKey default "")
		}
	} write "application/xml",
	headers: {
		header: {
			ns0#APIUsageInformation: {
				apiCallsRemaining: 10 **(1)**
			}
		} write "application/xml"
	}
}
```

Set `apiCallsRemaining` to `10`.  
---  
  5. Save and run the project again.
  6. In SoapUI, execute the `OrderTshirt` request again.
The response envelope from APIkit for SOAP is:


```
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
   <ns0:APIUsageInformation xmlns:ns0="http://mulesoft.org/tshirt-service">
     <apiCallsRemaining>10</apiCallsRemaining>
   </ns0:APIUsageInformation>
  </soap:Header>
  <soap:Body>
   <ns0:OrderTshirtResponse xmlns:ns0="http://mulesoft.org/tshirt-service">
     <orderId>I got a request from John, using the following auth header 987654321</orderId>
   </ns0:OrderTshirtResponse>
  </soap:Body>
</soap:Envelope>
```

## See Also
  * APIkit for SOAP Module Reference
X12 EDI Connector 2.17 Examples | MuleSoft Documentation
# X12 EDI Connector 2.17 Examples
Use this example to view the use case for Business-to-Business (B2B) EDI integration leveraging Anypoint X12 Connector. This example:
  * Transforms XML messages into outbound EDI X12 850 purchase order transactions


An HTTPS Listener source receives the enterprise purchase order XML messages from a backend system. DataWeave and X12 Writes translate the XML message into an X12 v4010 850 purchase order EDI message.
  * Transforms Inbound EDI X12 850 purchase orders into JSON


An HTTP Listener source receives the raw EDI X12 850 purchase order message. X12 Read and DataWeave components pare and translate the EDI data into the JSON format.
  * Generates a Functional Acknowledgment (997)


## Prerequisites
  1. Open the Transform XML to EDI X12 850 purchase orders and X12 850 to JSON example in Anypoint Studio from Anypoint Exchange Examples.
  2. Install the latest version of Anypoint X12 Connector.


## Run and Test the Outbound XML to EDI X12 850
  1. Run the application in Anypoint Studio.
  2. Test the outbound flow by using a REST Client to post a request (POST) to a JSON message to the URL:


`http://localhost:8081/x12/send/enterprise-ob-purchaseorder`
You see the payload location under the following directory:
`src/main/resources/outbound/Enterprise-Outbound-PO.xml`
The Mule app returns the generated EDI X12 850 transaction.
## Run and Test the Inbound EDI X12 850 to JSON
  1. Test the inbound flow using a REST Client to post a request (POST) to a raw EDI X12 850 message to the URL:
`http://localhost:8081/x12/receive/4010-850`
You see the payload location under the following directory:
`src/main/resources/inbound/EDI-4010-850-NTO-to-Mythical.edi`
The app returns the translated JSON purchase order message.
A Functional Acknowledgement (997) is generated and sent to the log.
  2. Send the message back to the trading partner via any standard protocol, such as FTP, SFTP, or AS2.


## See Also
  * Introduction to Anypoint Connectors
  * MuleSoft Help Center
Enable DoS for a WAF Policy | MuleSoft Documentation
# Enable DoS for a WAF Policy
You can configure actions in an existing DoS policy to apply to WAF errors, for example, blocking an IP address for a specified time interval. In a WAF policy, WAF errors are rejected and a status code of `400` is returned, however WAF processing is expensive, so you may want to add WAF errors to a DoS policy to protect resource usage.
If you don’t configure your DoS policy (apply DoS thresholding) for WAF errors, parsing request bodies can consume a large share of CPU. If you receive many requests, just detecting errors will consume a large share of CPU. If DoS thresholding is implemented, when the threshold for DoS is exceeded, it ceases to parse request bodies.
When a blocked IP address attempts to connect, the request will be rejected based solely on the IP address. This is extremely efficient. If **Drop Silently** is enabled for DoS, the TLS connection isn’t attempted, which saves more resources.
IP addresses coming from a malicious source may be attempting many other requests other than those triggering WAF. Some of these requests may look valid. When the DoS threshold is exceeded, all requests, good or bad, are dropped for the identified IP address.
## Escalate a WAF Policy to DoS
To escalate a WAF policy to DoS, verify that the Denial of Service Policy exists.
  1. In **Security Policies** , select the DoS policy in the list and click **Edit**.
  2. In the left menu, click **WAF Errors**.
  3. Configure the WAF errors, and click **Save Policy**. All WAF errors will be handled by the thresholds you configure in the DoS policy.
In this example, for **Rule A** , all requests for the source IP address are limited if more than 10 WAF errors are received within a 60-second time interval. (The default is 60 seconds, but you can change this value in the **General** tab for the DoS policy.)


In **Rule B** , the settings shown will block an IP address indefinitely if it causes the specified WAF error three times in a period of five **Rule A** intervals (5 60-second intervals in this case).
For more information about configuring DoS policies, see Denial of Service Policy
Amazon EC2 Connector 2.3 | MuleSoft Documentation
# Amazon EC2 Connector 2.3
Anypoint Connector for Amazon EC2 (Amazon EC2 Connector) provides connectivity to the Amazon Elastic Compute Cloud (Amazon EC2) API, enabling you to interface with Amazon EC2 to launch as many or as few virtual servers as you need, configure security and networking, and manage storage.
## Before You Begin
To use Amazon EC2 Connector, you must have the following:
  * AWS Identity and Access Management (IAM) user account credentials
  * Access to EC2 via the AWS cloud
  * Anypoint Studio 7.0 or later
  * A secret access key to IAM


## Common Use Cases
Common use cases for the connector:
  * Create an EBS volume to attach to an instance in the same availability zone
  * Attach an EBS volume to a running or stopped Amazon EC2 instance
  * Restart an Amazon EBS-backed AMI that you’ve previously stopped
  * Stop an Amazon EC2 instance


## Audience
  * New users, read:
    * Using Anypoint Studio to Configure the Connector to create your Mule app
    * Examples, which provide one or more use cases for the connector
  * Advanced users, read:
    * XML and Maven Support
    * Examples, which provides one or more use cases for the connector


## Authentication Types
Amazon EC2 Connector connections use the following authentication types:
  * Basic Uses a session token provided by Amazon STS to connect to Amazon SQS
  * Role Uses the Amazon role ARN that uniquely identifies the role to assume to allow cross-account access


## See Also
  * Introduction to Anypoint Connectors
  * Use Exchange to Discover Connectors, Templates, and Examples
  * Amazon EC2 Connector Reference
  * MuleSoft Help Center
isNumberType | MuleSoft Documentation
# isNumberType
## isNumberType(t: Type): Boolean
Returns `true` if the input is the Number type.
_Introduced in DataWeave version 2.3.0._
### Parameters
Name | Description  
---|---  
The type to check.  
### Example
This example shows how `isNumberType` behaves with different inputs.
#### Source
```
%dw 2.0
import * from dw::core::Types
type ANumber = Number
output application/json
---
{
  a: isNumberType(ANumber),
  b: isNumberType(Number),
  c: isNumberType(String),
}
```

#### Output
```
{
 "a": true,
 "b": true,
 "c": false
}
```
Assigning Permissions | MuleSoft Documentation
# Assigning Permissions
Before you set up your private space, ensure you have the required permissions assigned to your user account or a team to which you belong. To assign permissions, you need access to Access Management and the Organization Administrator permission.
  * To set up and manage a private space, you need the CloudHub Network Administrator permission.
  * To view a private space as an individual user within an organization, you need at least one of the following permissions:
    * Cloudhub Network Viewer, which enables you to view private spaces and their details.
    * Organization Administrator, which enables you to manage and update private spaces.
    * Cloudhub Network Administrator, which enables you to manage and update private spaces.
Without at least one of these permissions, you can’t see any details upon selecting the **Private Spaces** tab. Instead, you receive a **Not Authorized** message.
  * To deploy applications from Exchange, you must assign the Exchange Contributor and Exchange Viewer permissions to the Business Organization that owns the asset.
  * To deploy applications in Runtime Manager, you need the Create Applications permission.
  * To view all applications on the **Applications** page in Runtime Manager, you need the Read Applications and CloudHub Network Viewer permission.
  * To view applications deployed to Runtime Fabric and CloudHub 2.0, you also need the following two permissions:
    * Read Applications for the Environment.
    * Read Runtime Fabrics for the Business Group.
  * Assigning the **Create Applications** role to a user also gives the **Read Applications** role that is required to deploy applications.
  * To view the schedules in applications deployed to CloudHub 2.0 and Runtime Fabric, you must assign the Exchange Viewer permission to the Business Organization that owns the asset.


Depending on your organization’s permission structure, you can assign these permissions using the Teams feature, the Roles feature (deprecated), or by assigning an individual user permission.
Note that users who have the Organization Administrator permission can also view and manage all private spaces and additional privileges across Anypoint Platform. However, you should not assign this permission as a substitute for CloudHub 2.0-specific privileges. For more information, see general permissions.
## See Also
  * Access Management Overview
Anypoint Security Overview | MuleSoft Documentation
# Anypoint Security Overview
Anypoint Security for Anypoint Runtime Fabric provides a layered approach to secure your application network. These layers work together to protect both the application network and the network’s individual nodes by controlling access to APIs, enforcing policies, and proxying all inbound or outbound traffic to mitigate external threats and attacks. Anypoint Security also provides you with a dedicated endpoint to detect attacks and validate traffic without taxing your network implementations.
## Policies
Anypoint Security features a high-performance, reliable, and scalable service to enforce policies that apply to all nodes deployed to your Runtime Fabric instance. These policies then act as a default firewall or router capability through which all traffic traverses.
## Secrets Manager
Anypoint Security provides a secure vault for you to store the TLS certificates and keystores used by your deployments.
Through Secrets Manager, you can store the necessary secrets to set up the TLS context that encrypts inbound traffic to your Runtime Fabric.
## Tokenization Service
Anypoint Security’s tokenization service protects sensitive data from unwanted exposure by replacing key values, such as a credit card number, with a token.
Anypoint Security requires a separate license. Contact your MuleSoft account representative for more information.   
---  
## See Also
  *   * Tokenization Service
Troubleshooting SOAP APIs | MuleSoft Documentation
# Troubleshooting SOAP APIs
Flex Gateway does not natively support SOAP APIs and does not provide any schema validation for XML. However, you can publish an HTTP API instance to a secure SOAP upstream service.
To create an HTTP API instance to a secure SOAP API upstream service, refer to the following:
  * Publishing Managed Gateway and Connected Mode APIs
  * Publishing Local Mode APIs


## Publish a Soap API
Refer to the following video for additional information about how to publish a SOAP API as an HTTP API instance:
## SOAP API Policy Limitations
Flex Gateway policies return JSON error messages when the policy blocks a request. Most SOAP clients cannot read the JSON messages.
SOAP APIs do not support the following policies:
  * Schema Validation Policy
  * JSON Threat Protection Policy
Configuring an HTTPS Endpoint | MuleSoft Documentation
# Configuring an HTTPS Endpoint
You can automatically deploy an API proxy using an HTTP listener (inbound HTTP endpoint) with minimal setup. You can use this approach if you do not foresee any security concerns in your Anypoint Platform API setup. Otherwise, you must configure your API proxy with an HTTPs listener (inbound HTTPS endpoint), instead of an HTTP listener.
MuleSoft requires that you provide your own certificate when configuring your HTTPs setup. The certificate you use can be:
  * A self-signed certificate to be used for demo purposes
  * A custom TLS certificate with validity within your organization
  * A trusted Certificate Authority (CA) certificate


If your backend uses HTTPS with a self-signed certificate or custom TLS certificate, you must configure the API proxy requester with the corresponding certificate.
Depending on your business use case, you can use any of the following recommended ways to configure your API proxy:
  * Use a certificate configured through the UI by leveraging Secrets Manager:
Upload your certificate to a secure vault within API Platform, make it available when you configure the proxy through the secrets manager, and then deploy the secure API proxy to the target runtime, such as CloudHub, Runtime Fabric, or on-premises deployment.
  * Use a certificate defined in already deployed Mule domain
Configure the certificate in the domain so that the API proxy HTTPS Listener references it, and then deploy the secure API proxy to the target Runtime Fabric, or on-premises target. (CloudHub is not supported with this approach because it does not support Mule domains.)
  * Use a certificate configured with Anypoint Studio
For this approach, download the API proxy, open it in Anypoint Studio, and manually configure HTTPS. You can then deploy the proxy to the target runtime, such as CloudHub, Runtime Fabric, or on-premises deployment. (If the target runtime is on CloudHub, use port 8082 when working with HTTPs.)


## See Also
  *   * Building an HTTPS API Proxy
  *   * Domain Support for Mule 4 API Proxies
  *
XML Threat Protection Policy | MuleSoft Documentation
# XML Threat Protection Policy
**Policy Name** | XML Threat Protection  
---|---  
Protects against malicious XML in API requests  
Security  
**First Mule version available**  
**Returned Status Codes** | 400 - Bad Request  
## Summary
Applications processing XML requests are susceptible to attacks characterized by unusual inflation of elements, attributes, and nesting levels. Attackers use recursive techniques to consume memory resources. Dramatic increases in the size of the application data often signal a security problem. The XML Threat Protection policy helps protect your applications from such intrusions.
If you find that attacks on your Anypoint Platform setup are difficult to detect, design your services architecture with layers of protection in addition to XML Threat Protection.
## Configuring Policy Parameters
### Flex Gateway Local Mode
The XML Threat Protection policy is not supported in Flex Gateway Local Mode.
### Flex Gateway Connected Mode
The XML Threat Protection policy is not supported in Flex Gateway Connected Mode.
### Mule Gateway
When you apply the XML Threat Protection policy to your API from the UI, the following parameters are displayed:
**Description**  
---  
Maximum Node Depth | Specifies the maximum node depth of an XML document.  
Maximum Attribute Count Per Element | Specifies the maximum number of attributes in an element. Note that attributes used for defining namespaces are not counted.  
Maximum Child Count | Specifies the maximum number of children of an element in the XML document.  
Maximum Text Length | Specifies the maximum length (in characters) of text nodes in the XML document.  
Maximum Attribute Length | Specifies the maximum length (in characters) of an attribute in the XML document.  
Maximum Comment Length | Specifies the maximum number of comment characters in the XML document.  
A value of -1 indicates that the field value has no limits.   
---  
## Example
The following screenshot shows an example of the parameters configured for the XML Threat Protection policy:
Event Stream Format | MuleSoft Documentation
# Event Stream Format
MIME type: `text/event-stream`
ID: `eventstream`
DataWeave represents the Event Stream as an `Array` of `Object`, where each value is a `String`. The output type is `Array<{_:String}>`, where each key represents a field in the event.
## Examples
These examples show uses of the Event Stream format.
  * Example: Simple Server Event Input
  * Example: Ignoring Spaces After the Colon


### Example: Simple Server Event Input
This example shows how DataWeave represents a simple server event input.
#### Input
This stream contains four blocks. The first block has one comment, and fires no events. The second block has two fields with names `data` and `id` respectively; an event is fired with the data `first event` and sets the last event ID to `1`. The third block fires an event with the data `second event`; it also has an `id` field with no value, which resets the last event ID to an empty string. The fourth block contains a `data` field with the value `third event`, which fires an event.
```
: test stream
data: first event
id: 1
data:second event
id
data: third event
```

#### Source
The DataWeave script transforms this input into the given output.
```
%dw 2.0
output application/json
---
payload
```

#### Output
The JSON format outputs the 3 events.
```
[
 {
  "data": "first event",
  "id": "1"
 },
 {
  "data": "second event",
  "id": ""
 },
 {
  "data": "third event"
 }
]
```

### Example: Ignoring Spaces After the Colon
This example shows that spaces after the colon are ignored if present.
#### Input
myInput.sse:
```
data:test
data: test
```

#### Source
This process transforms the input into JSON.
```
%dw 2.0
output application/json
---
payload
```

#### Output
The JSON output is an `Array` of the valid `Object` from the server event input.
```
[
 {
  "data": "test"
 },
 {
  "data": "test"
 }
]
```

## Configuration Properties
DataWeave supports these configuration properties for this format.
### Reader Properties
This format has no reader properties.
### Writer Properties
This format accepts properties that provide instructions for writing output data.
Parameter | Type | Default | Description  
---|---|---|---  
`bufferSize` |  Size of the buffer writer, in bytes. The value must be greater than `8`.  
Generates the output as a data stream when set to `true`, and defers the script’s execution until the generated content is consumed. Valid values are `true` or `false`.  
## Supported MIME Types
This format supports the following MIME types.
`text/event-stream`  
---
singularize | MuleSoft Documentation
# singularize
## singularize(text: String): String
Converts a plural string to its singular form.
If the input is already singular (for example, "box"), the output will match the input.
### Parameters
Name | Description  
---|---  
The string to convert to singular form.  
### Example
This example converts the input string "boxes" to return "box".
#### Source
```
%dw 2.0
import * from dw::core::Strings
output application/json
---
{ "singularize" : singularize("boxes") }
```

#### Output
```
{ "singularize" : "box" }
```

## singularize(text: Null): Null
Helper function that enables `singularize` to work with a `null` value.
Downloading an API Proxy | MuleSoft Documentation
# Downloading an API Proxy
You use a proxy to manage your API without having to change its implementation and to prevent attacks on the server. Mule Runtime is the server that hosts a Mule proxy application.
You must have View APIs Configuration permission to download a proxy.   
---  
You can download a proxy that you generated in API Manager by following this procedure.
  1. Navigate to **Anypoint Platform** > **API Manager**.
  2. In **API Administration** , click the API instance whose proxy you want to download.
  3. Click **Actions** and select **Download Proxy**.


## See Also
  * Granting Permission to Access an environment
  * Creating an API instance on API Manager
  * Reviewing API Gateway API Autodiscovery concepts