/n software Connectors for MuleSoft

Questions / Feedback?

REST Connector

Properties   Configuration Settings  

The REST connector provides a simple, ligthweight and fast way to communicate with RESTful web server.

Remarks

The REST connector implements a highly configurable HTTP client that is capable of sending and receiving data to and from web servers. Support includes issuing simple GET requests as well as defining custom form and file parameters to be POSTed to server. URL defines the location to which the request is made.

The connector supports HTTP 1.0, 1.1, and 2.0 which can be configured in the HTTPVersion property.

The HTTPMethod property defines the HTTP method to use. Possible values are:

  • DELETE
  • GET (default)
  • HEAD
  • POST
  • PUT
  • TRACE

Getting Data From the Server

In the REST Send Connector, if HTTPMethod is set to GET the request is issued to the server specified by URL. Additional custom headers may be specified in the request by setting OtherHeaders.

The response received by the connector will be used as the body of the submitted message. In the case of the Send Connector the response message is only returned when the connector is configured in a solicit response port (recommended). The HTTP headers of the response are available via the TransferredHeaders context property of the message.

Sending Data To the Server

When HTTPMethod is set to POST or PUT data will be sent to the server. The RequestParams property specifies one or more parameters to add to the POST or PUT request. This property is only applicable when the HTTPMethod property is set to POST or PUT.

To specify additional parameters set this property to one or more name value pairs. Set one pair on each line. For instance:

name1=value1
name2=value2

The connector will format a request with parameters slightly differently depending on whether the request is made by the Send or Receive adapter.

Note: To have complete control over the data being sent set PostData instead.

Send Connector

When sending a POST or PUT request the message payload will always be used as the last parameter regardless of the values specified in RequestParams. If no values are set here then a request will be made with only one parameter which is the content of the message. Several examples and additional details follow.

Basic Example:

Setting the RequestParams to a value of:

name1=value1
name2=value2

Will result in a HTTP request like this:

POST / HTTP/1.1
Host: www.nsoftware.com
Accept-Encoding: gzip, deflate
User-Agent: IPWorks HTTP Component - www.nsoftware.com
Connection: close
Content-Type: multipart/form-data; boundary="boundaryV+iTxA=="
Content-Length: 335

--boundaryV+iTxA==
Content-Disposition: form-data; name="name1"
Content-Type: text/plain
	
value1
--boundaryV+iTxA==
Content-Disposition: form-data; name="name2"
Content-Type: text/plain
	
value2
--boundaryV+iTxA==
Content-Disposition: form-data
Content-Type: application/octet-stream
	
message body
--boundaryV+iTxA==--

Notice that the default "Content-Type" for the individual request parameters is "text/plain", and the default "Content-Type" for the message form variable is "application/octet-stream" and has no defined name attribute. See the following examples for further details.

Custom Request Parameter Content-Type Values:

When sending requests the RequestParams may optionally include a custom Content-Type value. The syntax is:


[ContentType]name=value

For instance setting RequestParams to a value of:

[text/html]name1=value1
[my/type]name2=value2
name3=value3
Will result in a HTTP request like:
POST / HTTP/1.1
Host: www.nsoftware.com
Accept-Encoding: gzip, deflate
User-Agent: IPWorks HTTP Component - www.nsoftware.com
Connection: close
Content-Type: multipart/form-data; boundary="boundaryQDNEUw=="
Content-Length: 439

--boundaryQDNEUw==
Content-Disposition: form-data; name="name1"
Content-Type: text/html
	
value1
--boundaryQDNEUw==
Content-Disposition: form-data; name="name2"
Content-Type: my/type
	
value2
--boundaryQDNEUw==
Content-Disposition: form-data; name="name3"
Content-Type: text/plain
	
value3
--boundaryQDNEUw==
Content-Disposition: form-data
Content-Type: application/octet-stream
	
message body
--boundaryQDNEUw==--

Note the updated Content-Type header values for the "name1" and "name2" parameters.

Custom Content-Type and Name Values for the Message Payload Variable:

The default Content-Type value for the Message Payload form variable is "application/octet-stream" and no "name" attribute is defined in the Content-Disposition header. These can be explicitly defined in the ContentType and ContentFilename properties. These properties are applicable to the Message Payload form variable even if RequestParams is not set. For instance setting:

And leaving RequestParams unspecified (no parameters) will result in a HTTP request like:


POST / HTTP/1.1
Host: www.nsoftware.com
Accept-Encoding: gzip, deflate
User-Agent: IPWorks HTTP Component - www.nsoftware.com
Connection: close
Content-Type: multipart/form-data; boundary="boundaryVAJHkA=="
Content-Length: 142

--boundaryVAJHkA==
Content-Disposition: form-data; name="myfile.txt"
Content-Type: text/html
	
message body
--boundaryVAJHkA==--

Parsing the Response

The ResponseXPath property may be set to traverse elements within the JSON document. This property implements a subset of the XML XPath specification, allowing you to point to specific elements in the XML document. When this property is set, the connector will parse the response and return the value at the specified location.

