Service Interceptor Guide

Is anyone aware of a guide to writing service interceptors?  I have the REST API Documentation which has a small section, but really looking for information on what references I need to include, how to setup the development environment, any actions such as user authentication that need to be completed?

A HelloWorld interceptor tutorial that goes through these would be so helpful if anyone has one...

Parents
  • Hi Everyone,

    After much turmoil we finally managed to implement a “Hello world” interceptor that just writes a text file to hard drive. I hope it helps someone.

    1.     Start a new class library project in VS and name it TestPluginCSharp.

    2.     Copy Tessitura.Services.Common.Interceptor.Client.dll from your Tessitura service (the one that you are building plug-in for e.g. ConstituentService) bin folder to your new class library bin folder and add project reference to it.

    3.     Add a class named TestPluginCSharp and add the following code:

     

    using Tessitura.Services.Common.Interceptor.Client;

     namespace TestPluginCSharp

    {

        public class TestPluginCSharp

        {

            public static PluginData Operation(PluginData pluginData)

            {

                //you'll need the folder set up somewhere on the server for your test file

                System.IO.File.WriteAllText(@"C:\Test\test.txt", "Howdy!");

     

                return pluginData;

            }

        }

    }

    4.     Build your project

    5.     Copy TestPluginCSharp.dll from bin\Debug folder to the service Plugins folder (e.g. ConstituentService\Plugins).

    6.     Open PluginConfig.xml from ConstituentService\Plugins in your VS and add:

    <PluginConfigs>

      <PluginConfig>

        <UriMatch>Constituents/*</UriMatch>

        <Verb>GET</Verb>

        <FullPluginName>TestPluginCSharp.TestPluginCSharp</FullPluginName>

        <PluginPlacement>PRE</PluginPlacement>

      </PluginConfig>

    </PluginConfigs>

     

    Note: no preceding forward slash in UriMatch

     

    7.       Save PluginConfig

    8.       You may need to restart Application Pool for Tess in IIS

    9.       I also have EnablePlugins and ReloadPluginConfig keys set to true in Web.config of the service.

    10.   In Firefox start RESTClient. Set up OAuth Authorisation as per REST_API_Documentation.doc

    11.   Set call method to GET

    12.   Set to address of your service (e.g. https://your_server/Tess/ConstituentService/Constituents/60671061 ) and send request.

    13.   This should result in test.txt being written to the path at step 2.

     

    Good luck!

     

    Sergei Stenkov

Reply
  • Hi Everyone,

    After much turmoil we finally managed to implement a “Hello world” interceptor that just writes a text file to hard drive. I hope it helps someone.

    1.     Start a new class library project in VS and name it TestPluginCSharp.

    2.     Copy Tessitura.Services.Common.Interceptor.Client.dll from your Tessitura service (the one that you are building plug-in for e.g. ConstituentService) bin folder to your new class library bin folder and add project reference to it.

    3.     Add a class named TestPluginCSharp and add the following code:

     

    using Tessitura.Services.Common.Interceptor.Client;

     namespace TestPluginCSharp

    {

        public class TestPluginCSharp

        {

            public static PluginData Operation(PluginData pluginData)

            {

                //you'll need the folder set up somewhere on the server for your test file

                System.IO.File.WriteAllText(@"C:\Test\test.txt", "Howdy!");

     

                return pluginData;

            }

        }

    }

    4.     Build your project

    5.     Copy TestPluginCSharp.dll from bin\Debug folder to the service Plugins folder (e.g. ConstituentService\Plugins).

    6.     Open PluginConfig.xml from ConstituentService\Plugins in your VS and add:

    <PluginConfigs>

      <PluginConfig>

        <UriMatch>Constituents/*</UriMatch>

        <Verb>GET</Verb>

        <FullPluginName>TestPluginCSharp.TestPluginCSharp</FullPluginName>

        <PluginPlacement>PRE</PluginPlacement>

      </PluginConfig>

    </PluginConfigs>

     

    Note: no preceding forward slash in UriMatch

     

    7.       Save PluginConfig

    8.       You may need to restart Application Pool for Tess in IIS

    9.       I also have EnablePlugins and ReloadPluginConfig keys set to true in Web.config of the service.

    10.   In Firefox start RESTClient. Set up OAuth Authorisation as per REST_API_Documentation.doc

    11.   Set call method to GET

    12.   Set to address of your service (e.g. https://your_server/Tess/ConstituentService/Constituents/60671061 ) and send request.

    13.   This should result in test.txt being written to the path at step 2.

     

    Good luck!

     

    Sergei Stenkov

Children
  • Hi Sergei,

    That's a great help, thanks very much!

    I don't suppose you've experimented a bit further and tried to get information from the REST Service?  So in your example, how you would get the consitutent id 60671061.

    Thanks

  • Hi Simon,

    It's all baby steps for me with interceptors. You could search for it I think. When I try executing this search through the REST client it brings back ConstituentSummary containing the ID:

    https://tessxxx.xxx.com/Tess/ConstituentService/Constituents/Search?q=""&type=basic&constituentGroups=individuals&ln=stenkov

    ... and a bit of result:

     

    <City>SYDNEY</City>
    <ConstituentGroup>1</ConstituentGroup>
    <ConstituentType>1</ConstituentType>
    <Country>Australia</Country>
    <FirstName>Sergei</FirstName>
    <ForSort>Stenkov/Sergei</ForSort>
    <FullNameAlias/>
    <Id>60671314</Id>

    You can get the list of resources for the service at address that looks something like:
    https://tessxxx.xxx.com/Tess/ConstituentService
    I am trying to modify the returned data in the interceptor at the moment. I can modify it and save it on the server but when I try to return modified data, it actually returns the original data. Probably just need to figure out how to work with Xml.Linq properly.

     



    [edited by: Sergei Stenkov at 5:06 PM (GMT -6) on 25 Oct 2012]