Eplan Platform API
Eplan API / User Guide / API Framework / Using Eplan in other applications / Eplan Web Service
In This Topic
    Eplan Web Service
    In This Topic

    Introduction to Eplan Web Service

    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:

    • The client and server parts are only loosely coupled. This means they can be written in a different languages.
      In other words, the client can use a different programming environment than the server does. They can use any version of .NET or any 3rd party libraries.
    • The client can perform operations asynchronously. Actions are queued.
    • The client can be remote or local.

    Preparations

    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.

     

    This message boy appears, when you run the very simple script. 


    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.

    Server

    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

    Client

    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

     

    Eplan Web Service Code Examples

     

    The following examples show how to use Eplan web service.

    Run Parts Management

        http://localhost/EPLAN_WebService1/callAction?s=XPartsManagementStart

    Runs action with parameters (project check)

        http://localhost/EPLAN_WebService1/callAction?s=check%20%2FTYPE%3APROJECT

    How to get the feedback from the server

    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>

     

    Apart from the Eplan web service, it is possible to create a user-defined web server in an Eplan add-in.
    The client-server communication must then be defined by the developer.