04/11/2018
Hi,
I am trying to call a method without of output parameter.
This is how i created the method on server side:
#region Input MethodMethodState ReceiveMessageMethod = CreateMethod(root, "ReceiveMessage", "ReceiveMessage");// set input argumentsReceiveMsiMethod.InputArguments = new PropertyState<Argument[]>(ReceiveMsiMethod);ReceiveMsiMethod.InputArguments.NodeId = new NodeId(ReceiveMsiMethod.BrowseName.Name + "InArgs", NamespaceIndex);ReceiveMsiMethod.InputArguments.BrowseName = BrowseNames.InputArguments;ReceiveMsiMethod.InputArguments.DisplayName = ReceiveMsiMethod.InputArguments.BrowseName.Name;ReceiveMsiMethod.InputArguments.TypeDefinitionId = VariableTypeIds.PropertyType;ReceiveMsiMethod.InputArguments.ReferenceTypeId = ReferenceTypeIds.HasProperty;ReceiveMsiMethod.InputArguments.DataType = DataTypeIds.String;ReceiveMsiMethod.InputArguments.ValueRank = ValueRanks.OneDimension;ReceiveMsiMethod.InputArguments.Value = new Argument[]{new Argument() { Name = "String value", Description = "String value", DataType = DataTypeIds.String, ValueRank = ValueRanks.Scalar }};ReceiveMessageMethod.OnCallMethod = new GenericMethodCalledEventHandler(OnInputCall);
and the default OnInputCall method from foundation's SDK:
private ServiceResult OnInputCall(ISystemContext context,MethodState method,IList<object> inputArguments,IList<object> outputArguments){// all arguments must be provided.if (inputArguments.Count < 1){return StatusCodes.BadArgumentsMissing;}return ServiceResult.Good;}
This is how I call this method on client side:
IList<object> val = session.Call(new NodeId("ns=2;s=Root"), new NodeId("ns=2;s=ReceiveMessage"), "Test string");
The problem now, is that I want to know if the call was successful or not. On client side, how can I get the ServiceResult from server?
05/30/2017
Returning "good" StatusCodes other than a simple "good" is not supported for service calls. A Method call is similar to a service call but you could call the raw Call method on the channel if you need a non-simple Good value. I do not recommend it because a lot of programming languages impose this limitation on the APIs exposed to developers.
03/01/2017
Hello Randy,
I have a question related to Method StatusCodes, and I thought it would be better to continue the discussion here rather than starting a new topic.
The question is: if I want to use self-defined StatusCodes, I would define an output argument, in which I can store this self-defined StatusCode. But in this case, which StatusCode should the Call Service return?
For example: I have a method which divide two doubles and returns the dicvision result and a the mathimatical operation StatusCode. So the method has two input arguments (double x, double y) and two output arguments (double z=x/y, int status). By division by zero the mathimatical operation is wrong and I write, let's say BAD_MATH_ZERO_DIVISION, in the status output argument. Should the call service StatusCode be in this case UA_STATUSCODE_GOOD or should I use a UA StatusCode, which represents an error like UA_STATUSCODE_BAD_INVALID_ARGUMENT?
Best regards
Sameer
05/30/2017
StatusCodes are set by the specification and cannot be replaced with vendor defined codes.
You should look at the available status codes and find one that is close.
If you need something more specific you can use the SymbolicName in the DiagnosticInfo to return your vendor defined code.
Adding an output argument is also an option.
1 Guest(s)