org.opcfoundation.ua.application
Class Client

java.lang.Object
  extended by org.opcfoundation.ua.application.Client

public class Client
extends Object

OPC UA Client application


Constructor Summary
Client(Application application)
          Construct a new client application Note: Client needs an application instance certificate to create secure channels.
 
Method Summary
 ApplicationDescription createApplicationDescription()
          createApplicationDescription.
static Client createClientApplication(KeyPair cert)
          createClientApplication.
 SecureChannel createSecureChannel(ApplicationDescription applicationDescription)
          Create a secure channel to a UA application This implementation accepts only connections with opc.tcp protocol and with encryption.
 SecureChannel createSecureChannel(EndpointDescription endpoint)
          Create a secure channel to an endpoint
 SecureChannel createSecureChannel(String endpointUrl)
          Create a secure channel to a UA Server This method first queries endpoints, chooses the most suitable and connects to it.
 SecureChannel createSecureChannel(String connectUrl, EndpointDescription endpoint)
          Create a secure channel to an endpoint.
 SecureChannel createSecureChannel(String connectUrl, String endpointUri)
          Create a secure channel to a UA Server This method first queries endpoints, chooses the most suitable and connects to it.
 SecureChannel createSecureChannel(String connectUrl, String endpointUri, SecurityMode mode, Cert remoteCertificate)
          Create and open a secure channel.
 SecureChannel createSecureChannel(String connectUrl, TransportChannelSettings settings)
          Create and open a secure channel.
 SecureChannel createSecureChannel(TransportChannelSettings settings)
          Create and open a secure channel.
 ServiceChannel createServiceChannel(ApplicationDescription applicationDescription)
          Create a service channel Note this implementation is unsecure as the dialog with discover endpoint is not encrypted.
 ServiceChannel createServiceChannel(EndpointDescription endpoint)
          Create a service channel to an endpoint.
 ServiceChannel createServiceChannel(String endpointUrl)
          Create a service channel to a UA Server This method first queries endpoints, chooses the most suitable and connects to it.
 ServiceChannel createServiceChannel(String connectUrl, EndpointDescription endpoint)
          Create a service channel to an endpoint
 ServiceChannel createServiceChannel(String connectUrl, String endpointUri)
          Create a service channel to a UA Server This method first queries endpoints, chooses the most suitable and connects to it.
 ServiceChannel createServiceChannel(String connectUrl, String endpointUri, SecurityMode mode, Cert remoteCertificate)
          Create and open a service channel.
 ServiceChannel createServiceChannel(TransportChannelSettings settings)
          Create and open a secure channel and adapt to service channel.
 Session createSession(SecureChannel channel)
          Create a new session on a server.
 Session createSession(SecureChannel channel, UnsignedInteger maxResponseMessageSize, Double requestedSessionTimeout, String sessionName)
          Create a new session on a server
 Session createSession(SecureChannel channel, UnsignedInteger maxResponseMessageSize, Double requestedSessionTimeout, String sessionName, EndpointDescription[] discoveredEndpoints)
          Create a new session on a server
 SessionChannel createSessionChannel(ApplicationDescription applicationDescription)
          Creates a secure channel and an unactivated session channel.
 SessionChannel createSessionChannel(EndpointDescription endpoint)
          Creates a secure channel and an unactivated session channel.
 SessionChannel createSessionChannel(String endpointUrl)
          Creates a secure channel and an unactivated session channel.
 SessionChannel createSessionChannel(String connectUrl, EndpointDescription endpoint)
          Creates a secure channel and an unactivated session channel.
 SessionChannel createSessionChannel(String connectUrl, String endpointUri)
          Creates a secure channel and an unactivated session channel.
 ApplicationDescription[] discoverApplications(String discoverServerEndpointUrl)
          Discover applications
 ApplicationDescription[] discoverApplications(String connectUrl, String discoverServerEndpointUri)
          Discover applications
 EndpointDescription[] discoverEndpoints(String discoveryEndpointUrl)
          Discover endpoints
 EndpointDescription[] discoverEndpoints(String connectUrl, String discoveryEndpointUri)
          Discover endpoints.
 ServerOnNetwork[] discoverServersOnNetwork(String discoverServerEndpointUrl)
          Discover ServerOnNetwork records from LDS
 ServerOnNetwork[] discoverServersOnNetwork(String connectUrl, String discoverServerEndpointUri)
          Discover ServerOnNetwork records from LDS
 ServerOnNetwork[] discoverServersOnNetwork(String connectUrl, String discoverServerEndpointUri, String[] serverCapabilities)
          Discover ServerOnNetwork records from LDS
 FindServersOnNetworkResponse discoverServersOnNetwork(String connectUrl, String discoverServerEndpointUri, UnsignedInteger startingRecordId, UnsignedInteger maxRecordsToReturn, String[] serverCapabilities)
          Get FindServersOnNetworkResponse to retrieve ServerOnNetwork records and lastCounterResetTime associated with them
 Application getApplication()
          Getter for the field application.
 HttpsSettings getApplicationHttpsSettings()
          getApplicationHttpsSettings.
 OpcTcpSettings getApplicatioOpcTcpSettings()
          getApplicatioOpcTcpSettings.
 EncoderContext getEncoderContext()
          getEncoderContext.
 EndpointConfiguration getEndpointConfiguration()
          Getter for the field endpointConfiguration.
 int getMaxMessageSize()
          getMaxMessageSize.
 int getTimeout()
          getTimeout.
 void setEndpointConfiguration(EndpointConfiguration endpointConfiguration)
          Setter for the field endpointConfiguration.
 void setMaxMessageSize(int maxMessagSize)
          setMaxMessageSize.
 void setTimeout(int timeout)
          setTimeout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Client

