Exporting S7 Connections from TIA Portal: CAx, Openness, AML

David Krause12 min read
SiemensTIA PortalTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Overview

S7 Connection resources configured under Devices & Networks > Networks view > S7 connections are not written into the AutomationML (.aml) file produced by the TIA Portal CAx export wizard. The CAx exporter serializes topology, module parameters, and a subset of software objects, but the cross-PLC S7 connection objects are filtered out by design. As a result, a CAx round-trip (export → modify → import) on a TIA V17 project rebuilds the hardware and PLC software skeleton but leaves every S7 connection empty and rewrites every drive parameter to its default value.

This article documents the practical methods available to preserve S7 Connection configuration across project exchanges:

  1. TIA Portal Openness API — programmatic export and re-import of S7 connection objects.
  2. SIMATIC S7 Connector V2.1.0 XML workflow — structured tag-level export that complements Openness.
  3. Direct PLC tag and connection XML export via the TIA Portal GUI — the lowest-effort manual path.
  4. Workarounds for the drive-parameter default-on-import behavior seen during CAx round-trip.

Verification steps, a troubleshooting matrix for the most common failure modes, and an FAQ close the document.

Why S7 Connections Are Missing from CAx .aml Export

The TIA Portal CAx data exporter targets the AutomationML (AML) role-class Communication only for a narrow set of object types: subnets, IO controllers, IO devices, PN/PN coupler link tables, and a small subset of HMI tags. S7 connection objects are represented inside the project by the type S7Connection under Subnet.Connections, and these are deliberately omitted from the AML CAx profile.

The architectural reasons are documented across the Siemens support database:

  • S7 connection semantics depend on protected CPU-to-CPU configuration objects (connection resources, TSAPs, local/partner IDs) that the AML CAx schema does not model.
  • The S7 connection lifecycle (active/passive endpoints, one-way/two-way, PUT/GET vs. ISO-on-TCP) does not map cleanly to the AML Communication role.
  • Drive parameters live in the GSD/GSDML importer pipeline; CAx import regenerates the device description from scratch, which resets parameters to GSD defaults unless a separate parameter file is re-applied.

Until Siemens extends the CAx exporter, the only reliable way to round-trip S7 connection objects is through TIA Portal Openness or manual XML handling.

Prerequisites

Item Requirement Notes
TIA Portal V16 or later (V17/V18 preferred) Openness API surface area differs between versions; build and run on the matching version.
TIA Portal Openness Installed and licensed on the engineering station Adds the Siemens.Engineering.dll reference assemblies.
.NET target .NET Framework 4.7.2 (V16/V17) or .NET 6+ (V18+) Match the assembly's TargetFramework.
Visual Studio 2019 or 2022 with desktop workload For compiling the exporter helper.
Project state Compiled (no unsaved changes) Openness requires a consistent project graph; compile before reading connection data.
User rights Local administrator to install TIA Openness The Openness license is bound to the install.
TIA Openness runs the TIA Portal shell in TiaPortalMode.WithoutUserInterface. Do not start a second TIA Portal instance in parallel — the project file is locked exclusively.

CAx Export Scope: What Is and Is Not Included

The following table summarizes the canonical CAx (.aml) coverage against a V17 project. Use it to predict what survives a round-trip before committing to a particular workflow.

Object Exported to AML Round-trip fidelity
PLC hardware (rack, modules) Yes High — module order, slot, article number preserved.
PROFINET subnet Yes High — name, IP, subnet mask.
IO devices and IO controllers Yes High — device names and IP addresses.
PN/PN coupler link table Yes Medium — depends on coupler GSD version.
S7 Connection (PUT/GET, ISO-on-TCP) No N/A — not serialized.
HMI tags (symbolic) Partial Medium — only DB-bound tags, not raw absolute tags.
PLC tags (DB tags) Yes (PLC tag table export) High when using SIMATIC S7 Connector V2.1.0 workflow.
Drive parameter set No Defaults restored on CAx import.
Safety configuration (F-CPU) No Must be re-entered or imported via Openness.

Method 1: TIA Openness API for S7 Connection Export

TIA Portal Openness exposes the full S7 connection graph through Siemens.Engineering.HW.Features.ConnectionService and Siemens.Engineering.HW.S7Connection. A C# console application can enumerate every connection in the project, serialize it to XML, and later re-import it on the target station.

