WebServicesInteroperability.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. //
  2. // System.Web.Services.Description.WebServicesInteroperability.cs
  3. //
  4. // Author:
  5. // Lluis Sanchez ([email protected])
  6. //
  7. // Copyright (C) Novell, Inc., 2004
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. #if NET_2_0
  30. using System.Collections;
  31. namespace System.Web.Services.Description
  32. {
  33. public sealed class WebServicesInteroperability
  34. {
  35. private WebServicesInteroperability ()
  36. {
  37. }
  38. [MonoTODO]
  39. public static bool CheckConformance (WsiClaims claims, ServiceDescription service, BasicProfileViolationCollection violations)
  40. {
  41. ServiceDescriptionCollection col = new ServiceDescriptionCollection ();
  42. col.Add (service);
  43. ConformanceCheckContext ctx = new ConformanceCheckContext (col, violations);
  44. return Check (claims, ctx, col);
  45. }
  46. [MonoTODO]
  47. public static bool CheckConformance (WsiClaims claims, ServiceDescriptionCollection services, BasicProfileViolationCollection violations)
  48. {
  49. ConformanceCheckContext ctx = new ConformanceCheckContext (services, violations);
  50. return Check (claims, ctx, services);
  51. }
  52. [MonoTODO]
  53. public static bool CheckConformance (WsiClaims claims, WebReference webReference, BasicProfileViolationCollection violations)
  54. {
  55. ConformanceCheckContext ctx = new ConformanceCheckContext (webReference, violations);
  56. return Check (claims, ctx, webReference.Documents.Values);
  57. }
  58. static bool Check (WsiClaims claims, ConformanceCheckContext ctx, IEnumerable documents)
  59. {
  60. ConformanceChecker[] checkers = GetCheckers (claims);
  61. if (checkers == null) return true;
  62. foreach (object doc in documents) {
  63. if (!(doc is ServiceDescription)) continue;
  64. foreach (ConformanceChecker c in checkers)
  65. Check (ctx, c, (ServiceDescription)doc);
  66. }
  67. return ctx.Violations.Count == 0;
  68. }
  69. static ConformanceChecker[] GetCheckers (WsiClaims claims)
  70. {
  71. if ((claims & WsiClaims.BP10) != 0)
  72. return new ConformanceChecker[] { BasicProfileChecker.Instance };
  73. return null;
  74. }
  75. static void Check (ConformanceCheckContext ctx, ConformanceChecker checker, ServiceDescription sd)
  76. {
  77. ctx.ServiceDescription = sd;
  78. ctx.Checker = checker;
  79. checker.Check (ctx, sd);
  80. CheckExtensions (ctx, checker, sd.Extensions);
  81. foreach (Import i in sd.Imports) {
  82. checker.Check (ctx, i);
  83. }
  84. foreach (Service s in sd.Services) {
  85. checker.Check (ctx, s);
  86. foreach (Port p in s.Ports) {
  87. checker.Check (ctx, p);
  88. CheckExtensions (ctx, checker, p.Extensions);
  89. }
  90. }
  91. foreach (Binding b in sd.Bindings)
  92. {
  93. checker.Check (ctx, b);
  94. CheckExtensions (ctx, checker, b.Extensions);
  95. foreach (OperationBinding oper in b.Operations) {
  96. CheckExtensions (ctx, checker, oper.Extensions);
  97. foreach (MessageBinding mb in oper.Faults) {
  98. checker.Check (ctx, mb);
  99. CheckExtensions (ctx, checker, mb.Extensions);
  100. }
  101. checker.Check (ctx, oper.Input);
  102. CheckExtensions (ctx, checker, oper.Input.Extensions);
  103. checker.Check (ctx, oper.Output);
  104. CheckExtensions (ctx, checker, oper.Output.Extensions);
  105. }
  106. }
  107. foreach (PortType pt in sd.PortTypes)
  108. {
  109. checker.Check (ctx, pt);
  110. foreach (Operation oper in pt.Operations) {
  111. checker.Check (ctx, oper);
  112. foreach (OperationMessage msg in oper.Messages)
  113. checker.Check (ctx, msg);
  114. foreach (OperationMessage msg in oper.Faults)
  115. checker.Check (ctx, msg);
  116. }
  117. }
  118. foreach (Message msg in sd.Messages)
  119. {
  120. checker.Check (ctx, msg);
  121. foreach (MessagePart part in msg.Parts)
  122. checker.Check (ctx, part);
  123. }
  124. }
  125. static void CheckExtensions (ConformanceCheckContext ctx, ConformanceChecker checker, ServiceDescriptionFormatExtensionCollection extensions)
  126. {
  127. foreach (ServiceDescriptionFormatExtension ext in extensions)
  128. checker.Check (ctx, ext);
  129. }
  130. }
  131. }
  132. #endif