public Client(Application application)
Construct a new client application

Note: Client needs an application instance certificate to create secure channels. See Application.addApplicationInstanceCertificate(KeyPair)

Parameters:
application - common application data
Method Detail

createClientApplication

public static Client createClientApplication(KeyPair cert)

createClientApplication.

Parameters:
cert - a KeyPair object.
Returns:
a Client object.

createApplicationDescription

public ApplicationDescription createApplicationDescription()

createApplicationDescription.

Returns:
a ApplicationDescription object.

getApplication

public Application getApplication()

Getter for the field application.

Returns:
a Application object.

getApplicationHttpsSettings

public HttpsSettings getApplicationHttpsSettings()

getApplicationHttpsSettings.

Returns:
a HttpsSettings object.

getApplicatioOpcTcpSettings

public OpcTcpSettings getApplicatioOpcTcpSettings()

getApplicatioOpcTcpSettings.

Returns:
a OpcTcpSettings object.

createSession

public Session createSession(SecureChannel channel)
                      throws ServiceResultException
Create a new session on a server.

Parameters:
channel - open channel
Returns:
Session made with the channel
Throws:
ServiceResultException - if error

createSession

public Session createSession(SecureChannel channel,
                             UnsignedInteger maxResponseMessageSize,
                             Double requestedSessionTimeout,
                             String sessionName)
                      throws IllegalArgumentException,
                             ServiceResultException
Create a new session on a server

Parameters:
channel - open channel to use
maxResponseMessageSize - max size of response messages - if null, use 4194304
requestedSessionTimeout - requested session time out (in ms) - if null, use 3600000 (one hour)
sessionName - session name - if null a random GUID is used to generate the name
Returns:
the session
Throws:
IllegalArgumentException - if error
ServiceResultException - if error

createSession

public Session createSession(SecureChannel channel,
                             UnsignedInteger maxResponseMessageSize,
                             Double requestedSessionTimeout,
                             String sessionName,
                             EndpointDescription[] discoveredEndpoints)
                      throws IllegalArgumentException,
                             ServiceResultException
Create a new session on a server

Parameters:
channel - open channel to use
maxResponseMessageSize - max size of response messages - if null, defaulting to 4194304
requestedSessionTimeout - requested session timeout (ms) - if null, defaulting to 3600000 (one hour)
sessionName - session name - if null, a random GUID is used to generate the name
discoveredEndpoints - list of previously discovered Endpoints using GetEndpoints service. This list is checked against the Endpoint list received from CreateSessionResponse, if it does not match, an exception is thrown, if null the check is disabled
Returns:
the session
Throws:
IllegalArgumentException - if endpoint or channel is null
ServiceResultException - if error