Step-by-Step Procedure

  1. Create a new Console App (.NET Framework 4.7.2) project in Visual Studio.
  2. Add references to Siemens.Engineering.dll and Siemens.Engineering.Hmi.dll from the TIA Portal installation directory (default C:\Program Files\Siemens\Automation\Portal V17\PublicAPI\V17).
  3. Reference the assembly with Embed Interop Types = False; the types are not COM but they must not be embedded.
  4. Compile the project to S7ConnectionExporter.exe.
  5. Close the TIA Portal UI.
  6. Run S7ConnectionExporter.exe "C:\Projects\Plant.ap17" "C:\Export\S7Connections.xml".
  7. Open S7Connections.xml and validate against the schema in Verification Steps.

Reference Code: Export Side

using System;
using System.IO;
using System.Xml;
using Siemens.Engineering;
using Siemens.Engineering.HW;
using Siemens.Engineering.HW.Features;

namespace S7ConnectionExporter
{
    internal static class Program
    {
        private const string Ns = "urn:siemens:tia:s7conn:1.0";

        static int Main(string[] args)
        {
            if (args.Length != 2)
            {
                Console.Error.WriteLine("Usage: S7ConnectionExporter <project.ap17> <output.xml>");
                return 2;
            }

            var projectFile = new FileInfo(args[0]);
            if (!projectFile.Exists) { Console.Error.WriteLine("Project not found."); return 3; }

            using var tia = new TiaPortal(TiaPortalMode.WithoutUserInterface);
            using Project project = tia.Projects.Open(projectFile);

            var settings = new XmlWriterSettings { Indent = true, IndentChars = "  ", Encoding = System.Text.Encoding.UTF8 };
            using var w = XmlWriter.Create(args[1], settings);
            w.WriteStartDocument();
            w.WriteStartElement("S7Connections", Ns);

            int total = 0;
            foreach (Device device in project.Devices)
            {
                total += WalkDevice(device, w);
            }

            w.WriteEndElement();
            w.WriteEndDocument();
            Console.WriteLine($"Exported {total} S7 connection(s) to {args[1]}");
            return 0;
        }

        private static int WalkDevice(Device device, XmlWriter w)
        {
            int count = 0;
            foreach (DeviceItem item in device.DeviceItems)
            {
                // S7 connections live on DeviceItems that participate in a Subnet
                Subnet subnet = item.Subnet;
                if (subnet == null) continue;

                foreach (object connObj in subnet.Connections)
                {
                    if (connObj is S7Connection s7)
                    {
                        WriteConnection(w, s7, device, item);
                        count++;
                    }
                }
            }
            return count;
        }

        private static void WriteConnection(XmlWriter w, S7Connection s7, Device owner, DeviceItem item)
        {
            w.WriteStartElement("Connection");
            w.WriteAttributeString("name", s7.Name);
            w.WriteAttributeString("ownerDevice", owner.Name);
            w.WriteAttributeString("ownerItem", item.Name);
            w.WriteElementString("Type", s7.Type.ToString());         // IsoOnTcp / S7Communication / PutGet
            w.WriteElementString("Active", s7.Active ? "true" : "false");
            w.WriteElementString("LocalTsap", s7.LocalTsap?.IdString ?? "");
            w.WriteElementString("PartnerTsap", s7.PartnerTsap?.IdString ?? "");
            w.WriteElementString("LocalAddress", s7.LocalAddress?.ToString() ?? "");
            w.WriteElementString("PartnerAddress", s7.PartnerAddress?.ToString() ?? "");
            w.WriteElementString("LocalId", s7.LocalId.ToString());
            w.WriteElementString("PartnerId", s7.PartnerId.ToString());
            w.WriteEndElement();
        }
    }
}

Reference Code: Import Side

The reverse pass opens the target project and rebuilds the connections by matching ownerDevice + ownerItem against the live project graph.

using Siemens.Engineering;
using Siemens.Engineering.HW;
using Siemens.Engineering.HW.Features;

using var tia = new TiaPortal(TiaPortalMode.WithoutUserInterface);
using Project project = tia.Projects.Open(new FileInfo(args[0]));

var doc = new System.Xml.XmlDocument();
doc.Load(args[1]);

