Exposing WCF services Utilizing Synergy .NET Interop


In this post I will explain just how a WCF service can be created Employing a Synergy .NET Interop undertaking. In my earlier post I explained how to use xfNetLink .NET to make a WCF service, which provided an easy way to produce a WCF service for programmers who were using xfNetLink .NET and xfServerPlus. Today I wish to show another approach that’s somewhat similar in nature to you, but which does not call for the continued utilization of xfNetLink .NET along with xfServerPlus in solution that is closing. Of course this may not be exactly what you need if your Synergy server is still a system.

compare asp net hosting

This is actually the fourth in a series of posts A variety of ways Synergy developers can utilize of Windows Communication Foundation (WCF) if building their software. The articles in the series are:


Building Distributed Apps with Synergy/DE along with WCF


Exposing WCF Services with xfNetLink .NET


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


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


Self-Hosting WCF Services


Exposing WCF services with Synergy .NET


What is Synergy .NET Interop


Before we get started we make sure you understand what a Synergy .NET Interop project is. In a nutshell an Interop job is a way of making a .NET assembly comprising a variety of classes, in which the external interface of these courses is defined by a collection of classic Synergy xfServerPlus procedures, along with the Synergy records which are referenced with the parameters of those methods. The concept is that the classes exposed by the assembly possess the specific same external interface which would be generated if the same approaches were defined at a Method Catalog and exposed via xfServerPlus and xfNetLink .NET. So the use case for an Interop assembly would be to enable developers with programs which use xfNetLink .NET and xfServerPlus to variable out those tools causing a pure .NET program.


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


Let’s get started. Here’s how to take action. Keep in Mind, an Interop project allows you to exhibit a Synergy .NET assembly based on a lot of more traditional Synergy Procedures and records, however there are some prerequisites:


The Synergy approaches must Use the introduced So that the external port of the technique is defined within the code Documentation and attributes remarks. The Interop job doesn’t use a Synergy Method Catalog. To find out more on this you can refer to a blog post which I wrote back in 2009 known as Wave Goodbye to the MDU.


Methods have to be defined in a repository, but this would have been the situation if you used xfServerPlus.


Normally the information files that are accessed from the methods Should be moved into the Windows server so that the files could be accessed locally, in which the WCF service is going to soon be hosted. In case your data files will need to stay on a non-Windows server of course you can use xfServer to access the documents remotely.


You will Have to Have a copy of the source code to the Synergy methods available on the Windows development platform in which you are currently utilizing Synergy .NET.


These are the steps that you’ll need to complete in order to Create a Synergy .NET Interop assembly from your existing Synergy techniques and repository construction definitions:


Create an Interop Project


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



In the menu, choose File > New > Project.


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


Put the name and place of the job as necessary (here I’m naming the job MyInteropAssembly and placing the location to my call:temp folder).


Click on the OK button to make the project.




When you create an Interop job a new source document called SynergyRoutines.dbl is automatically included in the project. This file comprises various utility routines which are used by the interop project in order to expose the interface which xfNetLink .NET does. You should not need to be concerned with this code, and should not change it. Simply close the document.


Insert Synergy Method Resource Documents


Having created the Interop job the next step is to add The origin code to your Synergy approaches into the undertaking. Bear in mind that the methods that you incorporate in an Interop endeavor are Conventional Synergy subroutines and functions which contain whatever xfMethod and xfParameter attributes are needed in order to completely document the external port of these procedures within the source documents.


When creating an Interop project I 9, imageFor clarity Like to add my system source documents inside a folder within the project, and I generally name the folder”Tactics”. This is completely optional though.


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


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


Right-click on your new Methods folder and from the circumstance Menu select Insert > Existing Item….


Use Of your Synergy strategy routines, choose all of them, and then click on the Add button to add the patterns.


In Solution Explorer your project should look something Such as the image .


Before we proceed let me make a few things clear. Firstly it is vital you know that if you add existing files to a job using Insert > Present Item, these files are COPIED to your folders. If you prefer to render the source files in their current location then it is possible to utilize Insert > Reference Existing Item.


The thing that you Want to understand is that at the Example I am using here the nature of the methods that I am using is comparatively straightforward, and also the methods don’t have external dependencies on other patterns in libraries, so don’t use include documents, etc.. You are going to need to determine how best to solve these dependencies if your approaches do have these dependencies.


