An Eplan application has the possibility to start with a build-in web server and call actions remotely via the HTTP protocol. Thus, an application can be written using a client-server model. This approach offers several benefits:
Before Eplan web service can be used, you need to make sure that the port for the web service is activated. The EplanUrlActivatoru.exe tool can be used for this purpose. By default it can be found under C:\Program Files\EPLAN\Platform\<version>\Bin.
You can filter the ports using the Only display Eplan services checkbox. To use the Eplan web service, there must be an entry here for EPLAN_WebService1. If there is no such entry yet, you need to create one using the star icon. The port relevant for the web service is activated by this entry. You can also change the port number. By default, the port is set to 80. If this port is already in use elsewhere, you can set another free port here. Edit an entry by clicking the pencil symbol. A port is only activated once at the operating system level.
In order to enable the Eplan web services, please run the Eplan platform application with the webservice parameter, for example:
w3u.exe /webservice:http://localhost/EPLAN_WebService1
The parameter value is the full URL with the hostname and the web service name. The communication is possible only via HTTP protocol. HTTPS is not supported yet. If you don't specify the port, it is 80 by default. It's also possible to call it without the full URL but with the port number:
w3u.exe /webservice:80
The client application can use the following endpoints:
| # | Endpoint | HTTP method | Description | Returns |
| 1 | /ping | GET | Server availability check | ok (as XML) and status code 200 if the server is running |
| 2 | /callAction?s=<action_name_with_parameters> | GET | Runs an action (with parameters) | 0 if the action call returns FALSE In this case, system error messages are also added. 1 if the action call returns TRUE |
The following examples show how to use Eplan web service.
http://localhost/EPLAN_WebService1/callAction?s=XPartsManagementStart
http://localhost/EPLAN_WebService1/callAction?s=check%20%2FTYPE%3APROJECT
The feedback can also be passed by setting the _result parameter via the action. It is then passed to the return content. Please take a look at the following example.
First, we need to define an action:
| C# |
Copy Code
|
|---|---|
public class Action1 : IEplAction { public bool Execute(ActionCallingContext ctx) { ctx.AddParameter("_result", "Action1 was called successfully"); return true; } } |
|
The client application can then execute the action like this:
| C# |
Copy Code
|
|---|---|
using (var client = new System.Net.Http.HttpClient()) { var response = client.GetAsync("http://localhost/EPLAN_WebService1/callAction?s=Action1"); Console.WriteLine(response.Result.Content.ReadAsStringAsync().Result); } |
|
The output will be the following:
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">1:Action1 was called successfully</string>