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