In this article we will show how to connect to the PixEdit Server Core and configure a job ticket to demonstrate document processing and optimization.
PixEdit Server and PixEdit Converter Server hosts a web service interface to allow clients to connect and submit documents for processing and conversion. The interface provides a set of methods to allow clients to create, submit and monitor document processing jobs. Document processing could for instance be OCR, de skew, crop, resize, barcode separation or a simple file format conversion.
In fact, the web service interface is used by the file pickup service ‘PixEdit Input Connector’ and the ‘PixEdit Server Manager’ embedded in the product’s installation.
Before you start
The article requires basic knowledge of programming in C# with Microsoft Visual Studio. Here, we will use Visual Studio 2017, but you should be able to follow along with other versions also. Still, we recommend using VS 2013 or newer.
You should also have the newest version of PixEdit® Server installed in your development environment.
Set up your application
Open up Visual Studio and choose File, New, Project. In the left pane of the New Project dialog, browse to Visual C#, Windows and select it. Select Windows Forms Application in the right pane, choose a name and location for your project and click OK. (In this article, we will call our application MyPixEditServerClientApp.)
Visual Studio prepares your application and eventually, a basic, empty form called Form1 comes up. We rename the form to PSClientApp and set its title to PixEdit Server Client Application.
Connect to PixEdit Server
First make sure PixEdit Server is running, preferable on your development computer.
To access the web service interface, we will need to know its endpoint/URL address. The PixEdit server Core writes this to the Windows Event Viewer when it starts. Like this:
Listening for messages at:
PixEdit Server provides two possible bindings. Net.tcp which is a duplex binding and will work inside your intranet. The http binding is simplex and will work for server/clients outside your intranet. In this tutorial we will go with the net.tcp binding which also allow us to implement some nice callback features creating a very tight and responsive client application.
For Visual studio to detect the PixEdit Web service interface you will need to add a line in PixEditService.exe.config file. The file is located in the installation folder: ‘C:\Program Files\Techsoft\PixEdit Server\Core’
Open the file for editing and locate the following line of code:
<endpoint address="" binding="netTcpBinding" bindingConfiguration = "NetTcpBinding_IPixEditWebService" bindingNamespace="PixEditWebServiceLibrary" contract="PixEditWebServiceLibrary.IPixEditWebService"/>
Just underneath this line, add the following:
<endpoint address="net.tcp://localhost:8080/PixEditWebService/mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
And then restart the ‘PixEdit Server Core’ service to apply the config change.
Now head back to Visual studio. In the solution explorer right click and select ‘Add Service reference’
In this dialog paste the endpoint address and press the ‘Go’ button to discover the PixEditWebService
Then rename the Namespace to ‘PixEditWebServiceReference’ and press ok to add the service reference to the project.
Adding some code to get things up and running
With the web service up and running its time to add some code to our sample client. In the solution explorer right click the form1.cs and select view code.
First, we need to add a reference to the web service
Since we are connecting using the net.tcp binding we also need to implement the callback features in the web service. We need to derive from the IPixEditWebServiceCallback and set the callback attribute, like this:
[CallbackBehavior(UseSynchronizationContext = false, ConcurrencyMode = ConcurrencyMode.Reentrant)]
public partial class PSClientApp : Form, IPixEditWebServiceCallback
Now above the form load handler add an instance of our PixEdit web Service a GUID to hold a user id and job status subscriber id.
(Continued in next post..)