Opc.Ua.EndpointBase.InvokeService C# (CSharp) Method

InvokeService() public method

Dispatches an incoming binary encoded request.
public InvokeService ( InvokeServiceMessage request ) : InvokeServiceResponseMessage
request InvokeServiceMessage Request.
return InvokeServiceResponseMessage
        public virtual InvokeServiceResponseMessage InvokeService(InvokeServiceMessage request)
        {          
            IServiceRequest decodedRequest = null;
            IServiceResponse  response = null;          
            
            // create context for request and reply.
            ServiceMessageContext context = MessageContext;
            
            try
            {
                // check for null.
                if (request == null || request.InvokeServiceRequest == null)
                {
                    throw new ServiceResultException(StatusCodes.BadDecodingError, Utils.Format("Null message cannot be processed."));
                }
                
                // decoding incoming message.
                decodedRequest = BinaryDecoder.DecodeMessage(request.InvokeServiceRequest, null, context) as IServiceRequest;

                // invoke service.
                response = ProcessRequest(decodedRequest);
                
                // encode response.
                InvokeServiceResponseMessage outgoing = new InvokeServiceResponseMessage();
                outgoing.InvokeServiceResponse = BinaryEncoder.EncodeMessage(response, context);
                return outgoing;
            }
            catch (Exception e)
            {
                // create fault.
                ServiceFault fault = CreateFault(decodedRequest, e);
                
                // encode fault response.
                if (context == null)
                {
                    context = new ServiceMessageContext();
                }

                InvokeServiceResponseMessage outgoing = new InvokeServiceResponseMessage();
                outgoing.InvokeServiceResponse = BinaryEncoder.EncodeMessage(fault, context);
                return outgoing;
            }
        }
        #else