예제 #1
0
        public Message SerializeRequest(MessageVersion messageVersion, object[] parameters)
        {
            object[] parts = null;

            if (messageVersion == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("messageVersion");
            }

            if (parameters == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parameters");
            }
            if (_requestDescription.IsTypedMessage)
            {
                TypedMessageParts typedMessageParts = new TypedMessageParts(parameters[0], _requestDescription);

                // copy values from the actual field/properties
                parts = new object[typedMessageParts.Count];
                typedMessageParts.GetTypedMessageParts(parts);
            }
            else
            {
                parts = parameters;
            }
            Message msg = new OperationFormatterMessage(this, messageVersion,
                                                        _action == null ? null : ActionHeader.Create(_action, messageVersion.Addressing),
                                                        parts, null, true /*isRequest*/);

            AddPropertiesToMessage(msg, _requestDescription, parts);
            AddHeadersToMessage(msg, _requestDescription, parts, true /*isRequest*/);

            return(msg);
        }
예제 #2
0
        public Message SerializeRequest(MessageVersion messageVersion, object[] parameters)
        {
            object[] values = null;
            if (messageVersion == null)
            {
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("messageVersion");
            }
            if (parameters == null)
            {
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parameters");
            }
            if (this.requestDescription.IsTypedMessage)
            {
                TypedMessageParts parts = new TypedMessageParts(parameters[0], this.requestDescription);
                values = new object[parts.Count];
                parts.GetTypedMessageParts(values);
            }
            else
            {
                values = parameters;
            }
            Message message = new OperationFormatterMessage(this, messageVersion, (this.action == null) ? null : ActionHeader.Create(this.action, messageVersion.Addressing), values, null, true);

            this.AddPropertiesToMessage(message, this.requestDescription, values);
            this.AddHeadersToMessage(message, this.requestDescription, values, true);
            return(message);
        }
예제 #3
0
        public Message SerializeReply(MessageVersion messageVersion, object[] parameters, object result)
        {
            object[] parts      = null;
            object   resultPart = null;

            if (messageVersion == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(messageVersion));
            }

            if (parameters == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(parameters));
            }

            if (replyDescription.IsTypedMessage)
            {
                // If the response is a typed message then it must
                // me the response (as opposed to an out param).  We will
                // serialize the response in the exact same way that we
                // would serialize a bunch of outs (with no return value).

                TypedMessageParts typedMessageParts = new TypedMessageParts(result, replyDescription);

                // make a copy of the list so that we have the actual values of the field/properties
                parts = new object[typedMessageParts.Count];
                typedMessageParts.GetTypedMessageParts(parts);

                resultPart = null;
            }
            else
            {
                parts      = parameters;
                resultPart = result;
            }

            Message msg = new OperationFormatterMessage(this, messageVersion,
                                                        replyAction == null ? null : ActionHeader.Create(replyAction, messageVersion.Addressing),
                                                        parts, resultPart, false /*isRequest*/);

            AddPropertiesToMessage(msg, replyDescription, parts);
            AddHeadersToMessage(msg, replyDescription, parts, false /*isRequest*/);
            return(msg);
        }