1

I am new with OPC-UA. Currently after studying the demos and examples provided by Unified Automation documentation. I was able to write a simple code which connects to a server end point and calls a method. But sadly that method does not return the expected out. Moreover, if I call the same method on the same server and the same URL with the same parameters through the UAExpert I get the expected result. I am at my wits end and would appreciate any help below is the code that I have currently written.

Do let me know if i have missed anything in the code.

public void Connect(string endpointUrl)
        {
            AppSession.UserIdentity = new UserIdentity();
            AppSession.SessionName = "urn:ACGIDT053:UnifiedAutomation:UaExpert";
            //AppSession.Application.CertificateGroups[0];            
            //string endpointUrl = "opc.tcp://212.43.72.27:51510/UA/WipotecServer/";
            AppSession.Connect(endpointUrl, SecuritySelection.None);
            ICertificate certificateServer = SecurityUtils.LoadCertificate(AppSession.EndpointDescription.ServerCertificate);
            AppSession.Application.TrustedStore.Add(certificateServer, true);

            /// [Step 1]
            // parse the object id.
            NodeId objectId = NodeId.Parse("ns=2;i=15108");

            // get the selected method id.            
            NodeId methodId = NodeId.Parse("ns=2;i=15057");

            // get input arguments.
            UInt32 a = 2;
            List<Variant> inputArguments = new List<Variant>
            {
                new Variant(string.Empty, TypeInfo.Scalars.String), new Variant(a,TypeInfo.Scalars.UInt32), new Variant(string.Empty, TypeInfo.Scalars.String),
                new Variant(null, TypeInfo.Arrays.ExtensionObject), new Variant(string.Empty, TypeInfo.Scalars.String)
            };

            /// [Step 2]
            List<StatusCode> inputArgumentErrors;
            List<Variant> outputArguments = null;

            // call the method on the server.
            StatusCode error = AppSession.Call(
                objectId,
                methodId,
                inputArguments,
                out inputArgumentErrors,
                out outputArguments);

            AppSession.Disconnect();

        }

There are no exceptions that are returned in the code by the server all input arguments are good and so is the error status.

UPDATE: The filter expression should be: (ip.src == 172.16.55.144 && ip.dst == 212.43.72.27) || (ip.dst == 172.16.55.144 && ip.src == 212.43.72.27) Please find below links for the packets from Wireshark: uaexpert: https://1drv.ms/u/s!ArxC3dVLzVTqhUGxsO1aDssb45er?e=tBcBRz localClient: https://1drv.ms/u/s!ArxC3dVLzVTqhUANVvKmHG5ULW6_?e=cAO5C8

UPDATE: Code updated as per suggestions from comments. Packets from wireshark for updated code: https://1drv.ms/u/s!ArxC3dVLzVTqhUIuqudrkrjMn8kn?e=fAZOtd

Mike M.
  • 38,532
  • 8
  • 99
  • 95
  • Could you maybe provide a small packet capture of both CallMethod Request/Response, from both your OPC UA Client and UA Expert ? – Camille G. Aug 12 '19 at 12:46
  • Packet capture with Wireshark. – Kevin Herron Aug 12 '19 at 12:55
  • @AnuragPatil You are not sending the right InputArguments. I think you should at least specify the Type of the Variant even when their values are Empty or null with CallRequest. Currently you are only specifying the value 2 of type UInt32 for the arg[1]. You should also have arg[0], arg[2] and arg[4] as String and arg[3] as Array of ExtensionObject. But yes this is strange that the OPC UA Server do not return any Bad StatusCode in the CallResponse InputArgumentResults – Camille G. Aug 13 '19 at 06:55
  • @AnuragPatil Can you send a new packet capture from your updated OPC UA Client code ? – Camille G. Aug 14 '19 at 06:44
  • @AnuragPatil Your 4th arg (arg[3] is Null whereas in UaExpert the Variant type is an Array of ExtensionObject, empty but still the type is defined ! – Camille G. Aug 19 '19 at 06:48
  • 3
    Please don't make more work for others by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the [CC BY-SA 4.0 license](//creativecommons.org/licenses/by-sa/4.0), for SE to distribute the content (i.e. regardless of your future choices). By SE policy, the non-vandalized version is distributed. Thus, any vandalism will be reverted. Please see: [How does deleting work? …](//meta.stackexchange.com/q/5221). If permitted to delete, there's a "delete" button below the post, on the left, but it's only in browsers, not the mobile app. – Makyen Sep 10 '19 at 23:45

0 Answers0