1 using System; 2 using System.Xml; 3 using System.Xml.Schema; 4 using System.Xml.Serialization; 5 using System.Text; 6 using System.Collections; 7 using System.Globalization; 8 9 namespace System.Web.Services.Protocols 10 { 11 internal class Soap12FaultReader : XmlSerializationReader 12 { ReadRoot_Soap12Fault()13 public object ReadRoot_Soap12Fault () 14 { 15 Reader.MoveToContent(); 16 if (Reader.LocalName != "Fault" || Reader.NamespaceURI != "http://www.w3.org/2003/05/soap-envelope") 17 throw CreateUnknownNodeException(); 18 return ReadObject_Fault (true, true); 19 } 20 ReadObject_Fault(bool isNullable, bool checkType)21 public System.Web.Services.Protocols.Soap12Fault ReadObject_Fault (bool isNullable, bool checkType) 22 { 23 System.Web.Services.Protocols.Soap12Fault ob = null; 24 if (isNullable && ReadNull()) return null; 25 26 if (checkType) 27 { 28 System.Xml.XmlQualifiedName t = GetXsiType(); 29 if (t == null) 30 { } 31 else if (t.Name != "Fault" || t.Namespace != "http://www.w3.org/2003/05/soap-envelope") 32 throw CreateUnknownTypeException(t); 33 } 34 35 ob = new System.Web.Services.Protocols.Soap12Fault (); 36 37 Reader.MoveToElement(); 38 39 while (Reader.MoveToNextAttribute()) 40 { 41 if (IsXmlnsAttribute (Reader.Name)) { 42 } 43 else { 44 UnknownNode (ob); 45 } 46 } 47 48 Reader.MoveToElement(); 49 if (Reader.IsEmptyElement) { 50 Reader.Skip (); 51 return ob; 52 } 53 54 Reader.ReadStartElement(); 55 Reader.MoveToContent(); 56 57 bool b0=false, b1=false, b2=false, b3=false, b4=false; 58 59 while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) 60 { 61 if (Reader.NodeType == System.Xml.XmlNodeType.Element) 62 { 63 if (Reader.LocalName == "Role" && Reader.NamespaceURI == "http://www.w3.org/2003/05/soap-envelope" && !b3) { 64 b3 = true; 65 ob.@Role = Reader.ReadElementString (); 66 } 67 else if (Reader.LocalName == "Detail" && Reader.NamespaceURI == "http://www.w3.org/2003/05/soap-envelope" && !b4) { 68 b4 = true; 69 ob.@Detail = ReadObject_Detail (false, true); 70 } 71 else if (Reader.LocalName == "Code" && Reader.NamespaceURI == "http://www.w3.org/2003/05/soap-envelope" && !b0) { 72 b0 = true; 73 ob.@Code = ReadObject_Code (false, true); 74 } 75 else if (Reader.LocalName == "Node" && Reader.NamespaceURI == "http://www.w3.org/2003/05/soap-envelope" && !b2) { 76 b2 = true; 77 ob.@Node = Reader.ReadElementString (); 78 } 79 else if (Reader.LocalName == "Reason" && Reader.NamespaceURI == "http://www.w3.org/2003/05/soap-envelope" && !b1) { 80 b1 = true; 81 ob.@Reason = ReadObject_Reason (false, true); 82 } 83 else { 84 UnknownNode (ob); 85 } 86 } 87 else 88 UnknownNode(ob); 89 90 Reader.MoveToContent(); 91 } 92 93 ReadEndElement(); 94 95 return ob; 96 } 97 ReadObject_Detail(bool isNullable, bool checkType)98 public System.Web.Services.Protocols.Soap12FaultDetail ReadObject_Detail (bool isNullable, bool checkType) 99 { 100 System.Web.Services.Protocols.Soap12FaultDetail ob = null; 101 if (isNullable && ReadNull()) return null; 102 103 if (checkType) 104 { 105 System.Xml.XmlQualifiedName t = GetXsiType(); 106 if (t == null) 107 { } 108 else if (t.Name != "Detail" || t.Namespace != "http://www.w3.org/2003/05/soap-envelope") 109 throw CreateUnknownTypeException(t); 110 } 111 112 ob = new System.Web.Services.Protocols.Soap12FaultDetail (); 113 114 Reader.MoveToElement(); 115 116 int anyAttributeIndex = 0; 117 System.Xml.XmlAttribute[] anyAttributeArray = null; 118 while (Reader.MoveToNextAttribute()) 119 { 120 if (IsXmlnsAttribute (Reader.Name)) { 121 } 122 else { 123 System.Xml.XmlAttribute attr = (System.Xml.XmlAttribute) Document.ReadNode(Reader); 124 anyAttributeArray = (System.Xml.XmlAttribute[]) EnsureArrayIndex (anyAttributeArray, anyAttributeIndex, typeof(System.Xml.XmlAttribute)); 125 anyAttributeArray[anyAttributeIndex] = ((System.Xml.XmlAttribute) attr); 126 anyAttributeIndex++; 127 } 128 } 129 130 anyAttributeArray = (System.Xml.XmlAttribute[]) ShrinkArray (anyAttributeArray, anyAttributeIndex, typeof(System.Xml.XmlAttribute), true); 131 ob.@Attributes = anyAttributeArray; 132 133 Reader.MoveToElement(); 134 if (Reader.IsEmptyElement) { 135 Reader.Skip (); 136 return ob; 137 } 138 139 Reader.ReadStartElement(); 140 Reader.MoveToContent(); 141 142 System.Xml.XmlElement[] o8; 143 o8 = null; 144 int n7=0; 145 146 while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) 147 { 148 if (Reader.NodeType == System.Xml.XmlNodeType.Element) 149 { 150 o8 = (System.Xml.XmlElement[]) EnsureArrayIndex (o8, n7, typeof(System.Xml.XmlElement)); 151 o8[n7] = ((System.Xml.XmlElement) ReadXmlNode (false)); 152 n7++; 153 } 154 else if (Reader.NodeType == System.Xml.XmlNodeType.Text || Reader.NodeType == System.Xml.XmlNodeType.CDATA) 155 { 156 ob.@Text = ReadString (ob.@Text); 157 } 158 else 159 UnknownNode(ob); 160 161 Reader.MoveToContent(); 162 } 163 164 o8 = (System.Xml.XmlElement[]) ShrinkArray (o8, n7, typeof(System.Xml.XmlElement), true); 165 ob.@Children = o8; 166 167 ReadEndElement(); 168 169 return ob; 170 } 171 ReadObject_Code(bool isNullable, bool checkType)172 public System.Web.Services.Protocols.Soap12FaultCode ReadObject_Code (bool isNullable, bool checkType) 173 { 174 System.Web.Services.Protocols.Soap12FaultCode ob = null; 175 if (isNullable && ReadNull()) return null; 176 177 if (checkType) 178 { 179 System.Xml.XmlQualifiedName t = GetXsiType(); 180 if (t == null) 181 { } 182 else if (t.Name != "Code" || t.Namespace != "http://www.w3.org/2003/05/soap-envelope") 183 throw CreateUnknownTypeException(t); 184 } 185 186 ob = new System.Web.Services.Protocols.Soap12FaultCode (); 187 188 Reader.MoveToElement(); 189 190 while (Reader.MoveToNextAttribute()) 191 { 192 if (IsXmlnsAttribute (Reader.Name)) { 193 } 194 else { 195 UnknownNode (ob); 196 } 197 } 198 199 Reader.MoveToElement(); 200 if (Reader.IsEmptyElement) { 201 Reader.Skip (); 202 return ob; 203 } 204 205 Reader.ReadStartElement(); 206 Reader.MoveToContent(); 207 208 bool b9=false, b10=false; 209 210 while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) 211 { 212 if (Reader.NodeType == System.Xml.XmlNodeType.Element) 213 { 214 if (Reader.LocalName == "Value" && Reader.NamespaceURI == "http://www.w3.org/2003/05/soap-envelope" && !b9) { 215 b9 = true; 216 ob.@Value = ReadElementQualifiedName (); 217 } 218 else if (Reader.LocalName == "Subcode" && Reader.NamespaceURI == "http://www.w3.org/2003/05/soap-envelope" && !b10) { 219 b10 = true; 220 ob.@Subcode = ReadObject_Code (false, true); 221 } 222 else { 223 UnknownNode (ob); 224 } 225 } 226 else 227 UnknownNode(ob); 228 229 Reader.MoveToContent(); 230 } 231 232 ReadEndElement(); 233 234 return ob; 235 } 236 ReadObject_Reason(bool isNullable, bool checkType)237 public System.Web.Services.Protocols.Soap12FaultReason ReadObject_Reason (bool isNullable, bool checkType) 238 { 239 System.Web.Services.Protocols.Soap12FaultReason ob = null; 240 if (isNullable && ReadNull()) return null; 241 242 if (checkType) 243 { 244 System.Xml.XmlQualifiedName t = GetXsiType(); 245 if (t == null) 246 { } 247 else if (t.Name != "Reason" || t.Namespace != "http://www.w3.org/2003/05/soap-envelope") 248 throw CreateUnknownTypeException(t); 249 } 250 251 ob = new System.Web.Services.Protocols.Soap12FaultReason (); 252 253 Reader.MoveToElement(); 254 255 while (Reader.MoveToNextAttribute()) 256 { 257 if (IsXmlnsAttribute (Reader.Name)) { 258 } 259 else { 260 UnknownNode (ob); 261 } 262 } 263 264 Reader.MoveToElement(); 265 if (Reader.IsEmptyElement) { 266 Reader.Skip (); 267 return ob; 268 } 269 270 Reader.ReadStartElement(); 271 Reader.MoveToContent(); 272 273 bool b11=false; 274 275 System.Web.Services.Protocols.Soap12FaultReasonText[] o13; 276 o13 = null; 277 int n12=0; 278 279 while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) 280 { 281 if (Reader.NodeType == System.Xml.XmlNodeType.Element) 282 { 283 if (Reader.LocalName == "Text" && Reader.NamespaceURI == "http://www.w3.org/2003/05/soap-envelope" && !b11) { 284 o13 = (System.Web.Services.Protocols.Soap12FaultReasonText[]) EnsureArrayIndex (o13, n12, typeof(System.Web.Services.Protocols.Soap12FaultReasonText)); 285 o13[n12] = ReadObject_Text (false, true); 286 n12++; 287 } 288 else { 289 UnknownNode (ob); 290 } 291 } 292 else 293 UnknownNode(ob); 294 295 Reader.MoveToContent(); 296 } 297 298 o13 = (System.Web.Services.Protocols.Soap12FaultReasonText[]) ShrinkArray (o13, n12, typeof(System.Web.Services.Protocols.Soap12FaultReasonText), true); 299 ob.@Texts = o13; 300 301 ReadEndElement(); 302 303 return ob; 304 } 305 ReadObject_Text(bool isNullable, bool checkType)306 public System.Web.Services.Protocols.Soap12FaultReasonText ReadObject_Text (bool isNullable, bool checkType) 307 { 308 System.Web.Services.Protocols.Soap12FaultReasonText ob = null; 309 if (isNullable && ReadNull()) return null; 310 311 if (checkType) 312 { 313 System.Xml.XmlQualifiedName t = GetXsiType(); 314 if (t == null) 315 { } 316 else if (t.Name != "Text" || t.Namespace != "http://www.w3.org/2003/05/soap-envelope") 317 throw CreateUnknownTypeException(t); 318 } 319 320 ob = new System.Web.Services.Protocols.Soap12FaultReasonText (); 321 322 Reader.MoveToElement(); 323 324 while (Reader.MoveToNextAttribute()) 325 { 326 if (Reader.LocalName == "lang" && Reader.NamespaceURI == "http://www.w3.org/XML/1998/namespace") { 327 ob.@XmlLang = Reader.Value; 328 } 329 else if (IsXmlnsAttribute (Reader.Name)) { 330 } 331 else { 332 UnknownNode (ob); 333 } 334 } 335 336 Reader.MoveToElement(); 337 if (Reader.IsEmptyElement) { 338 Reader.Skip (); 339 return ob; 340 } 341 342 Reader.ReadStartElement(); 343 Reader.MoveToContent(); 344 345 while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) 346 { 347 if (Reader.NodeType == System.Xml.XmlNodeType.Element) 348 { 349 UnknownNode (ob); 350 } 351 else if (Reader.NodeType == System.Xml.XmlNodeType.Text || Reader.NodeType == System.Xml.XmlNodeType.CDATA) 352 { 353 ob.@Value = ReadString (ob.@Value); 354 } 355 else 356 UnknownNode(ob); 357 358 Reader.MoveToContent(); 359 } 360 361 ReadEndElement(); 362 363 return ob; 364 } 365 InitCallbacks()366 protected override void InitCallbacks () 367 { 368 } 369 InitIDs()370 protected override void InitIDs () 371 { 372 } 373 374 } 375 376 internal class Soap12FaultWriter : XmlSerializationWriter 377 { 378 const string xmlNamespace = "http://www.w3.org/2000/xmlns/"; WriteRoot_Soap12Fault(object o)379 public void WriteRoot_Soap12Fault (object o) 380 { 381 WriteStartDocument (); 382 System.Web.Services.Protocols.Soap12Fault ob = (System.Web.Services.Protocols.Soap12Fault) o; 383 TopLevelElement (); 384 WriteObject_Fault (ob, "Fault", "http://www.w3.org/2003/05/soap-envelope", true, false, true); 385 } 386 WriteObject_Fault(System.Web.Services.Protocols.Soap12Fault ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)387 void WriteObject_Fault (System.Web.Services.Protocols.Soap12Fault ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem) 388 { 389 if (((object)ob) == null) 390 { 391 if (isNullable) 392 WriteNullTagLiteral(element, namesp); 393 return; 394 } 395 396 System.Type type = ob.GetType (); 397 if (type == typeof(System.Web.Services.Protocols.Soap12Fault)) 398 { } 399 else { 400 throw CreateUnknownTypeException (ob); 401 } 402 403 if (writeWrappingElem) { 404 WriteStartElement (element, namesp, ob); 405 } 406 407 if (needType) WriteXsiType("Fault", "http://www.w3.org/2003/05/soap-envelope"); 408 409 WriteObject_Code (ob.@Code, "Code", "http://www.w3.org/2003/05/soap-envelope", false, false, true); 410 WriteObject_Reason (ob.@Reason, "Reason", "http://www.w3.org/2003/05/soap-envelope", false, false, true); 411 WriteElementString ("Node", "http://www.w3.org/2003/05/soap-envelope", ((ob.@Node != null) ? (ob.@Node).ToString() : null)); 412 WriteElementString ("Role", "http://www.w3.org/2003/05/soap-envelope", ((ob.@Role != null) ? (ob.@Role).ToString() : null)); 413 WriteObject_Detail (ob.@Detail, "Detail", "http://www.w3.org/2003/05/soap-envelope", false, false, true); 414 if (writeWrappingElem) WriteEndElement (ob); 415 } 416 WriteObject_Code(System.Web.Services.Protocols.Soap12FaultCode ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)417 void WriteObject_Code (System.Web.Services.Protocols.Soap12FaultCode ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem) 418 { 419 if (((object)ob) == null) 420 { 421 if (isNullable) 422 WriteNullTagLiteral(element, namesp); 423 return; 424 } 425 426 System.Type type = ob.GetType (); 427 if (type == typeof(System.Web.Services.Protocols.Soap12FaultCode)) 428 { } 429 else { 430 throw CreateUnknownTypeException (ob); 431 } 432 433 if (writeWrappingElem) { 434 WriteStartElement (element, namesp, ob); 435 } 436 437 if (needType) WriteXsiType("Code", "http://www.w3.org/2003/05/soap-envelope"); 438 439 WriteElementQualifiedName ("Value", "http://www.w3.org/2003/05/soap-envelope", ob.@Value); 440 WriteObject_Code (ob.@Subcode, "Subcode", "http://www.w3.org/2003/05/soap-envelope", false, false, true); 441 if (writeWrappingElem) WriteEndElement (ob); 442 } 443 WriteObject_Reason(System.Web.Services.Protocols.Soap12FaultReason ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)444 void WriteObject_Reason (System.Web.Services.Protocols.Soap12FaultReason ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem) 445 { 446 if (((object)ob) == null) 447 { 448 if (isNullable) 449 WriteNullTagLiteral(element, namesp); 450 return; 451 } 452 453 System.Type type = ob.GetType (); 454 if (type == typeof(System.Web.Services.Protocols.Soap12FaultReason)) 455 { } 456 else { 457 throw CreateUnknownTypeException (ob); 458 } 459 460 if (writeWrappingElem) { 461 WriteStartElement (element, namesp, ob); 462 } 463 464 if (needType) WriteXsiType("Reason", "http://www.w3.org/2003/05/soap-envelope"); 465 466 if (ob.@Texts != null) { 467 for (int n15 = 0; n15 < ob.@Texts.Length; n15++) { 468 WriteObject_Text (ob.@Texts[n15], "Text", "http://www.w3.org/2003/05/soap-envelope", false, false, true); 469 } 470 } 471 if (writeWrappingElem) WriteEndElement (ob); 472 } 473 WriteObject_Detail(System.Web.Services.Protocols.Soap12FaultDetail ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)474 void WriteObject_Detail (System.Web.Services.Protocols.Soap12FaultDetail ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem) 475 { 476 if (((object)ob) == null) 477 { 478 if (isNullable) 479 WriteNullTagLiteral(element, namesp); 480 return; 481 } 482 483 System.Type type = ob.GetType (); 484 if (type == typeof(System.Web.Services.Protocols.Soap12FaultDetail)) 485 { } 486 else { 487 throw CreateUnknownTypeException (ob); 488 } 489 490 if (writeWrappingElem) { 491 WriteStartElement (element, namesp, ob); 492 } 493 494 if (needType) WriteXsiType("Detail", "http://www.w3.org/2003/05/soap-envelope"); 495 496 ICollection o16 = ob.@Attributes; 497 if (o16 != null) { 498 foreach (XmlAttribute o17 in o16) 499 if (o17.NamespaceURI != xmlNamespace) 500 WriteXmlAttribute (o17, ob); 501 } 502 503 if (ob.@Children != null) { 504 foreach (XmlNode o18 in ob.@Children) { 505 XmlNode o19 = o18; 506 if (o19 is XmlElement) { 507 } 508 else o19.WriteTo (Writer); 509 WriteElementLiteral (o19, "", "", false, true); 510 } 511 } 512 WriteValue (ob.@Text); 513 if (writeWrappingElem) WriteEndElement (ob); 514 } 515 WriteObject_Text(System.Web.Services.Protocols.Soap12FaultReasonText ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)516 void WriteObject_Text (System.Web.Services.Protocols.Soap12FaultReasonText ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem) 517 { 518 if (((object)ob) == null) 519 { 520 if (isNullable) 521 WriteNullTagLiteral(element, namesp); 522 return; 523 } 524 525 System.Type type = ob.GetType (); 526 if (type == typeof(System.Web.Services.Protocols.Soap12FaultReasonText)) 527 { } 528 else { 529 throw CreateUnknownTypeException (ob); 530 } 531 532 if (writeWrappingElem) { 533 WriteStartElement (element, namesp, ob); 534 } 535 536 if (needType) WriteXsiType("Text", "http://www.w3.org/2003/05/soap-envelope"); 537 538 WriteAttribute ("lang", "http://www.w3.org/XML/1998/namespace", ob.@XmlLang); 539 540 WriteValue (ob.@Value); 541 if (writeWrappingElem) WriteEndElement (ob); 542 } 543 InitCallbacks()544 protected override void InitCallbacks () 545 { 546 } 547 548 } 549 550 551 internal class Soap12FaultBaseSerializer : System.Xml.Serialization.XmlSerializer 552 { CreateReader()553 protected override System.Xml.Serialization.XmlSerializationReader CreateReader () { 554 return new Soap12FaultReader (); 555 } 556 CreateWriter()557 protected override System.Xml.Serialization.XmlSerializationWriter CreateWriter () { 558 return new Soap12FaultWriter (); 559 } 560 CanDeserialize(System.Xml.XmlReader xmlReader)561 public override bool CanDeserialize (System.Xml.XmlReader xmlReader) { 562 return true; 563 } 564 } 565 566 internal sealed class Fault12Serializer : Soap12FaultBaseSerializer 567 { Serialize(object obj, System.Xml.Serialization.XmlSerializationWriter writer)568 protected override void Serialize (object obj, System.Xml.Serialization.XmlSerializationWriter writer) { 569 ((Soap12FaultWriter)writer).WriteRoot_Soap12Fault(obj); 570 } 571 Deserialize(System.Xml.Serialization.XmlSerializationReader reader)572 protected override object Deserialize (System.Xml.Serialization.XmlSerializationReader reader) { 573 return ((Soap12FaultReader)reader).ReadRoot_Soap12Fault(); 574 } 575 } 576 577 internal class Soap12FaultSerializerImplementation : System.Xml.Serialization.XmlSerializerImplementation 578 { 579 System.Collections.Hashtable readMethods = null; 580 System.Collections.Hashtable writeMethods = null; 581 System.Collections.Hashtable typedSerializers = null; 582 583 public override System.Xml.Serialization.XmlSerializationReader Reader { 584 get { 585 return new Soap12FaultReader(); 586 } 587 } 588 589 public override System.Xml.Serialization.XmlSerializationWriter Writer { 590 get { 591 return new Soap12FaultWriter(); 592 } 593 } 594 595 public override System.Collections.Hashtable ReadMethods { 596 get { 597 lock (this) { 598 if (readMethods == null) { 599 readMethods = new System.Collections.Hashtable (); 600 readMethods.Add (@"", @"ReadRoot_Soap12Fault"); 601 } 602 return readMethods; 603 } 604 } 605 } 606 607 public override System.Collections.Hashtable WriteMethods { 608 get { 609 lock (this) { 610 if (writeMethods == null) { 611 writeMethods = new System.Collections.Hashtable (); 612 writeMethods.Add (@"", @"WriteRoot_Soap12Fault"); 613 } 614 return writeMethods; 615 } 616 } 617 } 618 619 public override System.Collections.Hashtable TypedSerializers { 620 get { 621 lock (this) { 622 if (typedSerializers == null) { 623 typedSerializers = new System.Collections.Hashtable (); 624 typedSerializers.Add (@"", new FaultSerializer()); 625 } 626 return typedSerializers; 627 } 628 } 629 } 630 GetSerializer(Type type)631 public override XmlSerializer GetSerializer (Type type) 632 { 633 switch (type.FullName) { 634 case "System.Web.Services.Protocols.Soap12Fault": 635 return (XmlSerializer) TypedSerializers [""]; 636 637 } 638 return base.GetSerializer (type); 639 } 640 CanSerialize(System.Type type)641 public override bool CanSerialize (System.Type type) { 642 if (type == typeof(System.Web.Services.Protocols.Soap12Fault)) return true; 643 return false; 644 } 645 } 646 647 } 648