For example, let's say the response data from the original request is below.


{
    "bag": {
        "name": "fanny-pack",
        "items": ["camera", "wallet"],
        "description": "A hip new design by nsoftware"
    }
}

The ResponseXPath property supports both XPath notation and JSONPath notation. For simplicitly, only the XPath notation is shown below. For more information and examples on notation schemes please see "Getting Started with JSON".

If you would like to return the value of element "name" from the operation, then set ResponseXPath to /json/bag/name/. Likewise, if you would like to return the value of the first element of the "items" array, then we can set ResponseXPath to /json/bag/items/[0]/ and the output will be camera.

Additional Settings

In addition to the basic operation as discussed above the connector supports a variety of other settings that control authentication, proxy settings, and other behavior. Some of additional features include:

Sender Property List


The following is the full list of the properties of the sender connector with short descriptions. Click on the links for further details.

AttachedFileA file to include in the POST data.
AuthorizationThe Authorization string to be sent to the server.
AuthSchemeThe authorization scheme to be used when server authorization is to be performed.
ContentFilenameDefines the filename of the content.
ContentTypeDefines the Content-Type header in the request.
CookiesThe cookies to be sent in the HTTP request.
FirewallA set of properties related to firewall access.
FollowRedirectsDetermines what happens when the server issues a redirect.
HTTPMethodThe HTTP method used for the request.
HTTPProxyA set of properties related to proxy access.
HTTPVersionThe HTTP version to use.
LogFileThe file to write logging information to at runtime.
LogModeWhat information gets logged during connector execution.
LogTypeHow information gets logged during connector execution.
OAuthAuthorizationOAuth Authorization Information.
OtherDefines a set of configuration settings to be used by the connector.
OtherHeadersOther headers as determined by the user.
PasswordA password if authentication is to be used.
PostDataThe data to be posted to the server.
RequestParamsParameters to add to the POST or PUT request.
ResponseXPathThis property may be set to traverse elements within the JSON document.
RuntimeLicenseSpecifies the connector runtime license key.
SSLAcceptServerCertInstructs the connector to unconditionally accept the server certificate that matches the supplied certificate.
SSLCertThe certificate to use for client authentication during the SSL handshake.
StatusCodeThe response status code of the last server response. TBD.
StatusLineThe first line of the last server response.
TimeoutA timeout for the connector.
TransferredHeadersThe full set of headers as received from the server.
URLThe URL to which the request is made.
UserA user name if authentication is to be used.

Configuration Settings


The following is a list of configuration settings for the connector with short descriptions. Click on the links for further details.

AcceptA list of acceptable MIME types for the request.
AcceptEncodingUsed to tell the server which types of content encodings the client supports.
AllowHTTPCompressionThis property enables HTTP compression for receiving data.
AllowHTTPFallbackA list of acceptable MIME types for the request.
ChunkSizeSpecifies the chunk size in bytes when using chunked encoding.
CustomRequestMethodSpecifies the HTTP method to be used.
EncodeURLIf set to true the URL will be encoded by the component.
IfModifiedSinceA date determining the maximum age of the desired document.
KerberosSPNThe Service Principal Name for the Kerberos Domain Controller.
LogDebugDataWhether to log debug data.
MaxRedirectAttemptsLimits the number of redirects that are followed in a request.
PragmaA browser/server specific header line (optional).
RangeThe byte-range to be sent to the server.
RefererReferer URL/document (optional).
ResponseBodyAlwaysAvailableWhether the response body is always available.
SubmitErrorAsMessageWhether errors are submitted as BizTalk messages.
TransferredDataLimitThe maximum of data to be transferred.
UseChunkedEncodingEnables or Disables HTTP chunked encoding for transfers.
UserAgentInformation about the user agent (browser).
ReuseSSLSessionDetermines if the SSL session is reused.
SSLCipherStrengthThe minimum cipher strength used for bulk encryption.
SSLEnabledCipherSuitesThe cipher suite to be used in an SSL negotiation.
SSLEnabledProtocolsUsed to enable/disable the supported security protocols.
SSLIncludeCertChainWhether the entire certificate chain is included in the SSLServerAuthentication event.
SSLSecurityFlagsFlags that control certificate verification.
TLS12SignatureAlgorithmsDefines the allowed TLS 1.2 signature algorithms when UseInternalSecurityAPI is True.
TLS13SignatureAlgorithmsThe allowed certificate signature algorithms.
TLSNamedGroupsThe supported (EC)DHE groups.
AbsoluteTimeoutDetermines whether timeouts are inactivity timeouts or absolute timeouts.
LocalHostThe name of the local host or user-assigned IP interface through which connections are initiated or accepted.
TcpNoDelayWhether or not to delay when sending packets.
UseInternalSecurityAPITells the connector whether or not to use the system security libraries or an internal implementation.

 
 
Copyright (c) 2021 /n software inc. - All rights reserved.
/n software Connectors for MuleSoft - Version 20.0 [Build 7722]