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 if (ex
.SubCode
!= null)
79 Code
.Subcode
= CreateFaultCode (ex
.SubCode
);
82 Reason
= new Soap12FaultReason ();
83 Soap12FaultReasonText text
=
84 new Soap12FaultReasonText ();
85 text
.XmlLang
= ex
.Lang
;
86 text
.Value
= ex
.Message
;
87 Reason
.Texts
= new Soap12FaultReasonText
[] {text}
;
88 if (ex
.Detail
!= null) {
89 Detail
= new Soap12FaultDetail ();
90 if (ex
.Detail
.NodeType
== XmlNodeType
.Attribute
)
91 Detail
.Attributes
= new XmlAttribute
[] {
92 (XmlAttribute
) ex
.Detail
};
93 else if (ex
.Detail
.NodeType
== XmlNodeType
.Element
)
94 Detail
.Children
= new XmlElement
[] {
95 (XmlElement
) ex
.Detail
};
97 Detail
.Text
= ex
.Detail
.Value
;
101 static Soap12FaultCode
CreateFaultCode (SoapFaultSubCode code
)
104 throw new ArgumentNullException ("code");
105 Soap12FaultCode ret
= new Soap12FaultCode ();
106 ret
.Value
= code
.Code
;
107 if (code
.SubCode
!= null)
108 ret
.Subcode
= CreateFaultCode (code
.SubCode
);
112 public static SoapFaultSubCode
GetSoapFaultSubCode (Soap12FaultCode src
)
114 return (src
== null) ? null :
115 new SoapFaultSubCode (src
.Value
, GetSoapFaultSubCode (src
.Subcode
));
119 public Soap12FaultCode Code
;
121 public Soap12FaultReason Reason
;
123 [XmlElement (DataType
= "anyURI")]
126 [XmlElement (DataType
= "anyURI")]
129 public Soap12FaultDetail Detail
;
132 [XmlType ("Code", Namespace
= "http://www.w3.org/2003/05/soap-envelope")]
133 internal class Soap12FaultCode
135 public XmlQualifiedName Value
;
137 public Soap12FaultCode Subcode
;
140 [XmlType ("Reason", Namespace
= "http://www.w3.org/2003/05/soap-envelope")]
141 internal class Soap12FaultReason
143 [XmlElement ("Text", Namespace
= "http://www.w3.org/2003/05/soap-envelope")]
144 public Soap12FaultReasonText
[] Texts
;
147 [XmlType ("Text", Namespace
= "http://www.w3.org/2003/05/soap-envelope")]
148 internal class Soap12FaultReasonText
150 [XmlAttribute ("lang", Namespace
= "http://www.w3.org/XML/1998/namespace")]
151 public string XmlLang
;
157 [XmlType ("Detail", Namespace
= "http://www.w3.org/2003/05/soap-envelope")]
158 internal class Soap12FaultDetail
161 public XmlAttribute
[] Attributes
;
164 public XmlElement
[] Children
;