5 // Atsushi Enomoto <atsushi@ximian.com>
7 // Copyright (C) 2006 Novell, Inc.
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 // This file is used to generate Fault12Serializer.cs with fault-12.genxs.
33 // To generate the file, do:
34 // - replace _internal_ class in this file to _public_ class
35 // - optionally you might have to remove Fault12Serializer.cs from
36 // System.Web.Services.dll.sources.
37 // - Build System.Web.Services.dll with make PROFILE=net_2_0.
38 // - run genxs.exe with 2.0 libraries (the easiest way would be
39 // to build genxs under 2.0 profile i.e. make PROFILE=net_2_0)
40 // - Edit Fault12Serializer.cs to rename "FaultSerializer" to
41 // "Fault12Serializer" as the name is a duplicate, and
42 // wrap the entire code with #if NET_2_0.
43 // - revert _public_ class in this file to _internal_ class back.
48 using System.Xml.Schema;
49 using System.Xml.Serialization;
51 using System.Collections;
52 using System.Globalization;
54 namespace System.Web.Services.Protocols
56 [XmlRoot ("Fault", Namespace = "http://www.w3.org/2003/05/soap-envelope")]
57 [XmlType ("Fault", Namespace = "http://www.w3.org/2003/05/soap-envelope")]
58 internal class Soap12Fault
60 // dummy constructor to not be rejected by genxs.
65 public static XmlSerializer Serializer =
67 new Fault12Serializer ();
74 public Soap12Fault (SoapException ex)
76 Code = new Soap12FaultCode ();
78 Code.Subcode = CreateFaultCode (ex.SubCode);
81 Reason = new Soap12FaultReason ();
82 Soap12FaultReasonText text =
83 new Soap12FaultReasonText ();
84 text.XmlLang = ex.Lang;
85 text.Value = ex.Message;
86 Reason.Texts = new Soap12FaultReasonText [] {text};
87 if (ex.Detail != null) {
88 Detail = new Soap12FaultDetail ();
89 if (ex.Detail.NodeType == XmlNodeType.Attribute)
90 Detail.Attributes = new XmlAttribute [] {
91 (XmlAttribute) ex.Detail};
92 else if (ex.Detail.NodeType == XmlNodeType.Element)
93 Detail.Children = new XmlElement [] {
94 (XmlElement) ex.Detail};
96 Detail.Text = ex.Detail.Value;
100 static Soap12FaultCode CreateFaultCode (SoapFaultSubCode code)
102 Soap12FaultCode ret = new Soap12FaultCode ();
103 ret.Value = code.Code;
104 if (code.SubCode != null)
105 ret.Subcode = CreateFaultCode (code.SubCode);
109 public static SoapFaultSubCode GetSoapFaultSubCode (Soap12FaultCode src)
111 return (src == null) ? null :
112 new SoapFaultSubCode (src.Value, GetSoapFaultSubCode (src.Subcode));
116 public Soap12FaultCode Code;
118 public Soap12FaultReason Reason;
120 [XmlElement (DataType = "anyURI")]
123 [XmlElement (DataType = "anyURI")]
126 public Soap12FaultDetail Detail;
129 [XmlType ("Code", Namespace = "http://www.w3.org/2003/05/soap-envelope")]
130 internal class Soap12FaultCode
132 public XmlQualifiedName Value;
134 public Soap12FaultCode Subcode;
137 [XmlType ("Reason", Namespace = "http://www.w3.org/2003/05/soap-envelope")]
138 internal class Soap12FaultReason
140 [XmlElement ("Text", Namespace = "http://www.w3.org/2003/05/soap-envelope")]
141 public Soap12FaultReasonText [] Texts;
144 [XmlType ("Text", Namespace = "http://www.w3.org/2003/05/soap-envelope")]
145 internal class Soap12FaultReasonText
147 [XmlAttribute ("lang", Namespace = "http://www.w3.org/XML/1998/namespace")]
148 public string XmlLang;
154 [XmlType ("Detail", Namespace = "http://www.w3.org/2003/05/soap-envelope")]
155 internal class Soap12FaultDetail
158 public XmlAttribute [] Attributes;
161 public XmlElement [] Children;