private void ReadFrom(XmlDictionaryReader reader) { try { reader.ReadFullStartElement(this.coordinationXmlDictionaryStrings.Register, this.coordinationXmlDictionaryStrings.Namespace); reader.MoveToStartElement(this.coordinationXmlDictionaryStrings.Protocol, this.coordinationXmlDictionaryStrings.Namespace); this.Protocol = WSAtomicTransactionStrings.WellKnownNameToProtocol(reader.ReadElementContentAsString().Trim(), this.protocolVersion); if (this.Protocol == ControlProtocol.None) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidMessageException(Microsoft.Transactions.SR.GetString("InvalidMessageBody"))); } this.ParticipantProtocolService = EndpointAddress.ReadFrom(MessagingVersionHelper.AddressingVersion(this.protocolVersion), reader, this.coordinationXmlDictionaryStrings.ParticipantProtocolService, this.coordinationXmlDictionaryStrings.Namespace); if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.Loopback, XD.DotNetAtomicTransactionExternalDictionary.Namespace)) { this.Loopback = reader.ReadElementContentAsGuid(); } while (reader.IsStartElement()) { reader.Skip(); } reader.ReadEndElement(); } catch (XmlException exception) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidMessageException(Microsoft.Transactions.SR.GetString("InvalidMessageBody"), exception)); } }
protected void AddTransportSecurityBindingElement(BindingElementCollection bindingElements) { TransportSecurityBindingElement item = new TransportSecurityBindingElement { MessageSecurityVersion = MessagingVersionHelper.SecurityVersion(this.protocolVersion) }; bindingElements.Add(item); }
protected void AddTextEncodingBindingElement(BindingElementCollection bindingElements) { TextMessageEncodingBindingElement item = new TextMessageEncodingBindingElement { WriteEncoding = Encoding.UTF8, MessageVersion = MessagingVersionHelper.MessageVersion(this.protocolVersion) }; bindingElements.Add(item); }
public void WriteTo(XmlDictionaryWriter writer) { writer.WriteStartElement(this.coordinationStrings.Prefix, this.coordinationXmlDictionaryStrings.Register, this.coordinationXmlDictionaryStrings.Namespace); XmlDictionaryString str = WSAtomicTransactionStrings.ProtocolToWellKnownName(this.Protocol, this.protocolVersion); writer.WriteStartElement(this.coordinationXmlDictionaryStrings.Protocol, this.coordinationXmlDictionaryStrings.Namespace); writer.WriteString(str); writer.WriteEndElement(); this.ParticipantProtocolService.WriteTo(MessagingVersionHelper.AddressingVersion(this.protocolVersion), writer, this.coordinationXmlDictionaryStrings.ParticipantProtocolService, this.coordinationXmlDictionaryStrings.Namespace); if (this.Loopback != Guid.Empty) { writer.WriteStartElement("mstx", XD.DotNetAtomicTransactionExternalDictionary.Loopback, XD.DotNetAtomicTransactionExternalDictionary.Namespace); writer.WriteValue(this.Loopback); writer.WriteEndElement(); } writer.WriteEndElement(); }
private void ReadFrom(XmlDictionaryReader reader) { try { reader.ReadFullStartElement(this.coordinationXmlDictionaryStrings.RegisterResponse, this.coordinationXmlDictionaryStrings.Namespace); this.CoordinatorProtocolService = EndpointAddress.ReadFrom(MessagingVersionHelper.AddressingVersion(this.protocolVersion), reader, this.coordinationXmlDictionaryStrings.CoordinatorProtocolService, this.coordinationXmlDictionaryStrings.Namespace); while (reader.IsStartElement()) { reader.Skip(); } reader.ReadEndElement(); } catch (XmlException exception) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidMessageException(Microsoft.Transactions.SR.GetString("InvalidMessageBody"), exception)); } }
public IAsyncResult BeginSendMessage(Message message, AsyncCallback callback, object state) { IAsyncResult result; if (base.from != null) { MessagingVersionHelper.SetReplyAddress(message, base.from, base.protocolVersion); } if (base.protocolVersion == ProtocolVersion.Version11) { message.Headers.ReplyTo = noneAddress; } base.AddRef(); try { result = base.GetChannel(message).BeginSend(message, callback, state); } catch (TimeoutException exception) { Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Warning); result = new SendMessageFailureAsyncResult(exception, callback, state); } catch (QuotaExceededException exception2) { Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Warning); result = new SendMessageFailureAsyncResult(exception2, callback, state); } catch (CommunicationException exception3) { Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.TraceHandledException(exception3, TraceEventType.Warning); result = new SendMessageFailureAsyncResult(exception3, callback, state); } catch (Exception exception4) { DebugTrace.Trace(TraceLevel.Error, "Unhandled exception {0} in DatagramProxy.BeginSendMessage: {1}", exception4.GetType().Name, exception4); throw Microsoft.Transactions.Bridge.DiagnosticUtility.InvokeFinalHandler(exception4); } return(result); }
private static void ReadFrom(CoordinationContext that, XmlDictionaryReader reader, XmlDictionaryString localName, XmlDictionaryString ns, Microsoft.Transactions.Wsat.Protocol.ProtocolVersion protocolVersion) { try { Uri uri; CoordinationXmlDictionaryStrings strings = CoordinationXmlDictionaryStrings.Version(protocolVersion); AtomicTransactionStrings strings2 = AtomicTransactionStrings.Version(protocolVersion); reader.ReadFullStartElement(localName, strings.Namespace); reader.MoveToStartElement(strings.Identifier, strings.Namespace); that.unknownIdentifierAttributes = ReadOtherAttributes(reader, strings.Namespace); that.contextId = reader.ReadElementContentAsString().Trim(); if ((that.contextId.Length == 0) || (that.contextId.Length > 0x100)) { throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCoordinationContextException(Microsoft.Transactions.SR.GetString("InvalidCoordinationContext"))); } if (!Uri.TryCreate(that.contextId, UriKind.Absolute, out uri)) { throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCoordinationContextException(Microsoft.Transactions.SR.GetString("InvalidCoordinationContext"))); } if (reader.IsStartElement(strings.Expires, strings.Namespace)) { that.unknownExpiresAttributes = ReadOtherAttributes(reader, strings.Namespace); int num = reader.ReadElementContentAsInt(); if (num < 0) { throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCoordinationContextException(Microsoft.Transactions.SR.GetString("InvalidCoordinationContext"))); } that.expiration = (uint)num; that.expiresPresent = true; } reader.MoveToStartElement(strings.CoordinationType, strings.Namespace); if (reader.ReadElementContentAsString().Trim() != strings2.Namespace) { throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCoordinationContextException(Microsoft.Transactions.SR.GetString("InvalidCoordinationContext"))); } that.registrationRef = EndpointAddress.ReadFrom(MessagingVersionHelper.AddressingVersion(protocolVersion), reader, strings.RegistrationService, strings.Namespace); if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.IsolationLevel, XD.DotNetAtomicTransactionExternalDictionary.Namespace)) { that.isoLevel = (System.Transactions.IsolationLevel)reader.ReadElementContentAsInt(); if (((that.IsolationLevel < System.Transactions.IsolationLevel.Serializable) || (that.IsolationLevel > System.Transactions.IsolationLevel.Unspecified)) || (that.IsolationLevel == System.Transactions.IsolationLevel.Snapshot)) { throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCoordinationContextException(Microsoft.Transactions.SR.GetString("InvalidCoordinationContext"))); } } if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.IsolationFlags, XD.DotNetAtomicTransactionExternalDictionary.Namespace)) { that.isoFlags = (System.ServiceModel.Transactions.IsolationFlags)reader.ReadElementContentAsInt(); } if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.Description, XD.DotNetAtomicTransactionExternalDictionary.Namespace)) { that.description = reader.ReadElementContentAsString().Trim(); } if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.LocalTransactionId, XD.DotNetAtomicTransactionExternalDictionary.Namespace)) { that.localTxId = reader.ReadElementContentAsGuid(); } if (OleTxTransactionHeader.IsStartPropagationTokenElement(reader)) { that.propToken = OleTxTransactionHeader.ReadPropagationTokenElement(reader); } if (reader.IsStartElement()) { XmlDocument document = new XmlDocument(); that.unknownData = new List <System.Xml.XmlNode>(5); while (reader.IsStartElement()) { System.Xml.XmlNode item = document.ReadNode(reader); that.unknownData.Add(item); } } reader.ReadEndElement(); } catch (XmlException exception) { throw Microsoft.Transactions.Bridge.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidCoordinationContextException(Microsoft.Transactions.SR.GetString("InvalidCoordinationContext"), exception)); } }
public void WriteContent(XmlDictionaryWriter writer) { if ((this.isoLevel != System.Transactions.IsolationLevel.Unspecified) || (this.localTxId != Guid.Empty)) { writer.WriteXmlnsAttribute("mstx", XD.DotNetAtomicTransactionExternalDictionary.Namespace); } writer.WriteStartElement(this.coordinationStrings.Prefix, this.coordinationXmlDictionaryStrings.Identifier, this.coordinationXmlDictionaryStrings.Namespace); if (this.unknownIdentifierAttributes != null) { foreach (System.Xml.XmlNode node in this.unknownIdentifierAttributes) { node.WriteTo(writer); } } writer.WriteString(this.contextId); writer.WriteEndElement(); if (this.expiresPresent) { writer.WriteStartElement(this.coordinationXmlDictionaryStrings.Expires, this.coordinationXmlDictionaryStrings.Namespace); if (this.unknownExpiresAttributes != null) { foreach (System.Xml.XmlNode node2 in this.unknownExpiresAttributes) { node2.WriteTo(writer); } } writer.WriteValue((long)this.expiration); writer.WriteEndElement(); } writer.WriteStartElement(this.coordinationXmlDictionaryStrings.CoordinationType, this.coordinationXmlDictionaryStrings.Namespace); writer.WriteString(this.atomicTransactionXmlDictionaryStrings.Namespace); writer.WriteEndElement(); this.registrationRef.WriteTo(MessagingVersionHelper.AddressingVersion(this.protocolVersion), writer, this.coordinationXmlDictionaryStrings.RegistrationService, this.coordinationXmlDictionaryStrings.Namespace); if (this.isoLevel != System.Transactions.IsolationLevel.Unspecified) { writer.WriteStartElement(XD.DotNetAtomicTransactionExternalDictionary.IsolationLevel, XD.DotNetAtomicTransactionExternalDictionary.Namespace); writer.WriteValue((int)this.isoLevel); writer.WriteEndElement(); } if (this.isoFlags != 0) { writer.WriteStartElement(XD.DotNetAtomicTransactionExternalDictionary.IsolationFlags, XD.DotNetAtomicTransactionExternalDictionary.Namespace); writer.WriteValue((int)this.isoFlags); writer.WriteEndElement(); } if (!string.IsNullOrEmpty(this.description)) { writer.WriteStartElement(XD.DotNetAtomicTransactionExternalDictionary.Description, XD.DotNetAtomicTransactionExternalDictionary.Namespace); writer.WriteValue(this.description); writer.WriteEndElement(); } if (this.localTxId != Guid.Empty) { writer.WriteStartElement(XD.DotNetAtomicTransactionExternalDictionary.LocalTransactionId, XD.DotNetAtomicTransactionExternalDictionary.Namespace); writer.WriteValue(this.localTxId); writer.WriteEndElement(); } if (this.propToken != null) { OleTxTransactionHeader.WritePropagationTokenElement(writer, this.propToken); } if (this.unknownData != null) { int count = this.unknownData.Count; for (int i = 0; i < count; i++) { this.unknownData[i].WriteTo(writer); } } }
public void WriteTo(XmlDictionaryWriter writer) { writer.WriteStartElement(this.coordinationStrings.Prefix, this.coordinationXmlDictionaryStrings.RegisterResponse, this.coordinationXmlDictionaryStrings.Namespace); this.CoordinatorProtocolService.WriteTo(MessagingVersionHelper.AddressingVersion(this.protocolVersion), writer, this.coordinationXmlDictionaryStrings.CoordinatorProtocolService, this.coordinationXmlDictionaryStrings.Namespace); writer.WriteEndElement(); }