createSessionChannel

public SessionChannel createSessionChannel(String endpointUrl)
                                    throws ServiceResultException
Creates a secure channel and an unactivated session channel.

The channel needs to be activated separately.

To close the object, both secure channel and the session must be close separately. SessionChannel.closeSession() SessionChannel.closeSecureChannel()

Parameters:
endpointUrl - endpoint identifier and socket address
Returns:
channel
Throws:
ServiceResultException - if error

createSessionChannel

public SessionChannel createSessionChannel(String connectUrl,
                                           String endpointUri)
                                    throws ServiceResultException
Creates a secure channel and an unactivated session channel.

The channel needs to be activated separately.

To close the object, both secure channel and the session must be close separately. SessionChannel.closeSession() SessionChannel.closeSecureChannel()

Parameters:
connectUrl - address that contains the socket address to the endpoint
endpointUri - endpoint identifier
Returns:
channel
Throws:
ServiceResultException - if error

createSessionChannel

public SessionChannel createSessionChannel(EndpointDescription endpoint)
                                    throws ServiceResultException
Creates a secure channel and an unactivated session channel.

The channel needs to be activated separately.

To close the object, both secure channel and the session must be close separately. SessionChannel.closeSession() SessionChannel.closeSecureChannel()

Parameters:
endpoint - endpoint description
Returns:
session channel
Throws:
ServiceResultException - on errors

createSessionChannel

public SessionChannel createSessionChannel(String connectUrl,
                                           EndpointDescription endpoint)
                                    throws ServiceResultException
Creates a secure channel and an unactivated session channel.

The channel needs to be activated separately.

To close the object, both secure channel and the session must be close separately. SessionChannel.closeSession() SessionChannel.closeSecureChannel()

Parameters:
connectUrl - address that contains the socket address to the endpoint
endpoint - endpoint description
Returns:
session channel
Throws:
ServiceResultException - on errors

createSessionChannel

public SessionChannel createSessionChannel(ApplicationDescription applicationDescription)
                                    throws ServiceResultException
Creates a secure channel and an unactivated session channel.

The channel needs to be activated separately.

To close the object, both secure channel and the session must be close separately. SessionChannel.closeSession() SessionChannel.closeSecureChannel()

Parameters:
applicationDescription - application description
Returns:
session channel
Throws:
ServiceResultException - on errors

createSecureChannel

public SecureChannel createSecureChannel(String endpointUrl)
                                  throws ServiceResultException
Create a secure channel to a UA Server This method first queries endpoints, chooses the most suitable and connects to it.

Parameters:
endpointUrl - Endpoint identifier and socket address
Returns:
service channel
Throws:
ServiceResultException - if error

createSecureChannel

public SecureChannel createSecureChannel(String connectUrl,
                                         String endpointUri)
                                  throws ServiceResultException
Create a secure channel to a UA Server This method first queries endpoints, chooses the most suitable and connects to it.

Parameters:
connectUrl - address that contains the socket address to the endpoint
endpointUri - EndpointUri identifier or "" for discovery
Returns:
service channel
Throws:
ServiceResultException - if error

createSecureChannel

public SecureChannel createSecureChannel(ApplicationDescription applicationDescription)
                                  throws ServiceResultException
Create a secure channel to a UA application

This implementation accepts only connections with opc.tcp protocol and with encryption.

Note this implementation is unsafe as the dialog with discover endpoint is not encrypted.

Parameters:
applicationDescription - application description
Returns:
service channel
Throws:
ServiceResultException - if error

createSecureChannel

public SecureChannel createSecureChannel(EndpointDescription endpoint)
                                  throws ServiceResultException
Create a secure channel to an endpoint

Parameters:
endpoint - endpoint description
Returns:
an open service channel
Throws:
ServiceResultException - if errror

createSecureChannel

public SecureChannel createSecureChannel(String connectUrl,
                                         EndpointDescription endpoint)
                                  throws ServiceResultException
Create a secure channel to an endpoint.

Parameters:
connectUrl - address that contains the socket address to the endpoint
endpoint - endpoint description
Returns:
an open service channel
Throws:
ServiceResultException - if error

createSecureChannel

public SecureChannel createSecureChannel(String connectUrl,
                                         String endpointUri,
                                         SecurityMode mode,
                                         Cert remoteCertificate)
                                  throws ServiceResultException
Create and open a secure channel.

Parameters:
connectUrl - address that contains the socket address to the endpoint
endpointUri - endpoint uri
mode - security mode
remoteCertificate - remove certificate
Returns:
an open secure channel
Throws:
ServiceResultException - if error

createSecureChannel

public SecureChannel createSecureChannel(String connectUrl,
                                         TransportChannelSettings settings)
                                  throws ServiceResultException
Create and open a secure channel.

Parameters:
connectUrl - address that contains the socket address to the endpoint
settings - (optional) overriding settings
Returns:
an open secure channel
Throws:
ServiceResultException - if error

createSecureChannel

public SecureChannel createSecureChannel(TransportChannelSettings settings)
                                  throws ServiceResultException
Create and open a secure channel.

Parameters:
settings - transport settings
Returns:
an open secure channel
Throws:
ServiceResultException - if error

createServiceChannel

public ServiceChannel createServiceChannel(String endpointUrl)
                                    throws ServiceResultException
Create a service channel to a UA Server This method first queries endpoints, chooses the most suitable and connects to it.

Parameters:
endpointUrl - endpoint idenfier and socket address
Returns:
service channel
Throws:
ServiceResultException - if error

createServiceChannel

public ServiceChannel createServiceChannel(String connectUrl,
                                           String endpointUri)
                                    throws ServiceResultException
Create a service channel to a UA Server This method first queries endpoints, chooses the most suitable and connects to it.

Parameters:
connectUrl - connection url
endpointUri - endpointUri idenfier or "" for discovery service
Returns:
service channel
Throws:
ServiceResultException - if error

createServiceChannel

public ServiceChannel createServiceChannel(ApplicationDescription applicationDescription)
                                    throws ServiceResultException
Create a service channel

Note this implementation is unsecure as the dialog with discover endpoint is not encrypted.

Parameters:
applicationDescription - application description
Returns:
service channel
Throws:
ServiceResultException - if error

createServiceChannel

public ServiceChannel createServiceChannel(EndpointDescription endpoint)
                                    throws ServiceResultException
Create a service channel to an endpoint.

Parameters:
endpoint - endpoint description
Returns:
an open service channel
Throws:
ServiceResultException - if error

createServiceChannel

public ServiceChannel createServiceChannel(String connectUrl,
                                           EndpointDescription endpoint)
                                    throws ServiceResultException
Create a service channel to an endpoint

Parameters:
connectUrl - address that contains the socket address to the endpoint
endpoint - endpoint description
Returns:
an open service channel
Throws:
ServiceResultException - if error

createServiceChannel

public ServiceChannel createServiceChannel(String connectUrl,
                                           String endpointUri,
                                           SecurityMode mode,
                                           Cert remoteCertificate)
                                    throws ServiceResultException
Create and open a service channel.

Parameters:
connectUrl - address that contains the socket address to the endpoint
endpointUri - endpointUri identifier of the endpoint
mode - security mode
remoteCertificate - remote certificate
Returns:
an open secure channel
Throws:
ServiceResultException - if error

createServiceChannel

public ServiceChannel createServiceChannel(TransportChannelSettings settings)
                                    throws ServiceResultException
Create and open a secure channel and adapt to service channel.

Parameters:
settings - transport settings
Returns:
an open service channel
Throws:
ServiceResultException - if error

discoverEndpoints

public EndpointDescription[] discoverEndpoints(String discoveryEndpointUrl)
                                        throws ServiceResultException
Discover endpoints

Parameters:
discoveryEndpointUrl - endpoint identifier or socket address
Returns:
Endpoint Descriptions
Throws:
ServiceResultException - Error that occured while processing the operation.

discoverEndpoints

public EndpointDescription[] discoverEndpoints(String connectUrl,
                                               String discoveryEndpointUri)
                                        throws ServiceResultException
