Featured image for: How to configure Siemens .NET Client Library for SIMATIC S7 Webserver API
Read Time: 4 minutes

The Siemens .NET Client Library for the SIMATIC S7 Webserver API (package nameSiemens.Simatic.S7.Webserver.API) lets .NET applications talk directly to the built-in web server on SIMATIC S7-1200 and S7-1500 PLCs. It wraps the PLC’s JSON-RPC 2.0 interface over HTTPS so you do not have to craft raw HTTP requests, manage GUIDs, or parse responses yourself.

This guide shows a complete, practical setup that remains valid across current PLC firmware. It also incorporates the security fixes released in library version3.3.62and later (addressing path-traversal and sensitive-information issues highlighted in the November 2026 CISA advisory). Follow the steps in order and you will have a working client that can browse API methods, manage web applications, and interact with PLC data.

What You Need

  • A computer with the.NET SDK(8.0 or later recommended) or Visual Studio 2022+
  • A SIMATIC S7-1200 or S7-1500 PLC with the web server enabled and a reachable IP address
  • TIA Portal (for creating a web-server user and downloading the configuration)
  • Network connectivity between the development machine and the PLC
  • Basic familiarity with C# and NuGet

Step-by-Step Guide

Step 1: Prepare the PLC Web Server

In TIA Portal, open your project, select the CPU, and enable the web server under the properties. Assign a fixed IP address on the PROFINET interface that will host the web server.

Create a dedicated user (for exampleApiUser) with a strong password and grant only the rights required by your application. The defaultAnonymoususer (previously called Everybody) exists with an empty password, but it is intentionally restricted and should not be used for production.

Download the hardware configuration to the PLC. Confirm the web server responds by browsing tohttps://in a browser and accepting the certificate warning once.

Step 2: Create a New .NET Project

Open a terminal and create a console application (or use Visual Studio’s New Project wizard):

dotnet new console -n S7WebserverClient
cd S7WebserverClient

This produces a clean .NET project that targets a modern runtime. You can later change the target framework if you need .NET Framework 4.8 compatibility.

Step 3: Install the Latest Secure Version of the Library

Add the official NuGet package. Always specify a version of3.3.62 or higherto include the recent security fixes:

dotnet add package Siemens.Simatic.S7.Webserver.API --version 3.3.92

Alternatively, in the Visual Studio Package Manager Console:

Install-Package Siemens.Simatic.S7.Webserver.API -Version 3.3.92

The package supports .NET Framework 4.8, .NET Standard 2.0, and .NET 8/9/10. Restore packages and build once to verify the reference is correct.

Step 4: Configure Certificate Validation

PLCs present self-signed certificates that .NET rejects by default. For development you can temporarily accept all certificates. In production, install the PLC certificate into the trusted root store instead.

Add the following near the top of your Program.cs (or equivalent entry point) before any connection attempt:

using Siemens.Simatic.S7.Webserver.API.Services;

// Development only – accept all certificates
ServerCertificateCallback.CertificateCallback = (sender, cert, chain, errors) => true;

For pure .NET Framework 4.8 projects useServicePointManager.ServerCertificateValidationCallbackinstead. Never leave the “accept-all” callback in production code.

Step 5: Establish a Connection and Authenticate

The library’s main entry point isApiStandardServiceFactory. It creates anApiHttpClientRequestHandlerthat manages the HTTPS session, authentication, and request lifecycle.

using Siemens.Simatic.S7.Webserver.API.Services;

var factory = new ApiStandardServiceFactory();
var requestHandler = await factory.GetApiHttpClientRequestHandlerAsync(
    "192.168.0.10",   // PLC IP address
    "ApiUser",        // username created in TIA Portal
    "YourStrongPassword!");

The handler automatically performs the login and stores the session token. Subsequent method calls reuse that session until it expires or you dispose the handler.

Step 6: Verify Connectivity with Api.Browse

CallApiBrowseAsyncto list every method the PLC currently exposes. This is the quickest way to confirm that authentication and certificate handling succeeded:

var browseResponse = await requestHandler.ApiBrowseAsync();
foreach (var method in browseResponse.Result)
{
    Console.WriteLine(method.Name);
}

You should see method names such asApi.Browse,WebApp.Browse,PlcProgram.Read, and others. If the call throws, check the troubleshooting section below.

Step 7: Perform a Useful Operation (Example: List Web Applications)

Once the connection works you can call any supported method. The following snippet browses existing web applications on the PLC:

var webApps = await requestHandler.WebAppBrowseAsync();
foreach (var app in webApps.Result.Applications)
{
    Console.WriteLine($"{app.Name} – State: {app.State}");
}

Other common operations include reading PLC tags via the PlcProgram handlers, uploading web-app resources with the ticket system, or retrieving module identification data. Always close tickets after use to avoid resource limits on the PLC.

Common Mistakes

  • Using a library version older than 3.3.62– leaves the application exposed to the path-traversal and password-leak issues fixed in the November 2026 update.
  • Leaving the default Anonymous/Everybody user– it has almost no rights; create a dedicated user with the minimum required permissions.
  • Ignoring certificate validation– either install the PLC certificate properly or (for lab use only) set the callback shown in Step 4.
  • Forgetting to close tickets– the PLC allows only a limited number of open tickets; always callApiCloseTicketAsync.
  • Wrong IP or firewall blocking HTTPS– confirm you can reachhttps://from the same machine before debugging code.
  • Mismatch between library and PLC firmware– consult the compatibility table in the official GitHub README when using older PLC firmware.

Final Check

Before moving to production, verify the following:

  • Library version is 3.3.62 or newer
  • Certificate validation is either properly trusted or explicitly limited to the PLC’s certificate
  • The account used by the application has the least privileges necessary
  • Api.Browse and at least one real business method succeed
  • Exception messages do not contain sensitive restore passwords or file paths

Summary

You now have a working Siemens .NET Client Library configuration that communicates securely with a SIMATIC S7 web server. The essential pieces are a current package version, correct certificate handling, a properly privileged user, and theApiHttpClientRequestHandlerobtained fromApiStandardServiceFactory.

Next steps include exploring the WebApp deployer helpers for automated web-application deployment, implementing robust error handling around ticket operations, and integrating the client into a larger monitoring or HMI application. Refer to the official GitHub repository (siemens/simatic-s7-webserver-api) and the PLC web-server function manual for the complete method catalog and firmware-specific limits.

Leave a Reply

Your email address will not be published. Required fields are marked *