Creating AddIns using Connect Web Services (CWS)

While the AddIn Framework provides a decent amount of information about the site you're connected to it often isn't enough to do anything too complicated.

This tutorial will demonstrate how to connect to CWS through the GlobalContext and retrieve account information about the current user. While a slightly contrived example it also provides information not available through the AddIn Framework.

  1. Start by setting up your project as described in previous tutorials I'm going to gloss over the creation of the add-in and focus on the changes related to enabling SOAP. See Hello World Workspace Component for a project setup tutorial.
  2. Add a service reference to the RightNow WSDL. In this example I use the WSDL hosted on the RightNow site, but in general you should use the one associated with your site. The URL is http://site/cgi-bin/interface.cfg/services/soap?wsdl
  3. Before creating the Service Reference click the advanced button and enable Async operations
  4. Creating the RightNowSoapClient class:
    1. You'll need to include the namespace you specified when generating your Service Reference. In this case I added
      using CWS_AddIn.RNT_SOAP;
    2. Implement a singleton using Lazy<>. A singleton is used to facilitate multiple add-ins reusing the same connection while also ensuring thread safety via the Lazy class. I often create a status bar add-in to host my CWS connection and then let other add-ins access the connection via the singleton accessor. You can even set up the status bar add-in to show the status of the connection, helpful for debugging and informative for impatient users.
    3. Initialize the connection from the global context

      Line 10: Sets up the connection to use the url for the current site
      Line 28: Use the session token for the current user for all requests
    4. I often expose a number of standard helper methods when I create the SOAP client class. RNObject Get(RNObject obj); and etc, but for the sake of simplicity I am accessing the SOAP client directly in this example.
  5. Init the client when the add-in loads. Update the Initialize method to pass the Global Context into the soap client
  6. At this point your project is set up to access RNT data via CWS, however the profile for your user needs to be updated (potentially) to allow Session level access to CWS. In the CX console go to Configuration->Staff Management->Profiles. Open the appropriate profile. Select the Permissions button in the ribbon and check the box for Session Authentication under Public SOAP API
  7. Using the connection we can now pull down the account that is currently logged in and display related data.

    Start by creating a template object, populating the ID and passing it in to GetAsync() then listen for the response and, after verifying that it came back properly, bind the resulting value to the UI
  8. This add-in can be placed on any workspace and once the workspace data has loaded it will display information about the current agent

Full source is available on Bitbucket under / AddIns / CWS AddIn /

Comments

I am new Rightnow developer and would like to get this source code to learn more about integration through CX Add-in.

Thank You

Jordi Merejo

source can be found on bitbucket at https://bitbucket.org/45north/cx-developer-tutorials/src under / AddIns / CWS AddIn /

Zircon - This is a contributing Drupal Theme
Design by WeebPal.