Set Environment Variables


It is likely that you will need to put some environment Variables in order for your code. It is nearly certain that you will want to at least set the environment variables that enable your repository to be found and accessed, and in the event of this code that I’m using, in runtime a environment variable named DAT can be used to define the location of this information files that are obtained by the code.


Synergy .NET Growth projects include the capability to place Environment variables in the development environment through properties of this job:


In Solution Explorer, right click your job and out of The context menu select Properties.


From the project properties dialog, to the side, pick The tab called Environment Variables.


Set whatever environment factors are needed in order for Your code to compile and run.


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


Close to the project properties dialog.


In the Event of the code I’m using for this instance I needed To set the following environment variables:




The tools from Synergy .NET also honour the same Mechanisms for setting environment variables on the Windows platform as Synergy. Therefore, if the environment variables that you want are already present on your system environment, or will be provided from the synergy.ini or even synuser.ini documents then you certainly won’t have to set them .


Construct an Interop Assembly


You should now have the ability to construct your interop meeting.


In Solution Explorer, right-click on your job and from The context menu select Build.


Check the output , you should find something similar to this:


Configuration: Debug Any CPU ——

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


ImageIf your assembly failed to build then you will need to Resolve any mistakes you might have before you move. The cause for errors at this stage will be.


Check out what occurred in your project. When You Look in Solution Explorer you’ll notice that a folder named GeneratedCode was created, and a few new source documents were added into the folder. These files are at the center of how Interop projects do the job.


The method source files you added into the job, in The Approaches folder, were functions and Conventional Synergy subroutines. An Interop project’s job would be to expose the functionality of those methods in precisely the same way that xfNetLink .NET’s GENCS utility does, also GENCS creates .NET classes that reflect the Synergy procedures, and the information structures exposed by those Synergy procedures.


The Interop project basically does the same thing, except Where GENCS created C# code that uses xfNetLink .NET and xfServerPlus to predict the Synergy techniques, the Interop project generates Synergy .NET code which calls the Synergy approaches right.


In my example used From the code the Synergy approaches that I Added to the project were part of an interface named”SynergyServer”. This was characterized by the xfMethod features that were present in each of the source documents I included to the project. You’ll notice that your GeneratedCode folder today includes a resource file named SynergyServer.dbl, and if you were to look in the source document you would observe that it includes a class called SynergyServer, which then includes procedures named GetAddressForUpdate, GetAllCustomers and so forth. These approaches correspond to the Synergy techniques that I initially included in the project.


Additionally you will notice that the GeneratedCode folder Also includes several source files which represent the definitions that are exposed by the parameters of my approaches. For a course has been created by the interop project. These classes are named so on, Address_type, Touch and Address.


But if you were to look Been generated into the GeneratedCode folder that you might see that these generated classes do not contain some ServiceContract, DataMember, DataContract or OperationContract attributes. In other words, the classes can not currently be exposed via WCF.


Note: You shouldn’t make modifications Folder, because this code will be recreated each time you construct the project.


Expose a WCF Service


Like I discussed in a previous article, in order for lessons To be vulnerable through WCF it is necessary to apply several attributes to all those courses:


Nature of Item Required Attribute


Class containing callable methods ServiceContract


Callable method OperationContract


Class specifying a data construction DataContract


Available manhood


In an Interop endeavor, these characteristics can be Added into the generated classes by enabling a project choice referred to as”Generate WCF Assets”.


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


In the project properties dialog, to the side, pick Interop was named by the tab.


Check the Generate WCF Contracts option.


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


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


Close the project properties dialog.


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


Check the output window and make Sure your meeting Built properly.


Notice: The default behaviour of generating parameters out as Ref is to maintain compatibility but you would always need output parameters described as kind out when exposing a WCF support to another client application.


Take a look GeneratedCode folder. You should observe that both the OperationContract, ServiceContract, DataContract and DataMember characteristics are present as necessary.


Host the Service


That’s it, you simply employed a Synergy. NET Interop project to Define and make a WCF service. Obviously before you are able to do anything with all the service you will have to host it somewhere. One alternative is to host the service in an ASP.NET Web Program as explained in my earlier post.


But, sometimes developers do not want to have to setup And maintain an IIS web server to host a WCF services. Fortunately there are Other ways of hosting a WCF service that is going to be, and which don’t need IIS The subject of the next post in this sequence.