Establishing a Connection
This section describes how to connect to NetSuite from your AnyPoint Studio project. You can use wizards or the XML editor in AnyPoint Studio to define connection properties in a global element. Global elements can be reused across other building blocks in your project.
Create a Connection in the Visual Editor
Complete the following steps to visually add the connector to your project and create a connection:
- Create a new Mule Project in Anypoint Studio.
- From the palette, drag the connector into your Mule flow.
- On the Message Flow canvas, double-click the connector icon to open the connector properties in the Properties pane.
- In the General section, click Add and define the NetSuite connection properties. Note that the user name and Password properties always appear here. The user name must be set as it is used as the key for the connection if connection pooling is enabled.
Create a Connection in the XML Editor
Set connection properties in the <cdata-netsuite:config> element in the root of the project's XML.
Note: The user name attribute must always be included here and serves as the key for the connection if connection pooling is enabled.
<cdata-netsuite:config name="CData_NetSuite_Configuration" username="MyName" connectionProperty1="MyProperty" ... doc:name="CData NetSuite: Configuration"/>
Connecting to NetSuite
As of 2020.2, NetSuite will no longer support user / password connections. While the CData MuleSoft Connector for NetSuite will continue to support User/Password connections for Version set to values lower than 2020.2, it is recommended that all customers migrate to OAuth and Token Based Authentication mechanisms described below.
It is recommended but not required to specify the NetsuiteMetadataFolder. The Netsuite Metadata Folder is a folder on disk where NetSuite metadata files will be stored. If you do not specify one, a folder location will be selected automatically. To ensure fast load times when listing metadata about tables, it is best to set this property.
NetSuite Web Services Permissions
The connector communicates with NetSuite through the NetSuite Web services. This means that any connecting user must have permissions on the specified AccountId to connect through NetSuite Web services. Please see the Permission Configurations for greater details on required and optional permissions.
1. Create or edit a role for Web services permissions
- Log into NetSuite and under Setup go to User/Roles -> Manage Roles -> New. Alternatively, edit an existing role.
- Click Permissions -> Setup and add the "SOAP Web Services" and "REST Web Services" permissions.
- Add other permissions that are needed for interacting with various entities and transactions.
- Under Setup, go to User/Roles -> Manage Users and select the user.
- On the Access tab, add the newly created role and save the user.
There are two methods of Token Authentication that may be performed:
- Token Based Authentication - A form of authentication where the administrator directly creates an app within NetSuite and the OAuthAccessToken and OAuthAccessTokenSecret to assign the user. See Creating an Access Token in NetSuite for further details on this process.
- OAuth - OAuth 1.0 is used to form a two way handshake where the user logs in and directly grants permissions to the connection application and selects which role will be used for the app. Please see Using OAuth Authentication for details on how to connect via OAuth.
By default, NetSuite allows only one request at a time for a given user. If a request is still executing against NetSuite when another one is attempted, an error stating "Only one request may be made against a session at a time" will be thrown on the second connection.
NetSuite Response Times
NetSuite response times can take a long time depending on what you are retrieving. This can range from 20-40 seconds to retrieve 1000 SalesOrders to up to 8-12 minutes to retrieve a single page of the SalesOrder_ItemList. The main factor that can affect performance is whether or not child table information is retrieved. For instance, the SalesOrder_ItemList table would be considered the child table of SalesOrder. In addition, the information in the ItemListAggregate on the SalesOrder table would be considered child table information. Because of the significant delay it adds in response times from NetSuite, we have defaulted AggregateColumnMode to Ignore. When set to either Ignore or List, this will cause any Aggregate columns on base tables such as SalesOrder to not request data from NetSuite. This property has no effect on child tables.
Configure Connector Operations
The connector is an operation-based connector; its operations correspond to SQL statements and expose other functionality such as Schema Discovery. See Using the Connector (Mule 3.8+) for more information on executing SQL to NetSuite in Mule applications.