Jumpstart

Creating Your First Application

This section will take you through the steps of how to build, deploy and consume service with the framework.

There are only four steps involved:

1. Build a service and a service contract

[Service Contract]
Create a project by the name "HelloWorldContract" in Visual Studio.Net
Create a Class by the name "IHelloWorld"

using
System;
using System.Collections.Generic;
using System.Text;
using Acctra.Framework.CustomAttributes;

namespace HelloWorldContract
{
         public interface
IHelloWorld
         {
               // The Greeting Service Contract
               // Enable Audit to collection statistic
               [AuditEnable()]
               string Greeting();
         }
}

[Service Provider and Service]
Create a project  by the name "HelloWorld" in Visual Studio.Net
Create a Class by the name "HelloWorld"

using
System;
using System.Collections.Generic;
using System.Text;
using Acctra.Framework;
using HelloWorldContract;

namespace HelloWorld
{
         public class SayHello: Acctra.Framework.Service.RemoteServiceProvider,
IHelloWorld
         {
                    // You can optionally override the base method and 
                    // give a name to the Service Provider.
                    public override string Name()
                    {
                             return "HelloRemSP";
                    }
                    // You can optionally override the base method
                    // and give description to the Service Provider.
                    public override string Description()
                    {
                             return "Hello Service Remote Provider";
                    }
                    // The Greeting Service
                    public string Greeting()
                    {
                             return "Hello From " + ServiceAgent.Name;
                    }
          }
}

2. Deploy the service on the Remote Server and service contract on the Windows Application Desktop
Compile and Copy the "HelloWorld.dll and HelloWorldContract.dll" to directory where the TopSpinner is installed. 

[Remote Server - Service/Provider Deployment]

Add the following record to your Remote Service Provider Container. For Example, BLogicRemSPC.

Id HelloWorld
PublishUri HelloWorld.srv
Name HelloWorldRemSP
Description Hello World Remote Service Provider
Full Class HelloWorld.SayHello
DLL Helloworld
Mode SingleCall

[Windows Application Desktop - Service Contract Deployment]

Add the following record to your Remote Service Consumer Container  For Example, DemoSCC.

Id HelloWorld
Subscribe Uri HelloWorld.srv
Name HelloWorldService
Description Hello World Service
Full Class HelloWorldContract.IHelloWorld
DLL HelloWorldContract
Consumer Proxy Type Default
Consumer Proxy Full Class N/A
Consumer Proxy DLL N/A

3. Build your User Interface.

Create a project by the name "HelloWorldGUI" in Visual Studio.Net
Create a Windows Form Class by the name "FrmHelloWorld"

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Acctra.Framework.Agent;
using HelloWorldContract;

namespace
HelloWorldGUI
{
         public partial class FrmHelloWorld : Acctra.Framework.BaseWinForm.
FrmBaseForm
         {
               public FrmHelloWorld()
               {
                       InitializeComponent();
               }
               private void ButPressMe_Click(object sender, EventArgs e)
               {
                       MessageBox.Show(GetHelloWorldService().Greeting());
               }
               private IHelloWorld GetHelloWorldService()
               {
                       string hwContainer = ServiceAgent.GetServiceAgentData("HelloWorldSCContainer");
                       string hwServiceId = ServiceAgent.GetServiceAgentData("HelloWorldServiceId");
                       return (IHelloWorld)ServiceAgent.GetServiceContainerService(hwContainer, hwServiceId,  "RemoteServiceConsumer");
               }
          }
}


4. Deploy the User Interface to Windows Application Desktop

Compile and Copy the "HelloWorldGUI.dll" to directory where the TopSpinner is installed. 

Create the Menu Items

Goto the Designer, select Application Menu. 

Add Record for Level 1

Code firstservice
Display First Service

Add Record for Level 2

Code helloworld
Display Hello World

Add Record for level 3

Code greeting
Display Greeting
Link Form Select Custom Form and Enter "HelloWorldGUI:HelloWorldGUI.FrmHelloWorld"

Goto Administrator, select user(s) i.e demo then select Access Control and grant access right by selecting the "Enable" Checkbox for each organization.

Goto the Service Agent, select the Service Agent Data Tab,

Enter the following Records

Parameter HelloWorldSCContainer
Value DemoSCC or Id of your Remote Service Consumer Container

Parameter HelloWorldServiceId
Value HelloWorld

Test the First Service

Exit and Lanuch again the Windows Application Desktop or restart the Service Agent.
Click the greeting item, you should see the FrmHelloWorld form shown. Press the "Press Me" button.

A Message Box will display the message like "Hello From " + Service Agent Name of your Remote Server.