Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [milo-dev] call method failed: badTypeMisMatch(0x80740000)

Step 1:  Set the input arguments.  For example, the method below multiplies two Doubles.  You will set your values appropriately, e.g. Integer and Byte:

NodeId objectId = new NodeId(4, "Demo.Method");
NodeId methodId = new NodeId(4, "Demo.Method.Multiply");

List<Object> inputArguments = new ArrayList<>();
inputArguments.add(new Double(4.0));
inputArguments.add(new Double(2.0));
Step 2:  Call the method and get the result (8.0):

List<Object> outputs = uaClient.callMethodSynch(objectId, methodId, inputArguments);

logger.info("Result: " + outputs.get(0));

callMethodSynch() is implemented as below:
private static final int REQUEST_TIMEOUT = 5000;

private static final TimeUnit REQUEST_TIMEOUT_UNIT = TimeUnit.MILLISECONDS;

public synchronized List<Object> callMethodSynch(NodeId objectId, NodeId methodId, List<Object> inputArguments)
throws Exception {
try {
Variant[] variants = new Variant[inputArguments.size()];
for (int i = 0; i < inputArguments.size(); i++) {
variants[i] = new Variant(inputArguments.get(i));
}

CallMethodRequest request = new CallMethodRequest(objectId, methodId, variants);

CompletableFuture<List<Object>> cf = opcUaClient.call(request).thenCompose(result -> {
StatusCode statusCode = result.getStatusCode();

if (statusCode.isGood()) {
Variant[] outputArguments = result.getOutputArguments();

List<Object> outputs = new ArrayList<>(outputArguments.length);

for (int i = 0; i < outputArguments.length; i++) {
outputs.add(outputArguments[i].getValue());
}

return CompletableFuture.completedFuture(outputs);
} else {
CompletableFuture<List<Object>> f = new CompletableFuture<>();
f.completeExceptionally(new org.eclipse.milo.opcua.stack.core.UaException(statusCode));
return f;
}
});

List<Object> results = cf.get(REQUEST_TIMEOUT, REQUEST_TIMEOUT_UNIT);

clientFuture.complete(opcUaClient);

return results;
} catch (Exception e) {
throw new Exception(e.getMessage());
}
}

Virus-free. www.avast.com

On Tue, Nov 28, 2017 at 7:07 PM, 殷胜兵 <yinshengbing@xxxxxxxxxxxxxxxxxx> wrote:
hi,
    server define a method:test(unsigned int input1, unsigned char input2), how the client call this method?





------------------
殷胜兵   150 7239 4089

武汉中科牛津波谱技术有限公司
Wuhan Zhongke-Niujin Magnetic Resonance Technology Co., LTD.
 

_______________________________________________
milo-dev mailing list
milo-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/milo-dev



Back to the top