Remote Connection to a GisLink Add-In Application (WCF)

You can connect remotely to the SIS Desktop desktop via Windows Communication Foundation (WCF).

The GisLink Add-In application will act as a WCF service.

GisLink processes will be written as delegates into this service. The service capabilities can be fed into a WCF client inside a .NET application.

Cadcorp SIS Desktop and the Windows Communication Foundation require the .NET framework 4.

To TakeOver control of the SIS Desktop process the WCF service should be hosted on a modeless Windows form.

This form may be invisible and can be started from the GisLink constructor.

Public Sub New(ByVal SISApplication As SisApplication)

    APP = SISApplication

    WCFserviceform = New ServiceForm

    WCFserviceform.Show()

End Sub

Public delegates must be declared in the Windows form class which hosts the WCF service.

Public Class ServiceForm

   Public Delegate Sub DoCommand(ByVal acom AsString)

   Public Delegate_DoCommand AsDoCommand

   Public Delegate Function DoCommandF(ByVal acom AsString) AsString

   Public Delegate_DoCommandF As DoCommandF

Delegate addresses and the WCF service host itself are declared inside the form constructor.

Private Sub ServiceForm_Load(sender As System.Object, e As System.EventArgs) HandlesMyBase.Load

   Try

        selfHost = New ServiceHost(GetType(WCFserver), New Uri("http://localhost:8000/WCFserver"))

        selfHost.AddServiceEndpoint(GetType(IRemoteGisLink), New WSHttpBinding(), "RemoteGisLink")

       Dim smb AsNew ServiceMetadataBehavior()

        smb.HttpGetEnabled = True

        selfHost.Description.Behaviors.Add(smb)

        selfHost.Open()

   Catch ce As CommunicationException

        MsgBox("An exception occurred: {0}", ce.Message)

        selfHost.Abort()

   End Try

    Delegate_DoCommand = New DoCommand(AddressOf DoCommand_Sub)

    Delegate_DoCommandF = New DoCommandF(AddressOf DoCommandF_Function)

End Sub

The WCF service host should be closed when the form which hosts the service is disposed.

Private Sub FormClose() HandlesMe.Disposed

    selfHost.Close()

End Sub

Public Sub procedures and Functions must be written for each declared delegate.

Public Function DoCommandF_Function(ByVal acom AsString) AsString

   Dim SISresponse AsString

   Try

       Loader.SIS.DoCommand(acom)

       Loader.SIS.Dispose()

       Loader.SIS = Nothing

        SISresponse = "Success"

       Return SISresponse

   Catch ex As Exception

        SISresponse = ex.ToString

       Return SISresponse

   End Try

End Function

If WCF service is run (from inside the SIS Desktop process) it is possible to generate app.config and proxy files using ServiceModel Metadata Utility Tool (Svcutil.exe).

These files must be added to the WCF client project in order to call delegates through a WCF service.