foreach (System.Xml.XmlNode node in doc.SelectNodes("//*[local-name()='Connection']"))
{
    string ownerDevice = node.Attributes["ownerDevice"].Value;
    string ownerItem   = node.Attributes["ownerItem"].Value;

    Device device = FindDevice(project, ownerDevice);
    DeviceItem item = FindDeviceItem(device, ownerItem);
    if (device == null || item == null) { Console.WriteLine($"Skip {ownerDevice}/{ownerItem}"); continue; }

    var connSvc = item.GetService<ConnectionService>();
    if (connSvc == null) continue;

    // Use the appropriate factory based on Type
    // Example for ISO-on-TCP:
    //   var c = connSvc.CreateIsoOnTcpConnection(...);
    //   c.LocalTsap  = ... ; c.PartnerTsap = ... ;
    //   c.LocalAddress = ... ; c.PartnerAddress = ... ;
    //   c.Name = node["@name"].Value;
}
The exact factory method names (CreateIsoOnTcpConnection, CreateS7Connection, CreatePutGetConnection) depend on the TIA Portal version. Refer to the Openness API reference installed with Siemens.Engineering.dll for the version on your station.

Method 2: SIMATIC S7 Connector V2.1.0 XML Workflow

The SIMATIC S7 Connector V2.1.0 is an Industrial Edge application whose primary purpose is to forward PLC tag values to the IE runtime. As a side-effect of its configuration workflow, it forces a structured XML export of PLC tags that can be reused for partial project reproduction.

XML Export Procedure

  1. Compile the TIA Portal project.
  2. Navigate to the target PLC → PLC tags → Show all tags.
  3. Right-click the tag table and select Export file.
  4. Choose XML as the format and save to a known location.
  5. Import the resulting XML into the S7 Connector configurator as described in the XML file export documentation.

The output schema is stable across V17/V18 of TIA Portal. Tags are addressable by fully qualified name and grouped by data block. The connector reads the file at deploy time and binds each tag to the IE runtime variable tree.

The SIMATIC S7 Connector exports PLC tags, not S7 connections. Use this method in combination with the Openness workflow when both tag definitions and connection routing must be preserved across project exchanges.

Method 3: Direct PLC Tag and Connection XML Export

For small projects where Openness is overkill, the TIA Portal GUI itself can export per-PLC tag tables and per-subnet connection tables. The procedure does not capture cross-references between devices but it is sufficient when the receiving project uses the same hardware catalog.

Tag Export

  1. In the project tree, expand the target PLC → PLC tags.
  2. Select Default tag table or a user-defined table.
  3. Right-click → Export → Export to Excel or Export to XML.
  4. Save the file as <plcname>_tags.xml.

Connection Export (Manual Snapshot)

Because the GUI does not expose a connection-only exporter, capture the connection properties via a screenshot or by copy-pasting the Properties → General tab of each S7 connection into a side document. Useful fields:

  • Connection name
  • Local interface / Local IP / Local TSAP
  • Partner IP / Partner TSAP
  • Connection type (ISO-on-TCP, S7 communication, PUT/GET)
  • Active / Passive role
  • Connection resource ID (hex, e.g., 10, 11)

For a 30-CPU plant this is tedious but viable when Openness is not available on the engineering station.

Drive Parameter Export Limitation and Workarounds

CAx import always rewrites drive parameters to the values defined by the GSD/GSDML file because the AML role for drives does not carry parameter payloads. The original values must be re-applied by one of the following methods:

Method Effort Best for
Openness: enumerate DeviceItem.Parameters and serialize to XML Medium Large fleets with identical drive types.
STARTER / SINAMICS Startdrive project archive (.par / .zip) Low Sinamics G120/G130/G150/S120 with Startdrive commissioning.
TIA Portal → Device → Export parameter assignment Low Single-device round-trip.
Web server / BOP-2 upload (for hardware that supports it) High Field service, no engineering station.

If the drives are managed by Startdrive inside the same TIA project, parameter sets can be exported via Drive → Commissioning → Save to memory card. The card image is then loaded back after the CAx import completes.

Verification Steps After Import

  1. Open the target TIA Portal project.
  2. Navigate to Devices & Networks.
  3. Open the Connections table (right-click the network → Show connections).
  4. Confirm that every S7 connection from the source XML appears with the correct Type, Active, Local TSAP, and Partner TSAP.
  5. Right-click each CPU → Compile → Software (rebuild all).
  6. Check the Info → Compile tab for warnings of the form "S7 connection X references unknown partner Y". Resolve any by re-binding the partner.
  7. Download the project to each CPU and force an Establish connection from the online diagnostics view.
  8. For drives, compare the Online → Parameter assignment tab against the source project. Diff at parameter-set level.

