+ if (headers != null)
+ return headers;
+ else
+ return new SoapHeaderCollection ();
+ }
+
+ class HeaderSerializationHelper
+ {
+ SoapHeaderCollection headers;
+ XmlSerializer headerSerializer;
+
+ public HeaderSerializationHelper (XmlSerializer headerSerializer)
+ {
+ this.headers = new SoapHeaderCollection ();
+ this.headerSerializer = headerSerializer;
+ }
+
+ public SoapHeaderCollection Deserialize (XmlTextReader xmlReader)
+ {
+ try {
+ headerSerializer.UnknownElement += new XmlElementEventHandler (OnAddUnknownHeader);
+ object[] headerArray = (object[]) headerSerializer.Deserialize (xmlReader);
+ foreach (SoapHeader h in headerArray)
+ if (h != null) headers.Add (h);
+ return headers;
+ } finally {
+ headerSerializer.UnknownElement -= new XmlElementEventHandler (OnAddUnknownHeader);
+ }
+ }
+
+ void OnAddUnknownHeader (object sender, XmlElementEventArgs e)
+ {
+ headers.Add (new SoapUnknownHeader (e.Element));
+ }
+ }
+
+#if NET_2_0
+ public static SoapException Soap12FaultToSoapException (Soap12Fault fault)
+ {
+ Soap12FaultReasonText text =
+ fault.Reason != null &&
+ fault.Reason.Texts != null &&
+ fault.Reason.Texts.Length > 0 ?
+ fault.Reason.Texts [fault.Reason.Texts.Length - 1] : null;
+ XmlNode detail = (fault.Detail == null) ? null :
+ (fault.Detail.Children != null &&
+ fault.Detail.Children.Length > 0) ?
+ (XmlNode) fault.Detail.Children [0] :
+ (fault.Detail.Attributes != null &&
+ fault.Detail.Attributes.Length > 0) ?
+ fault.Detail.Attributes [0] : null;
+ SoapFaultSubCode subcode = Soap12Fault.GetSoapFaultSubCode (fault.Code.Subcode);
+ return new SoapException (
+ text != null ? text.Value : null,
+ fault.Code.Value, null, fault.Role,
+ text != null ? text.XmlLang : null,
+ detail, subcode, null);
+ }
+#endif
+
+ public static XmlQualifiedName ClientFaultCode (bool soap12)
+ {
+#if NET_2_0
+ return soap12 ? Soap12FaultCodes.SenderFaultCode : SoapException.ClientFaultCode;
+#else
+ return SoapException.ClientFaultCode;
+#endif
+ }
+
+ public static XmlQualifiedName ServerFaultCode (bool soap12)
+ {
+#if NET_2_0
+ return soap12 ? Soap12FaultCodes.ReceiverFaultCode : SoapException.ServerFaultCode;
+#else
+ return SoapException.ServerFaultCode;
+#endif
+ }
+
+ public static XmlQualifiedName MustUnderstandFaultCode (bool soap12)
+ {
+#if NET_2_0
+ return soap12 ? Soap12FaultCodes.ReceiverFaultCode : SoapException.MustUnderstandFaultCode;
+#else
+ return SoapException.MustUnderstandFaultCode;
+#endif
+ }
+
+ public static XmlQualifiedName VersionMismatchFaultCode (bool soap12)
+ {
+#if NET_2_0
+ return soap12 ? Soap12FaultCodes.VersionMismatchFaultCode : SoapException.VersionMismatchFaultCode;
+#else
+ return SoapException.VersionMismatchFaultCode;
+#endif