> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Siemens Opcenter Execution

> Siemens Opcenter Execution MES: OData reads of work orders and runtime data, archive queries, plant config, OpenAPI discovery and public command invocation

Technical Preview

## Overview

One client-mode connector, **SiemensOpcenterExecution**, for the service layer of Siemens Opcenter Execution. Opcenter Execution Discrete, Process and other solutions built on Opcenter Execution Foundation expose the same surface: OData v4 reads on `/sit-svc`, a read-only archive on `/sit-arch`, and public commands that the solution's workers execute.

Use the connector to bring MES context into your Unified Namespace: publish active work orders next to the machine data that serves them, count open operations per line, or look up a finished order in the archive. In the other direction, a machine event on the broker can call an Opcenter command such as completing an operation or recording a consumption.

Every Opcenter solution is different. Entity sets and command names come from the Apps installed in your solution, and Opcenter generates an OpenAPI 3.0.3 description of them when the solution is built. Start with the discovery events, then use the exact names they return.

| Event | Request | Notes |
| - | - | - |
| GetPlantConfig | `GET /sit-svc/config?{query}` | Configured plants; `plantid=<PlantId>` filters one |
| GetHostMonitoring | `GET /sit-svc/monitoring?{query}` | Host and worker status, the data behind the Solution Studio monitoring screen |
| GetSolutionOpenApi | `GET /sit-svc/{solution_path}/$openapi` | OpenAPI of every public command in the solution |
| GetAppServiceDocument | `GET /sit-svc/{app_path}/odata/` | OData service document: the App's entity sets |
| GetAppMetadata | `GET /sit-svc/{app_path}/odata/$metadata` | CSDL XML: entities, keys, properties, navigation |
| GetAppOpenApi | `GET /sit-svc/{app_path}/odata/$openapi` | OpenAPI of the App's commands and entities |
| QueryEntities | `GET /sit-svc/{app_path}/odata/{entity}?{query}` | Any entity set with `$filter`, `$select`, `$expand`, `$orderby`, `$top`, `$skip` |
| GetEntity | `GET /sit-svc/{app_path}/odata/{entity}({key})?{query}` | One record by key |
| CountEntities | `GET /sit-svc/{app_path}/odata/{entity}/$count?{query}` | Plain-text count |
| ListWorkOrders | `GET /sit-svc/{app_path}/odata/WorkOrder?{query}` | Shortcut for the `WorkOrder` entity set; check the name in `$metadata` |
| QueryArchive | `GET /sit-arch/{app_path}/odata/{entity}?{query}` | Archived runtime data, read-only |
| InvokeCommand | `POST /sit-svc/{app_path}/odata/{command}` | Any public command; body as described in `$openapi` |

Topics are `mes/siemens-opcenter-execution/<object>/<verb>`; every reply goes to `<topic>/response`.

`app_path` is `Application/<AppName>` for the default plant, or `<PlantId>/Application/<AppName>` in a multi-plant installation, for example `Application/AppU4DM` or `Plant1/Application/AppU4DM`. `solution_path` is `Application` or `<PlantId>/Application`.

## Authentication

Every event sends `Authorization: {authorization}`, so pass the whole header value, normally `"Bearer <access token>"`. Opcenter issues tokens through its authentication service (`/sit-auth`), backed by Siemens UMC or the identity provider your installation is configured with. How a service account gets a token depends on that setup, so ask your Opcenter administrator for a service account and the token procedure, and give the account only the roles the commands you plan to call need.

Keep the value in a broker secret (suggested `OPCENTER_AUTHORIZATION`) and map it in with `GET SECRET`. Tokens expire, so refresh the secret on the schedule your identity provider uses. A missing or expired token returns `401`; a role without permission returns `403`.

## Basic Syntax

Opcenter runs on your own servers or private cloud, so set `BASE_ADDRESS` to the host that serves `/sit-svc` (no trailing slash).

```lot theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
DEFINE ROUTE SiemensOpcenterExecution WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://YOUR_OPCENTER_HOST"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '60'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT QueryEntities
        WITH SOURCE_TOPIC "mes/siemens-opcenter-execution/entity/query"
        WITH DESTINATION_TOPIC "mes/siemens-opcenter-execution/entity/query/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/sit-svc/{value.json.app_path}/odata/{value.json.entity}?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Authorization" "{value.json.authorization}"
    ADD EVENT InvokeCommand
        WITH SOURCE_TOPIC "mes/siemens-opcenter-execution/command/invoke"
        WITH DESTINATION_TOPIC "mes/siemens-opcenter-execution/command/invoke/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/sit-svc/{value.json.app_path}/odata/{value.json.command}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "Content-Type" "application/json"
            ADD "Authorization" "{value.json.authorization}"
        WITH BODY "{value.json.body}"
```

