Exposing WCF services Utilizing Synergy .NET Interop

In this post I will explain how the WCF service can be created Using a Synergy .NET Interop project. In my earlier post I explained how to utilize xfNetLink .NET to make a WCF service, which provided an effortless method to produce a WCF support for developers who were using xfNetLink .NET and xfServerPlus. Now I want to show you an alternate strategy that is somewhat similar in nature, but which does not require the use of xfNetLink .NET along with xfServerPlus in solution that is closing. Of course this may not be exactly what you need if your Synergy host is a system that is non-Windows.


Here is the fourth in a series of articles Regarding this Many ways that Synergy developers can use of Windows Communication Foundation (WCF) when building their software. The articles in the series are:


Building Distributed Programs with Synergy/DE and WCF


Exposing WCF Services using xfNetLink .NET


Hosting WCF Services in an asp net hosting uk .NET Web Program


Exposing WCF services utilizing Synergy .NET Interop (this article )


Self-Hosting WCF Services


Exposing WCF services using Synergy .NET


What’s Synergy .NET Interop


Before we begin we make sure you know exactly what a Synergy .NET Interop project is. In a nutshell an Interop job is a means of making a .NET assembly comprising various classes, in which the outside interface of these classes is characterized by a set of classic Synergy xfServerPlus techniques, along with the Synergy records that are referenced by the parameters of these approaches. The idea is that the classes exposed by the assembly have the specific same external port which would be created if those methods were defined in a Method Catalog and subjected via xfServerPlus and xfNetLink .NET. So the usage case for an Interop meeting is to allow developers with existing applications that use xfNetLink .NET and xfServerPlus to factor out those tools from their solution, causing a pure .NET application.


In Precisely the Same manner that GENCS has an optional –W control line Switch which basically transforms the .NET assembly into a WCF assistance, the Synergy .NET Interop project has a job option which does the same item.


So let’s begin. Here is how to do it. Bear in Mind, an Interop project allows you to expose a Synergy .NET meeting based on a couple of more traditional Synergy Techniques and records, however there are some prerequisites:


The Synergy methods must make use of the recently introduced So that the external port of this procedure is completely defined inside the code documentation and attributes comments. A Synergy Method Catalog does not be used by the Interop project. You can refer to a blog post which I wrote back into 2009 known as Wave Goodbye to the MDU.


The records which are referenced by the parameters of the This could have been the situation if you used xfServerPlus, although methods have to be defined at a repository.


Generally the information files which are obtained from the methods In which the WCF service will be hosted, so that the files can be retrieved 23, should be moved to the Windows server. If your data files will need to stay on a server of course you could utilize xfServer to get the documents remotely.


You will need to have a copy of the source code for the Synergy methods available on the Windows development platform at which you’re using Synergy .NET.


These are the measures that you’ll need to complete in order to Produce a Synergy .NET Interop meeting from your current Synergy procedures and repository construction definitions:


Create an Interop Project


Step one in the process is to create a Synergy .NET Interop Assembly job:



In the menu, select File > New > Project.


In the Installed Templates list select Synergy/DE > Interop.


Put place and the name of the new project as required (here I am naming the project MyInteropAssembly and setting the location for my call:temp folder).


Click on the OK button to make the new job.




When you create an Interop project a source file called SynergyRoutines.dbl is automatically contained in the project. This file comprises various utility routines that are used by the interop project so as to expose the interface that xfNetLink .NET does. You shouldn’t have to be concerned with this particular code, and shouldn’t change it. Close the document.


Add Synergy Method Source Files


Having created the Interop project The origin code into the undertaking for your Synergy methods. Do not forget that the methods that you include in an Interop job are Conventional Synergy subroutines and functions that contain whatever xfMethod and xfParameter features are needed to be able to completely record the external interface of these processes within the source documents.


When creating an Interop endeavor I 9, imageFor Like to add my strategy source documents in a folder within the project, and that I generally name the folder”Tactics”. This is entirely optional however.


In solution Explorer, right-click on your Interop job And from the context menu choose Insert > New Folder.


Change this folder’s name to press and Approaches enter.


Right-click on your Approaches folder and from the context Menu select Add > Existing Item….


Use Of your Synergy process routines, pick all of them, then click on the Insert button to bring the routines.


In Solution Explorer your job should look something Like the image on the right.


Before we move on let me make a few things clear. Primarily it is imperative that you know that if you add existing files to a project using Add > Existing Item, those documents are COPIED into your project folders. If you prefer to leave the source files in their existing location then you can use Add > Reference Present Item.


