Calling a Method (without InputArguments, OutputArguments) throws "A requested item was not found or a search operation ended without success."
============================================== version: org.eclipse.milo:sdk-client:0.6.0
============================================== Expected behaviour: the method can be called without InputArguments, and OutputArguments
============================================== Observed behaviour: the method can be called by UaEpert, but milo throws an exception
If I add the InputArguments and OutputArguments to the model, then the call from milo works...
============================================== The our code to call the method via milo:
var parentNode = readObjectNode(methodNode.parentId(), ns);
----> var method = parentNode.getMethod(methodNode.methodName()); var inputs = Stream.of(inputParams).map(Variant::new).toArray(Variant[]::new);
the ----> marks the line from where the exception is thowrn
============================================== The exception:
java.util.concurrent.ExecutionException: UaException: status=Bad_NotFound, message=A requested item was not found or a search operation ended without success.
StatusCode{name=Bad_NotFound, value=0x803E0000, quality=bad}
Caused by: UaException: status=Bad_NotFound, message=A requested item was not found or a search operation ended without success. at org.eclipse.milo.opcua.stack.core.util.FutureUtils.failedUaFuture(FutureUtils.java:99) at org.eclipse.milo.opcua.stack.core.util.FutureUtils.failedUaFuture(FutureUtils.java:87) at org.eclipse.milo.opcua.sdk.client.nodes.UaNode.lambda$getPropertyNodeAsync$18(UaNode.java:1071) at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1146) at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506) at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2137) at org.eclipse.milo.opcua.stack.client.UaStackClient.lambda$deliverResponse$5(UaStackClient.java:309) at org.eclipse.milo.opcua.stack.core.util.ExecutionQueue$Task.run(ExecutionQueue.java:119) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) at java.base/java.lang.Thread.run(Thread.java:832)
============================================== OPCUA method Definition:
<UAMethod NodeId="ns=1;i=7005" BrowseName="1:performSomeOperation">
<DisplayName>PerformSomeOperation</DisplayName>
<References>
<Reference ReferenceType="HasComponent" IsForward="false">ns=1;i=5002</Reference>
</References>
<Extensions>
<Extension>
<NodeAccessInfo SigningRequired="true" xmlns="http://unifiedautomation.com/Configuration/NodeSet.xsd" EncryptionRequired="true">
<Group ID="com.mycompany">R;B</Group>
</NodeAccessInfo>
</Extension>
</Extensions>
</UAMethod>
============================================== The milo code from where the exception is thrown: in the class UaObjectNode.java: in the method getMethodAsync on the line:
UaMethodNode methodNode = (UaMethodNode) node;
the correct OPCUA method was found by the search, but the next statements return an exception.
public CompletableFuture<UaMethod> getMethodAsync(QualifiedName methodName) {
UInteger nodeClassMask = uint(NodeClass.Method.getValue());
UInteger resultMask = uint(BrowseResultMask.All.getValue());
CompletableFuture<BrowseResult> future = client.browse(
new BrowseDescription(
getNodeId(),
BrowseDirection.Forward,
Identifiers.HasComponent,
true,
nodeClassMask,
resultMask
)
);
return future.thenCompose(result -> {
StatusCode statusCode = result.getStatusCode();
if (statusCode != null && statusCode.isGood()) {
Optional<ExpandedNodeId> methodNodeId = l(result.getReferences())
.stream()
.filter(rd -> Objects.equals(methodName, rd.getBrowseName()))
.findFirst()
.map(ReferenceDescription::getNodeId);
return methodNodeId
.map(xni -> {
AddressSpace addressSpace = client.getAddressSpace();
return addressSpace.toNodeIdAsync(xni).thenCompose(
nodeId ->
addressSpace.getNodeAsync(nodeId).thenCompose(node -> {
UaMethodNode methodNode = (UaMethodNode) node;
return methodNode.readInputArgumentsAsync().thenCombine(
methodNode.readOutputArgumentsAsync(),
(in, out) -> new UaMethod(client, this, methodNode, in, out)
);
})
);
})
.orElse(failedFuture(new UaException(StatusCodes.Bad_NotFound, "method not found: " + methodName)));
} else {
return failedFuture(new UaException(statusCode, "browsing for MethodNodes failed"));
}
});
}
============================================== The definitions from milo: MethodNodeProperties
/**
* The InputArguments Property is used to specify the arguments that shall
* be used by a client when calling the Method.
*/
public static final QualifiedProperty<Argument[]> InputArguments = new QualifiedProperty<>(
Namespaces.OPC_UA,
"InputArguments",
Identifiers.Argument.expanded(),
ValueRanks.OneDimension,
Argument[].class
);
/**
* The OutputArguments Property specifies the result returned from the
* Method call.
*/
public static final QualifiedProperty<Argument[]> OutputArguments = new QualifiedProperty<>(
Namespaces.OPC_UA,
"OutputArguments",
Identifiers.Argument.expanded(),
ValueRanks.OneDimension,
Argument[].class
);
If I add InputArguments and OutputArguments the call from milo works...
This was fixed in 0.6.1. See issue #815 and PR #816.
the fix confirmed thanks!