OPC UA Client
Since Camel 2.19
Both producer and consumer are supported
The Milo Client component provides access to OPC UA servers>
The OPC UA Client component supports 25 options, which are listed below.
URI format
The URI syntax of the endpoint is:
milo-client:opc.tcp://[user:password@]host:port/path/to/service?node=RAW(nsu=urn:foo:bar;s=item-1)
If the server does not use a path, then it is possible to simply omit it:
milo-client:opc.tcp://[user:password@]host:port?node=RAW(nsu=urn:foo:bar;s=item-1)
If no user credentials are provided the client will switch to anonymous mode.
URI options
All configuration options in the group client are applicable to the shared client instance. Endpoints will share client instances for each endpoint URI. So the first time a request for that endpoint URI is made, the options of the client group are applied. All further instances will be ignored.
If you need alternate options for the same endpoint URI it is possible though to set the clientId option which will by added internally to the endpoint URI in order to select a different shared connection instance. In other words, shared connections located by the combination of endpoint URI and client id.
The OPC UA Client endpoint is configured using URI syntax:
milo-client:endpointUri
with the following path and query parameters:
Discovery
If the server uses a dedicated discovery endpoint (e.g.
/discovery), which may support different (less secure) security policies, then you can make use of this via the parameter
discoveryEndpointSuffix, which will be appended to the
endpointUri. Or by using an explicit
discoveryEndpointUri.
Overriding the host name
The client uses the host information from the endpoint information, queried from the server. However in some situations this endpoint URI might be different, and wrong from the point of view of the connecting client (e.g. an internal hostname).
In this case it is possible to set the parameter
overrideHost to
true, which will take the discovered endpoint information, but override the host information with the value of the original URI.
Node ID
In order to define a target node a namespace and node id is required. In previous versions this was possible by specifying
nodeId and either
namespaceUri or
namespaceIndex. However this only allowed for using string based node IDs. And while this configuration is still possible, the newer one is preferred.
The new approach is to specify a full namespace+node ID in the format
ns=1;i=1 which also allows to use the other node ID formats (like numeric, GUID/UUID or opaque). If the
node parameter is used the older ones must not be used. The syntax of this node format is a set of
key=value pairs delimited by a semi-colon (
;).
Exactly one namespace and one node id key must be used. See the following table for possible keys:
As the values generated by the syntax cannot be transparently encoded into a URI parameter value, it is necessary to escape them. However Camel allows to wrap the actual value inside
RAW(…), which makes escaping unnecessary. For example:
milo-client:opc.tcp://user:password@localhost:12345?node=RAW(nsu=;s=foo/bar)
Method ID
It is possible to perform methods calls on OPC UA nodes. If the parameter
method is set to the Node ID of a method call (the node ID must be set to the parent object in this case), then a method call will be performed instead of a write operation.
Input parameters are taken from the body:
If the body is null, then an empty
Variant[]will be used
If the body is a
Variant[], then it will be used as is
If the body is a
Variant, then it will be wrapped in a
Variant[]array
Otherwise the body will be converted into a
Variantand wrapped in an array of
Variant[]");
Security policies
When setting the allowing security policies is it possible to use the well known OPC UA URIs (e.g.) or to use the Milo enum literals (e.g.
None). Specifying an unknown security policy URI or enum is an error.
The known security policy URIs and enum literals are can be seen here: SecurityPolicy.java
Note: In any case security policies are considered case sensitive..