How to send return value of function from server to clien?.

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
sushilN
Jr. Member
Jr. Member
Posts: 3
Joined: 03 Nov 2017, 13:33

How to send return value of function from server to clien?.

Post by sushilN »

Hi,

I am using .NET based OPC UA SDK. I created one function as Addition and registered it on server side. I can successfully call and provide the input arguments for Addition function from client side. But I am not able to send the result of addition through output argument from server to client. It is always null. I don't understand how to send return value of addition function to client.

Thanks!

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re: How to send return value of function from server to clie

Post by Support Team »

Hello,

Please see the code of the DemoServer. There are Methods defined and implemented.

Code: Select all

        private StatusCode DoMultiply(
            RequestContext context,
            MethodHandle methodHandle,
            IList<Variant> inputArguments,
            List<StatusCode> inputArgumentResults,
            List<Variant> outputArguments)
        {
            double x = inputArguments[0].ToDouble();
            double y = inputArguments[1].ToDouble();

            outputArguments[0] = x * y;

            return StatusCodes.Good;
        }
Best regards
Unified Automation Support Team

sushilN
Jr. Member
Jr. Member
Posts: 3
Joined: 03 Nov 2017, 13:33

Re: How to send return value of function from server to clie

Post by sushilN »

Hi,
Thanks for the reply. Yes I am using the same method definition. If we look at the function parameters while debugging, outputArguments is always null. So thats why I am not able to put return value into outputArguments. So It will throw the exception. Even if I initialise outputArguments inside the function and assign the return value, on the client side outputArgument result is always null. So I am not getting how to assign the return value to the outputArguments . I am using examples/ServerGettingStarted/Lesson04.

Thnaks!

sushilN
Jr. Member
Jr. Member
Posts: 3
Joined: 03 Nov 2017, 13:33

Re: How to send return value of function from server to clie

Post by sushilN »

Hi,

I am able to solve the problem. Just need to add OutputArguments UAVariable in XML file.

Thanks.!

Post Reply