Tuesday, September 6, 2016

WSO2 NetSuite Connector

In this blog post, I am going to explain how to configure the WSO2 NetSuite Connector.

NetSuite is cloud-based Enterprise Resource Planning (ERP) solution. It provides powerful financial/accounting capabilities, which gives the real-time visibility to make better, faster decisions. NetSuite exposes its functionality via SuiteTalk web services to makes easy for customers and developers to integrate NetSuite with a variety of applications.

WSO2 NetSuite connector allows you to interact with the functionality and data of the NetSuite from the WSO2 ESB message flow and makes the integrations faster. This connector uses authentication with the request-level credentials, which are sent in the SOAP header. When you use this approach, the request-level preferences override any system-wide preferences that might have been set.

These sections provide step-by-step instructions on how to set up your web services environment in NetSuite and start using the connector to interface with SuiteTalk.

Requirements 

  • WSO2 ESB
  • Netsuite connector
  • Netsuite account


Enable the NetSuite Web Services Feature

  • Go to setup > company > enable features
  • Select the SuiteCloud tab.
  • Check the Web Services check box.
  • Select Save.



Get the account Id

  • Go to Setup > Integration > Web Services Preferences
  • Copy the Account ID



If you use SuiteTalk API version 2015.2 in which NetSuite introduced a new concept called "Integration Record." So if you upgrade to the 2015.2 or a later endpoint, all web services requests must be associated with an integration record. That is, each request must include the application ID. If you uses the 2015.1 endpoint or earlier, an application ID is optional.

To manually create an integration record

  • Go to Setup > Integration > Manage Integrations > New.
  • Fill the required fields. Click Save.



The system saves the new record and updates the page to show the record’s application ID.


Setting the Internal ID Preference


You can configure NetSuite to display internal ID values in the UI. This behavior can be useful during development of your web services integration. The display of internal IDs lets you verify that the values submitted in web services requests match the intended records.
  • Go to Home > Set Preferences. The General subtab is displayed by default.
  • In the Defaults section, click Show Internal IDs.

Using the Web Services Usage Log


Web Services Usage Log lists web services calls. The request and response are captured in NetSuite under: Setup > Integration > Web Services Usage Log


Setup the WSO2 ESB with NetSuite Connector


  • Download the ESB from here and start the server.
  • Download the NetSuite connector from WSO2 Store.
  • Add and enable the connector via ESB Management Console.
  • Create Proxy service to search customer info from NetSuite and invoke the proxy with the following request.
Proxy Service

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="searchCustomer"
       startOnLoad="true"
       statistics="disable"
       trace="disable"
       transports="https,http">
   <target>
      <inSequence>
         <property xmlns:ns="wso2.connector.netsuite"
                   expression="//ns:apiUrl/text()"
                   name="apiUrl"/>
         <property xmlns:ns="wso2.connector.netsuite"
                   expression="//ns:applicationId/text()"
                   name="applicationId"/>
         <property xmlns:ns="wso2.connector.netsuite"
                   expression="//ns:email/text()"
                   name="email"/>
         <property xmlns:ns="wso2.connector.netsuite"
                   expression="//ns:password/text()"
                   name="password"/>
         <property xmlns:ns="wso2.connector.netsuite"
                   expression="//ns:account/text()"
                   name="account"/>
         <property xmlns:ns="wso2.connector.netsuite"
                   expression="//ns:searchRecord/*"
                   name="searchRecord"/>
         <netsuite.init>
            <apiUrl>{$ctx:apiUrl}</apiUrl>
            <applicationId>{$ctx:applicationId}</applicationId>
            <password>{$ctx:password}</password>
            <email>{$ctx:email}</email>
            <account>{$ctx:account}</account>
         </netsuite.init>
         <netsuite.search>
            <searchRecord>{$ctx:searchRecord}</searchRecord>
         </netsuite.search>
         <respond/>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
   <description/>
</proxy>

Request

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="wso2.connector.netsuite">
   <soapenv:Header />
   <soapenv:Body>
      <urn:apiUrl>https://webservices.na1.netsuite.com/services/NetSuitePort_2015_2</urn:apiUrl>
      <urn:applicationId>32XXX75-CXXE-47X7-BX7-A3EXXXX9D</urn:applicationId>
      <urn:email>johndoe@abc.com</urn:email>
      <urn:password>john4doe</urn:password>
      <urn:account>TSTXXXXXX12</urn:account>
      <urn:searchRecord>
         <platformMsgs:searchRecord xmlns:platformMsgs="urn:messages_2015_2.platform.webservices.netsuite.com" xmlns:ns1="urn:relationships_2015_2.lists.webservices.netsuite.com" xmlns:platformCore="urn:core_2015_2.platform.webservices.netsuite.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns1:CustomerSearch">
            <basic>
               <email operator="contains" xsi:type="platformCore:SearchStringField">                  <searchValue>john@smith.com</searchValue>
               </email>
            </basic>
         </platformMsgs:searchRecord>
      </urn:searchRecord>
   </soapenv:Body>
</soapenv:Envelope>

1 comment: