getEndpoints
사전 준비 / 부대 조치
- Endpoint로 끌어온 후 다음을 사용하여 생성자 세션을 실제로 생성합니다.
- 서비스 간 검색을 하려면 다음을 사용하십시오. FindServers.
서명
public static List<EndpointDescription> getEndpoints(String endpointUrl);
public static List<EndpointDescription> getEndpoints(String endpointUrl, int timeoutMs);
임시 SecureChannel(None mode)로 서버에 연결하여 Endpoint 목록을 가져온 후 즉시 연결을 끊습니다. 세션이 필요하지 않습니다. 기본 시간 초과는 10초입니다.
EndpointDescription 필드
| 방법 | 유형 | 설명 |
|---|---|---|
| getEndpointUrl() | String | 실제 엔드포인트 URL |
| getSecurityMode() | Enums.MessageSecurityMode | None / Sign / SignAndEncrypt |
| getSecurityPolicyUri() | String | 알고리즘 패키지 URI |
| getServerCertificate() | byte[] | 서버 인증서 (DER) |
| getServerApplicationUri() | String | 서버 애플리케이션 URI |
| getServerProductUri() | String | 서버 제품 URI |
| getServerApplicationName() | String | 서버 애플리케이션 이름 |
| getServerApplicationType() | int | 0=Server / 1=Client / 2=ClientAndServer / 3=DiscoveryServer |
| getUserTokens() | List<UserTokenPolicy> | 지원되는 로그인 방식 |
| getTransportProfileUri() | String | 전송 프로필 (일반적으로 UA-TCP) |
| getSecurityLevel() | byte | 서버 측 추천 우선순위 |
UserTokenPolicy 필드
| 방법 | 설명 |
|---|---|
| getPolicyId() | 서버에서 제공한 ID로, 클라이언트 활성화 시 전송됨 |
| getTokenType() | Enums.UserTokenType Anonymous / Username / Certificate / Issued |
사용법
List<EndpointDescription> endpoints =
OpcUaDiscovery.getEndpoints("opc.tcp://server:4840");
System.out.println("Server has " + endpoints.size() + " endpoints:");
for (EndpointDescription ep : endpoints) {
System.out.println();
System.out.println(" URL: " + ep.getEndpointUrl());
System.out.println(" Mode: " + ep.getSecurityMode());
System.out.println(" Policy: " + ep.getSecurityPolicyUri());
System.out.println(" Tokens:");
for (UserTokenPolicy t : ep.getUserTokens()) {
System.out.println(" - " + t.getTokenType() + " (PolicyId=" + t.getPolicyId() + ")");
}
}
대표적인 출력
Server has 4 endpoints:
URL: opc.tcp://server:4840
Mode: None
Policy: http://opcfoundation.org/UA/SecurityPolicy#None
Tokens:
- Anonymous
URL: opc.tcp://server:4840
Mode: Sign
Policy: http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256
Tokens:
- Anonymous
- Username
URL: opc.tcp://server:4840
Mode: SignAndEncrypt
Policy: http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256
Tokens:
- Username
- Certificate
서버 측에서는 일반적으로 여러 가지 조합(None / Sign / SignAndEncrypt × Anonymous / Username / Certificate)을 제공하며, 클라이언트는 필요에 따라 선택합니다.
예외
| 예외 | 의미 |
|---|---|
| OpcUaException(BadCommunicationError) | 인터넷 / 서버에 연결할 수 없음 |
| OpcUaException(BadServiceUnsupported) | 서버 측에서 Discovery를 지원하지 않습니다 (드문 경우). |