You can create your own custom WCF gateway by using the WCF Service Library option in the <Technology Folder Name> Property Pages window. This builds a basic WCF Service that can transmit requests and receive responses in a synchronous manner. It does not expose the full Access Layer API. Therefore, it does not implement callbacks, nor does it require a full-duplex asynchronous session.
The WCF Service Library technology option generates two projects
A WCF Service library project that defines a WCF service. The WCF service can be exposed through various hosting options, such as an IIS Web application, a Windows Service, or a Windows Self-Hosting Service.
A WCF Service Gateway project that allow you to host the Service Library.
Note: If you do not want to use this Service Gateway, then you can choose to host the Service Library in the Service Gateway supplied with the AB Suite software.
Due to its relatively simple interface, this WCF Service is ideal for use by remote clients where callbacks and duplex channels cannot be used (for example, mobile devices, Java, Web Service client, and others). It does not allow you to execute colon commands and other asynchronous operations, such as running reports or receiving unsolicited messages. However, with these client types, such operations are typically not required.
To create a custom service library, perform the following:
Create an AB Suite Client Framework application.
Right-click the Technology folder, and then select Properties.
The <Technology Folder Name>Property Pages window appears.
From the Client Technology list, select WCF Library (Windows Communication Foundation).
Click OK.
This creates two projects in the solution
The WCF Service library project named <SegmentName>.<FolderName>Library (for example, Sample.MyWCFServiceLibrary).
This project creates the WCF Service Library that can be hosted.
A default WCF Hosting project named <SegmentName>.<Foldername>Gateway (for example, Sample.MyWCFServiceGateway).
This project creates hosting application that hosts your service library. It can be run as an application or can be installed as a Windows Service.
Refer to the Agile Business Suite Installation and Configuration Guide for more information on installing the WCF Hosting application as a Windows Service.
In the Solution Explorer window, right-click the <Project Name>.<FolderName>Library project, and then select Start New Instance.
The WCF Service Host application starts and displays the generated service being hosted (for example, Sample.MyWCFServiceLibrary.SampleMyWCFService). The Microsoft WCF Test Client window also appears, which allows you to discover the hosted service and perform operations on it for testing purposes.
To connect a client with this gateway, perform the following:
Create an application in Visual Studio.
Note: You can create a console application, WPF application, Windows Service application, Windows Store application, or others as required.
Right-click the project, point to Add, and then click Service Reference from the context menu.
The Add Services References dialog box appears.
In the Address box, enter the endpoint address. You can either discover the endpoint address or copy it from the left pane of the WCF Test Client window
Click Go.
The methods available as part of the endpoint are listed in the Operations box.
In the Namespace box, enter a name; for example, SampleRef.
Click OK to close the Add Services References dialog box.
The name you entered in the Namespace box appears under the Service Reference folder in Solution Explorer window.
Double-click the Service Reference to open the Service definition in the Object Browser window
Add code in your application class to create and use the service. For example, the following code is executed when a button is pressed in a WPF Client application:
private void Button_Click(object sender, RoutedEventArgs e) { // Create an instance of the Service SampleMyWCFClient svc = new SampleMyWCFClient("WSHttpBinding_ISampleWcfService”);
or
SampleMyWCFClient svc = new SampleMyWCFClient("BasicHttpBinding_ ISampleWcfService”); MessageData messageData; // Perform the Connect operation on the service messageData = svc.Connect(); // The fireup ispec is a type of MENUmodel MENUModel menu = (MENUModel) messageData.Data; menu.ACTION2 = "PROD"; // Navigate to the PROD ispec // Transmit the MENUModel messageData = svc.Transmit(menu); PRODModel prod = (PRODModel)messageData.Data; prod._UserMAINT = "FIR"; // Set the UserMaint field // Tranmit the PRODModel messageData = svc.Transmit(prod); prod = (PRODModel)messageData.Data; // Extract the Name information for the first record string name = prod.NAM; // Check the Status information string status = messageData.Status; }
In your logic, you can call the operations that the service provides.
In the example above
The service is created.
(WSHttpBinding_ISampleWcfService) and (BasicHttpBinding_ISampleWcfService) are two endpoints for service reference. The interface reference, ISampleWcfService is I<SegmentName><webservice foldername>.
The Connect() operation is performed that returns the fireup ispec.
The MENUModel is populated and sent using the Transmit() operation.
The PROD ispec is returned and the PRODModel is populated.
The PRODModel is sent using the Transmit() operation and the data is extracted from the information returned.
The Status message is also extracted from the returned MessageData.