The full template, with all 12 events, is `SiemensOpcenterExecutionRestApi.lot` in the REST API app.

## MQTT examples

Request bodies go under `body`, so control fields like `authorization`, `app_path`, `entity` and `query` are not sent to Opcenter.

**Discover what an App offers**: publish to `mes/siemens-opcenter-execution/app-openapi/get`:

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
{
  "authorization": "Bearer <Opcenter token>",
  "app_path": "Application/AppU4DM"
}
```

The reply lists the App's commands with their request schemas. `app-metadata/get` returns the entity sets and keys.

**Read the first 20 work orders**: publish to `mes/siemens-opcenter-execution/work-order/list`. The OData query must be URL-encoded:

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
{
  "authorization": "Bearer <Opcenter token>",
  "app_path": "Application/AppU4DM",
  "query": "$top=20"
}
```

Use `entity/query` with `"entity": "<EntitySet>"` for any other entity set, and send `"query": ""` when you do not need options.

**Get one record**: publish to `mes/siemens-opcenter-execution/entity/get` with `"entity"` and `"key"`. The key is the OData key literal as it appears in the URL: a Guid as is, a string in single quotes such as `"'WO-0001'"`.

**Call a public command**: publish to `mes/siemens-opcenter-execution/command/invoke`:

```json theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
{
  "authorization": "Bearer <Opcenter token>",
  "app_path": "Application/<AppName>",
  "command": "<PublicCommandName>",
  "body": { "...": "fields exactly as the command's request schema in $openapi" }
}
```

The connector sends `body` unchanged, so copy its shape from the command's schema in `GetAppOpenApi` or `GetSolutionOpenApi`.

## Helper actions

Keep the token in a broker secret, poll work orders every minute, and turn a line event into an Opcenter command:

```lot theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
DEFINE ACTION OpcenterPollActiveWorkOrders
ON EVERY 1 MINUTE DO
    SET "auth" WITH GET SECRET "OPCENTER_AUTHORIZATION"
    PUBLISH TOPIC "mes/siemens-opcenter-execution/work-order/list" WITH { "authorization": {auth}, "app_path": "Application/AppU4DM", "query": "$top=50" }

DEFINE ACTION OpcenterInvokeFromLine
ON TOPIC "porto/line1/opcenter/command" DO
    SET "auth" WITH GET SECRET "OPCENTER_AUTHORIZATION"
    SET "cmd" WITH GET JSON "command" IN PAYLOAD AS STRING
    SET "args" WITH GET JSON "body" IN PAYLOAD
    PUBLISH TOPIC "mes/siemens-opcenter-execution/command/invoke" WITH { "authorization": {auth}, "app_path": "Application/AppU4DM", "command": {cmd}, "body": {args} }
```

Restrict who can publish to `mes/siemens-opcenter-execution/#` with a rule: its payloads carry the token, and `InvokeCommand` changes production records.

## Notes

* Errors come back on the response topic: `401` for a missing or expired token, `403` when the account's role does not allow the call, `404` for an unknown App, entity set or command, `400` for a malformed OData query or command body, and `500` when a command handler fails.
* Commands are executed by Opcenter workers. Some return only after the transaction commits; check the result by reading the affected entity afterwards.
* `/sit-arch` is the archive database and is read-only. Use it for history and audit, and `/sit-svc` for live production data.
* In a multi-plant installation each plant has its own data. Put the plant id in `app_path` and use `GetPlantConfig` with `plantid=<PlantId>` to check it.
* Names differ between Opcenter Execution Discrete, Process and custom solutions. `ListWorkOrders` assumes a `WorkOrder` entity set; if your App names it differently, use `QueryEntities`.

## Related

* [REST API Connectors](/latest/lot-language/routes/rest-api-routes)
* [REST API app templates](/latest/lot-language/routes/rest-api-apps/index)
* [Ignition](/latest/lot-language/routes/rest-api-apps/ignition)
* [SAP Digital Manufacturing](/latest/lot-language/routes/rest-api-apps/sap-digital-manufacturing)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.