WebServicesInteroperability.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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);
  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 (Service s in sd.Services) {
  82. checker.Check (ctx, s);
  83. foreach (Port p in s.Ports) {
  84. checker.Check (ctx, p);
  85. CheckExtensions (ctx, checker, p.Extensions);
  86. }
  87. }
  88. foreach (Binding b in sd.Bindings)
  89. {
  90. checker.Check (ctx, b);
  91. CheckExtensions (ctx, checker, b.Extensions);
  92. foreach (OperationBinding oper in b.Operations) {
  93. CheckExtensions (ctx, checker, oper.Extensions);
  94. foreach (MessageBinding mb in oper.Faults) {
  95. checker.Check (ctx, mb);
  96. CheckExtensions (ctx, checker, mb.Extensions);
  97. }
  98. checker.Check (ctx, oper.Input);
  99. CheckExtensions (ctx, checker, oper.Input.Extensions);
  100. checker.Check (ctx, oper.Output);
  101. CheckExtensions (ctx, checker, oper.Output.Extensions);
  102. }
  103. }
  104. foreach (PortType pt in sd.PortTypes)
  105. {
  106. checker.Check (ctx, pt);
  107. foreach (Operation oper in pt.Operations) {
  108. checker.Check (ctx, oper);
  109. foreach (OperationMessage msg in oper.Messages)
  110. checker.Check (ctx, msg);
  111. foreach (OperationMessage msg in oper.Faults)
  112. checker.Check (ctx, msg);
  113. }
  114. }
  115. foreach (Message msg in sd.Messages)
  116. {
  117. checker.Check (ctx, msg);
  118. foreach (MessagePart part in msg.Parts)
  119. checker.Check (ctx, part);
  120. }
  121. }
  122. static void CheckExtensions (ConformanceCheckContext ctx, ConformanceChecker checker, ServiceDescriptionFormatExtensionCollection extensions)
  123. {
  124. foreach (ServiceDescriptionFormatExtension ext in extensions)
  125. checker.Check (ctx, ext);
  126. }
  127. }
  128. }
  129. #endif