Troubleshooting Matrix

Symptom Likely cause Remedy
Openness call returns EngineeringTargetInvocationException: TIA Portal is already running Another TIA Portal instance has the project locked Close all TIA Portal windows and retry.
subnet.Connections is empty after CAx import CAx does not serialize S7 connections Use Method 1 (Openness) or Method 3 (manual snapshot).
Drive parameters reset to GSD defaults CAx rebuilds device description from GSDML Re-apply via Startdrive memory card or Openness parameter export.
SIMATIC S7 Connector fails to parse exported XML Tags contain unsupported data types (POINTER, VARIANT) Pre-process the tag list to exclude POINTER/VARIANT; rely on derived tags for those signals.
item.GetService<ConnectionService>() returns null DeviceItem is not a CPU or CP with routing capability Iterate device.DeviceItems and only call GetService on CPU/CP entries.
S7 connection created but partner cannot establish TSAPs reversed (local/partner swapped) Confirm TSAP hex values match the source XML byte-for-byte.
CAx import silently drops connection resources Project is in "not compiled" state Compile before running the CAx export.
Openness build fails: FileNotFoundException Siemens.Engineering.dll Wrong PublicAPI folder referenced Reference the version-specific subfolder (e.g., PublicAPI\V17).
Drive parameter names differ between GSDML revisions Drive family firmware mismatch Lock the drive family/firmware version in the project before CAx import.

Cross-Platform Notes

The TIA Portal V17 Openness API surface is consistent across Windows 10 LTSC 2019, Windows 10 21H2, and Windows 11 22H2. There is no native Linux or macOS support. Industrial Edge runtime targets Linux but the configuration is performed on a Windows engineering station.

For STEP 7 V5.x projects (pre-V15), the equivalent of CAx export is the Source code export via SIMATIC Manager → Options → Manage multilingual texts → Export. Net connections defined in NetPro are not preserved across that path either; only the S7 program blocks are. To migrate S7 connections from V5.x to TIA Portal, use Migration → Migrate project in the TIA Portal UI, which preserves connection objects at the project level.

Safety Considerations

S7 connections participate in safety-related communication when paired with F-CPUs and F-CPs. Openness-driven round-trips must be validated against the F-signature and F-runtime signature before re-commissioning. Do not use the Openness script as the only authoritative record of a safety configuration — always re-run the safety acceptance test after import.

Why are S7 connections missing from the TIA Portal CAx .aml export?

The CAx exporter targets the AutomationML Communication role for subnets, IO controllers, and IO devices only. S7Connection objects under Subnet.Connections are filtered out by design; the AML schema does not model connection resources, TSAPs, or local/partner IDs. Use TIA Portal Openness to round-trip S7 connections.

Which TIA Portal version is required to use the Openness API for S7 connection export?

TIA Portal V16 or later is required. V17 is the recommended baseline because the ConnectionService API surface is stable and the documentation is current. The compiled helper must match the major version of the target TIA Portal (V16 helper against V16 TIA, V17 helper against V17 TIA).

Can the SIMATIC S7 Connector V2.1.0 export S7 connections?

No. The S7 Connector exports PLC tag tables to XML and binds them to Industrial Edge runtime variables. It does not serialize S7 connection objects. Combine the S7 Connector with the Openness workflow when both tag definitions and connection routing must be preserved.

How do I prevent drive parameters from resetting to defaults after a CAx import?

Export drive parameter sets before the CAx round-trip using Startdrive → Commissioning → Save to memory card or the Openness DeviceItem.Parameters API. Re-apply the saved set after the CAx import completes. Lock the drive firmware version in the project before the round-trip so GSDML revisions do not shift parameter names.

Is it safe to use TIA Openness in headless mode against a live project?

Openness acquires an exclusive lock on the .ap17 file. No second TIA Portal process can open the project while the Openness helper is running. Always run in TiaPortalMode.WithoutUserInterface, close any user-facing TIA Portal instance, and back up the project file before mutating imports. For safety-related projects, re-validate the F-signature after any round-trip.

Back to blog