Objective

Enabling SalesForce component using Apex classes to invoke user-defined operations.

Prerequisites

  • Start Fiorano Enterprise Server (FES) and Fiorano Peer Server (FPS)
  • Login to eStudio application
  • Understand the basic menus and perspectives (panels) in eStudio application
  • Create a Salesforce account (use URL: https://login.salesforce.com) and note down the username, password and security token that you receive through e-mail.

Scenario

  • Create an apex class with method to create contact and generate WSDL.
  • Load the generated WSDL to invoke 'createContact' operation using SalesForce component to create a new Contact with lastname value sent as input from Feeder component.

Components Used

Setting up the Example

Downloading WSDL

  1. Login to salesforce.com and click the username on upper-right corner of page. Choose Setup in the dropdown.
  2. In the landing page, under App Setup section, navigate to Develop > Apex Classes, and click New button to open the Apex Class editor.
  3. In the Apex Class editor, provide a valid class and save the Apex Class. Use the below class for the present example:

    global class MyWebService {

        webService static Id createContact(String lastName) {

            Contact c = new Contact(lastName=lastName);

            insert c;

            return c.id;

        }

    }

  4. In the API WSDL page that opens, click Generate WSDL. Save the WSDL opened in web browser to a file.

Configuring SalesForce component

To configure SalesForce component, perform the following action in eStudio:

  1. Add a new Event Process with name 'SalesForce_Apex_Example'.
  2. Drag the SalesForce component present under Bridges category in the Micro Service Palette to the Fiorano Orchestrator.


    Figure 1: Adding SalesForce component to Fiorano Orchestrator

  3. Double-click the SalesForce component in the orchestrator to open Configuration Property Sheet (CPS).

    Icon

    Highlighted properties in Figure 2 are used for configuration, which are explained further.



    Figure 2: SalesForce Component Property SheetUnder 

  4. Connection section, click the WSDL Configuration button and perform the following actions in WSDL Configuration dialog box, and click OK:

    1. Retain Load WSDL From value as 'File'.

    2. Click SalesForce WSDL File Ellipsis button to browse for the downloaded WSDL as explained in the Downloading WSDL section.


      Figure 3: WSDL Configuration

  5. Select 'Yes' from  Is Apex? Drop-down.

  6. Under Call and Addressing section, open Operations window and perform the following actions:

    1. Click the Add button in the Operations dialog box. Operation with default name 'Operation1' gets added.

    2. In the Operations dialog box, click Operation button under WSDL Operation Configuration.

    3. In the Configure dialog box that appears, select the Web Service Operation 'createContact' and click OK.


      Figure 4: Selecting create operationClick 

    4. Operation1 and change the name as 'createContact' in Port Name Prefix field (just to provide a logical/meaningful name).

      Port name prefix represents the prefix that is appended to names of input and output ports. 

      Modifying Port Name Prefix value to 'createContact' for createContact Operation generates createContact_REQUEST and createContact_RESPONSE ports.

      Icon

      Refer Figure 7 to see that input port and output port are generated with these names.


      Figure 5: Modifying Port Name Prefix to 'createContact' for query operation

  7. Click Login Configurations button. In Login Parameters dialog box, click Add and provide user name and password for Salesforce account as mentioned in Prerequisites section and click OK.

    Icon

    While adding password, security token must be concatenated. For example, if password is "password123" and security token is "abcdefgHijklMnopQrstuVwxY", then password entered must be "password123abcdefgHijklMnopQrstuVwxY".



    Figure 6: Providing Login Configurations

  8. Click Finish to save Salesforce configuration. The input and output ports get generated as below:

    1. Input port for create operation - createContact_REQUEST

    2. Output port for create operation - createContact_RESPONSE


    Figure 7: Changed names that reflect in tooltip

Composing the Event Process

To work with the SalesForce component, compose the Event Process by performing the below actions:

  1. Drag a Feeder component and a Display component from Util category in the Micro Service Palette to the SalesForce_Apex_Example Fiorano Orchestrator.
  2. Connect the Feeder component output port to SalesForce component input port and connect the SalesForce component output port to Display component input port.


    Figure 8: Feeder and Display components connected to SalesForce component

  3. Double-click the Feeder component and perform the following actions in Feeder CPS:
    1. In the Message Type Configuration page, retain Output Message Format option as 'XML' and click the Connected Port Schemas button.
    2. In the Connected ports dialog box, select createContact_REQUEST to enable connection between output port of Feeder and input port of salesForce component. Click OK and then click Next.


      Figure 9: Enabling connecting between the Feeder and SalesForce ports

    3. In the Message Details Configuration page, click the Generate Sample button.
    4. Under 'No.of Repeatable elements to be generated' section in the XSD Sample Generation Dialog window, replace max value '3' with '1' so that only one output is generated, and click OK.
    5. In the Body tab, under Default Message editor, remove the soapenv:Header element as it is not required in the present example.


      Figure 10: After changing name in message body
    1. Click Finish to save the Feeder configuration.

Running the Example

To run the SalesForce_Apex_Example, perform the following actions:

  1. Click Check Resource and Connectivity icon (or press ALT+SHIFT+C) to check resource and connectivity.
  2. Click Run Event Process icon (ALT+SHIFT+R) to run the event process. Two windows get launched for Feeder and Display components.
  3. In the Feeder, click the Send button to add the new contact "lastName" to the Salesforce account.

    Icon

    Name can be changed as per your requirement.



    Figure 11: Sending message from the Feeder window

  4. In the Display window, click the second tab at the bottom of the screen to find the ID created for the new contact.


    Figure 12: ID number created for the new contact

  5. Go to salesforce account, click the All Tabs icon on the main menu and then click Contacts which opens Recent Contacts page. Verify that the new contact is added.


    Figure 13: New contact "lastName" added in the salesforce account

References

Please note that the options used in this example are minimum, which helps you to get an overview of the application. To explore the other options present in the SalesForce, Feeder and Display, refer sections: SalesForce, Feeder and Feeder respectively.

Adaptavist ThemeBuilder EngineAtlassian Confluence