object DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, bool isRequest) { object val; try { val = part.ReadObject(reader); } catch (System.InvalidOperationException e) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException( SR.Format(SR.SFxInvalidMessageBodyErrorDeserializingParameter, part.Description.Namespace, part.Description.Name), e)); } catch (System.Runtime.Serialization.InvalidDataContractException e) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException( SR.Format(SR.SFxInvalidMessageBodyErrorDeserializingParameter, part.Description.Namespace, part.Description.Name), e)); } catch (System.FormatException e) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( OperationFormatter.CreateDeserializationFailedFault( SR.Format(SR.SFxInvalidMessageBodyErrorDeserializingParameterMore, part.Description.Namespace, part.Description.Name, e.Message), e)); } catch (System.Runtime.Serialization.SerializationException e) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( OperationFormatter.CreateDeserializationFailedFault( SR.Format(SR.SFxInvalidMessageBodyErrorDeserializingParameterMore, part.Description.Namespace, part.Description.Name, e.Message), e)); } return(val); }
public void DeserializeRequest(Message message, object[] parameters) { if (message == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(message)); } if (parameters == null) { throw TraceUtility.ThrowHelperError(new ArgumentNullException(nameof(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)); } }
public void DeserializeRequest(Message message, object[] parameters) { if (message == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(message))); } if (parameters == null) { throw TraceUtility.ThrowHelperError(new ArgumentNullException(nameof(parameters)), message); } try { if (message.IsEmpty) { if (_requestWrapperName == null) { return; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SerializationException(SR.SFxInvalidMessageBodyEmptyMessage)); } XmlDictionaryReader bodyReader = message.GetReaderAtBodyContents(); using (bodyReader) { DeserializeRequest(bodyReader, parameters); message.ReadFromBodyContentsToEnd(bodyReader); } } catch (XmlException xe) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( OperationFormatter.CreateDeserializationFailedFault( SR.Format(SR.SFxErrorDeserializingRequestBodyMore, _operation.Name, xe.Message), xe)); } catch (FormatException fe) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( OperationFormatter.CreateDeserializationFailedFault( SR.Format(SR.SFxErrorDeserializingRequestBodyMore, _operation.Name, fe.Message), fe)); } catch (SerializationException se) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CommunicationException( SR.Format(SR.SFxErrorDeserializingRequestBodyMore, _operation.Name, se.Message), se)); } }