Example #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);
        }
Example #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);
        }
Example #3
0
        public void DeserializeRequest(Message message, object[] parameters)
        {
            if (message == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("message");
            }

            if (parameters == null)
            {
                throw TraceUtility.ThrowHelperError(new ArgumentNullException("parameters"), message);
            }

            try
            {
                if (_requestDescription.IsTypedMessage)
                {
                    object            typeMessageInstance = CreateTypedMessageInstance(_requestDescription.MessageType);
                    TypedMessageParts typedMessageParts   = new TypedMessageParts(typeMessageInstance, _requestDescription);
                    object[]          parts = new object[typedMessageParts.Count];

                    GetPropertiesFromMessage(message, _requestDescription, parts);
                    GetHeadersFromMessage(message, _requestDescription, parts, true /*isRequest*/);
                    DeserializeBodyContents(message, parts, true /*isRequest*/);

                    // copy values into the actual field/properties
                    typedMessageParts.SetTypedMessageParts(parts);

                    parameters[0] = typeMessageInstance;
                }
                else
                {
                    GetPropertiesFromMessage(message, _requestDescription, parameters);
                    GetHeadersFromMessage(message, _requestDescription, parameters, true /*isRequest*/);
                    DeserializeBodyContents(message, parameters, true /*isRequest*/);
                }
            }
            catch (XmlException xe)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                          OperationFormatter.CreateDeserializationFailedFault(
                              SR.Format(SR.SFxErrorDeserializingRequestBodyMore, _operationName, xe.Message),
                              xe));
            }
            catch (FormatException fe)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                          OperationFormatter.CreateDeserializationFailedFault(
                              SR.Format(SR.SFxErrorDeserializingRequestBodyMore, _operationName, fe.Message),
                              fe));
            }
            catch (SerializationException se)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(
                                                                              SR.Format(SR.SFxErrorDeserializingRequestBodyMore, _operationName, se.Message),
                                                                              se));
            }
        }
Example #4
0
        public object DeserializeReply(Message message, object[] parameters)
        {
            if (message == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("message");
            }

            if (parameters == null)
            {
                throw TraceUtility.ThrowHelperError(new ArgumentNullException("parameters"), message);
            }

            try
            {
                object result = null;
                if (_replyDescription.IsTypedMessage)
                {
                    object            typeMessageInstance = CreateTypedMessageInstance(_replyDescription.MessageType);
                    TypedMessageParts typedMessageParts   = new TypedMessageParts(typeMessageInstance, _replyDescription);
                    object[]          parts = new object[typedMessageParts.Count];

                    GetPropertiesFromMessage(message, _replyDescription, parts);
                    GetHeadersFromMessage(message, _replyDescription, parts, false /*isRequest*/);
                    DeserializeBodyContents(message, parts, false /*isRequest*/);

                    // copy values into the actual field/properties
                    typedMessageParts.SetTypedMessageParts(parts);

                    result = typeMessageInstance;
                }
                else
                {
                    GetPropertiesFromMessage(message, _replyDescription, parameters);
                    GetHeadersFromMessage(message, _replyDescription, parameters, false /*isRequest*/);
                    result = DeserializeBodyContents(message, parameters, false /*isRequest*/);
                }
                return(result);
            }
            catch (XmlException xe)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(
                                                                              string.Format(SRServiceModel.SFxErrorDeserializingReplyBodyMore, _operationName, xe.Message), xe));
            }
            catch (FormatException fe)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(
                                                                              string.Format(SRServiceModel.SFxErrorDeserializingReplyBodyMore, _operationName, fe.Message), fe));
            }
            catch (SerializationException se)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(
                                                                              string.Format(SRServiceModel.SFxErrorDeserializingReplyBodyMore, _operationName, se.Message), se));
            }
        }
Example #5
0
        public object DeserializeReply(Message message, object[] parameters)
        {
            object obj4;

            if (message == null)
            {
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("message");
            }
            if (parameters == null)
            {
                throw TraceUtility.ThrowHelperError(new ArgumentNullException("parameters"), message);
            }
            try
            {
                object obj2 = null;
                if (this.replyDescription.IsTypedMessage)
                {
                    object            instance = CreateTypedMessageInstance(this.replyDescription.MessageType);
                    TypedMessageParts parts    = new TypedMessageParts(instance, this.replyDescription);
                    object[]          objArray = new object[parts.Count];
                    this.GetPropertiesFromMessage(message, this.replyDescription, objArray);
                    this.GetHeadersFromMessage(message, this.replyDescription, objArray, false);
                    this.DeserializeBodyContents(message, objArray, false);
                    parts.SetTypedMessageParts(objArray);
                    obj2 = instance;
                }
                else
                {
                    this.GetPropertiesFromMessage(message, this.replyDescription, parameters);
                    this.GetHeadersFromMessage(message, this.replyDescription, parameters, false);
                    obj2 = this.DeserializeBodyContents(message, parameters, false);
                }
                obj4 = obj2;
            }
            catch (XmlException exception)
            {
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(System.ServiceModel.SR.GetString("SFxErrorDeserializingReplyBodyMore", new object[] { this.operationName, exception.Message }), exception));
            }
            catch (FormatException exception2)
            {
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(System.ServiceModel.SR.GetString("SFxErrorDeserializingReplyBodyMore", new object[] { this.operationName, exception2.Message }), exception2));
            }
            catch (SerializationException exception3)
            {
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException(System.ServiceModel.SR.GetString("SFxErrorDeserializingReplyBodyMore", new object[] { this.operationName, exception3.Message }), exception3));
            }
            return(obj4);
        }
Example #6
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);
        }