Discover endpoints.

Parameters:
connectUrl - address that contains the socket address to the endpoint
discoveryEndpointUri - the endpoint identifier that identifies the endpoints that are being discovered
Returns:
Endpoint Descriptions
Throws:
ServiceResultException - Error that occured while processing the operation.

discoverApplications

public ApplicationDescription[] discoverApplications(String discoverServerEndpointUrl)
                                              throws ServiceResultException
Discover applications

Parameters:
discoverServerEndpointUrl - endpointURI that is also the socket address
Returns:
Endpoint Application Descriptions
Throws:
ServiceResultException - if error

discoverApplications

public ApplicationDescription[] discoverApplications(String connectUrl,
                                                     String discoverServerEndpointUri)
                                              throws ServiceResultException
Discover applications

Parameters:
connectUrl - address that contains the socket address to the endpoint
discoverServerEndpointUri - endpointURI or ""
Returns:
Endpoint Application Descriptions
Throws:
ServiceResultException - if error

discoverServersOnNetwork

public ServerOnNetwork[] discoverServersOnNetwork(String discoverServerEndpointUrl)
                                           throws ServiceResultException
Discover ServerOnNetwork records from LDS

Parameters:
discoverServerEndpointUrl - endpointURI that is also the socket address
Returns:
ServerOnNetwork records
Throws:
ServiceResultException - if error

discoverServersOnNetwork

public ServerOnNetwork[] discoverServersOnNetwork(String connectUrl,
                                                  String discoverServerEndpointUri)
                                           throws ServiceResultException
Discover ServerOnNetwork records from LDS

Parameters:
connectUrl - address that contains the socket address to the endpoint
discoverServerEndpointUri - endpointURI or ""
Returns:
ServerOnNetwork records
Throws:
ServiceResultException - if error

discoverServersOnNetwork

public ServerOnNetwork[] discoverServersOnNetwork(String connectUrl,
                                                  String discoverServerEndpointUri,
                                                  String[] serverCapabilities)
                                           throws ServiceResultException
Discover ServerOnNetwork records from LDS

Parameters:
connectUrl - address that contains the socket address to the endpoint
discoverServerEndpointUri - endpointURI or ""
serverCapabilities - list of server capability filters
Returns:
ServerOnNetwork records
Throws:
ServiceResultException - if error

discoverServersOnNetwork

public FindServersOnNetworkResponse discoverServersOnNetwork(String connectUrl,
                                                             String discoverServerEndpointUri,
                                                             UnsignedInteger startingRecordId,
                                                             UnsignedInteger maxRecordsToReturn,
                                                             String[] serverCapabilities)
                                                      throws ServiceResultException
Get FindServersOnNetworkResponse to retrieve ServerOnNetwork records and lastCounterResetTime associated with them

Parameters:
connectUrl - address that contains the socket address to the endpoint
discoverServerEndpointUri - endpointURI or ""
startingRecordId - smallest id of records to be returned
maxRecordsToReturn - maximum number of records to return
serverCapabilities - list of server capability filters
Returns:
response to the FindServersOnNetworkRequest constructed from the parameters
Throws:
ServiceResultException - if error

getEncoderContext

public EncoderContext getEncoderContext()

getEncoderContext.

Returns:
a EncoderContext object.

setTimeout

public void setTimeout(int timeout)

setTimeout.

Parameters:
timeout - a int.

getTimeout

public int getTimeout()

getTimeout.

Returns:
a int.

setMaxMessageSize

public void setMaxMessageSize(int maxMessagSize)

setMaxMessageSize.

Parameters:
maxMessagSize - a int.

getMaxMessageSize

public int getMaxMessageSize()

getMaxMessageSize.

Returns:
a int.

getEndpointConfiguration

public EndpointConfiguration getEndpointConfiguration()

Getter for the field endpointConfiguration.

Returns:
a EndpointConfiguration object.

setEndpointConfiguration

public void setEndpointConfiguration(EndpointConfiguration endpointConfiguration)

Setter for the field endpointConfiguration.

Parameters:
endpointConfiguration - a EndpointConfiguration object.


Copyright © 2018. All rights reserved.