The second thing that you need to understand is that in the Example I am using here the nature of the methods that I am using is comparatively easy, and also the methods don’t have external dependencies on different routines in libraries, so do not use include documents, etc.. You are going to need to choose how best to solve these dependencies, if your strategies have such dependencies then.


Set Environment Variables


It is Very Likely You Will need to put some environment Variables in order for your code. It is almost certain that you’ll need to set the environment variables that permit your repository to be located and accessed, and in the event of the code that I’m using, at perform an environment variable named DAT is used to specify the location of these data files which are obtained by this code.


Synergy .NET development projects include the ability to place Environment variables in the development environment through properties of this project:


In Solution Explorer, right click your project and from The context menu select Properties.


In the project properties dialog, on the left side, pick Environment Variables were named by the tab.


Establish whatever environment variables are needed in order for Your code to compile and operate.


Save the changes by selecting File > Save in the menu.


Close to the project properties dialog.


In the Event of this code I’m using for this particular case I needed To place the following environment variables:




By the way, the resources in Synergy .NET also honor the same Mechanisms for setting environmental factors on the Windows platform as Synergy. So if the environment variables which you need are already existing on your system environment, or are provided from the synergy.ini or synuser.ini files then you won’t have to place them .


Build an Interop Assembly


You should be able to build your interop assembly.


In Solution Explorer, click on your job and out of The context menu choose Build.


Examine the output window, you should see something like this:



========== Build: 1 triumphed or upward, 0 failed, 0 skipped ==========


ImageIf your meeting failed to construct you’ll have to Solve any mistakes you might have before you proceed. The most probable cause for errors at this point will be outside dependencies that are not catered for.


Check out what happened in your project. If you look in Solution Explorer you will observe that a new folder called GeneratedCode was created, and a few new source documents have been added to the folder. These new documents are at the center of Interop endeavors work.


The process source files you added into the project, in The Approaches folder, were Synergy subroutines and functions. The task of an Interop job would be to expose those methods’ performance in exactly the same manner that xfNetLink .NET’s GENCS utility does, and GENCS creates .NET courses that represent the Synergy methods, along with the information structures.


The Interop project basically does the Exact Same thing, except Where GENCS created C# code that utilizes xfNetLink .NET and xfServerPlus to call the Synergy procedures, the Interop project generates Synergy .NET code that calls the Synergy approaches.


From the code used in my case the strategies that I Added to the project were all part of an interface called”SynergyServer”. This was defined by the xfMethod features that exist in each of the source files I included to the project. You will find that the GeneratedCode folder now contains a resource file named SynergyServer.dbl, and if you should look in the source document you would observe that it comprises a category named SynergyServer, which in turn comprises methods named GetAddressForUpdate, GetAllCustomers and so on. These approaches correspond to the Synergy techniques I originally included in the undertaking.


You also will notice that the GeneratedCode folder Also includes source files that represent the listing definitions that are exposed by the parameters of its own processes. For the interop job has produced a course. These courses are called Address, Address_type, Contact and so Forth.


However, if you were to look Been generated DataContract, OperationContract or DataMember features. To put it differently, the classes can not now be exposed via WCF.


Note: You shouldn’t make changes Folder, as this code is going to be recreated whenever you build the project.


Like I briefly discussed in a previous article To be vulnerable using WCF it is necessary to apply different attributes to all those classes:


Nature of Item Required Characteristic


Class containing callable methods ServiceContract


Callable method OperationContract


Class specifying a data structure DataContract


Accessible member


Within an Interop project, these characteristics can be mechanically Added into the generated classes by enabling a project choice known as”Create WCF Assets”.


In Solution Explorer, right-click on your job and choose Properties.


At the project properties dialog, on the side, pick Interop was called by the tab.


Assess the Generate WCF Contracts option.


It’s also a good idea to place out the Generate Parameters property to out rather than the default value of”ref”.


Save your changes by selecting File > Save from the menu.


Close the project properties dialog.


In Solution Explorer, right-click in your project and out of The context menu select Build.


Examine the output and make sure that your meeting Built correctly.


Note: The default behavior of generating parameters out as Ref is to maintain compatibility with that which GENCS does by default, but you would always need output parameters defined as type 34, when exposing a WCF support.


Take a look GeneratedCode folder. You should notice that the DataContract, OperationContract, ServiceContract and DataMember attributes exist as necessary.


Host the Service


That is it, you simply employed a Synergy. NET Interop project to Define and make a WCF services. Of course before you can do anything with all the service you will have to host it somewhere. 1 choice is to sponsor the service in an ASP.NET Web Program as explained in my earlier article.


Sometimes developers do not Want to setup And keep an IIS web server to host a WCF service. Luckily there are Other methods of hosting a WCF service that don’t require IIS, and that will be The subject of the following post.