| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- //
- // System.Web.Services.Description.WebServicesInteroperability.cs
- //
- // Author:
- // Lluis Sanchez ([email protected])
- //
- // Copyright (C) Novell, Inc., 2004
- //
- //
- // 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.
- //
- #if NET_2_0
- using System.Collections;
- namespace System.Web.Services.Description
- {
- public sealed class WebServicesInteroperability
- {
- private WebServicesInteroperability ()
- {
- }
-
- [MonoTODO]
- public static bool CheckConformance (WsiClaims claims, ServiceDescription service, BasicProfileViolationCollection violations)
- {
- ServiceDescriptionCollection col = new ServiceDescriptionCollection ();
- col.Add (service);
- ConformanceCheckContext ctx = new ConformanceCheckContext (col, violations);
- return Check (claims, ctx, col);
- }
- [MonoTODO]
- public static bool CheckConformance (WsiClaims claims, ServiceDescriptionCollection services, BasicProfileViolationCollection violations)
- {
- ConformanceCheckContext ctx = new ConformanceCheckContext (services, violations);
- return Check (claims, ctx, services);
- }
- [MonoTODO]
- public static bool CheckConformance (WsiClaims claims, WebReference webReference, BasicProfileViolationCollection violations)
- {
- ConformanceCheckContext ctx = new ConformanceCheckContext (webReference, violations);
- return Check (claims, ctx, webReference.Documents);
- }
-
- static bool Check (WsiClaims claims, ConformanceCheckContext ctx, IEnumerable documents)
- {
- ConformanceChecker[] checkers = GetCheckers (claims);
- if (checkers == null) return true;
-
- foreach (object doc in documents) {
- if (!(doc is ServiceDescription)) continue;
-
- foreach (ConformanceChecker c in checkers)
- Check (ctx, c, (ServiceDescription)doc);
- }
-
- return ctx.Violations.Count == 0;
- }
-
- static ConformanceChecker[] GetCheckers (WsiClaims claims)
- {
- if ((claims & WsiClaims.BP10) != 0)
- return new ConformanceChecker[] { BasicProfileChecker.Instance };
- return null;
- }
-
- static void Check (ConformanceCheckContext ctx, ConformanceChecker checker, ServiceDescription sd)
- {
- ctx.ServiceDescription = sd;
- ctx.Checker = checker;
-
- checker.Check (ctx, sd);
- CheckExtensions (ctx, checker, sd.Extensions);
-
- foreach (Service s in sd.Services) {
- checker.Check (ctx, s);
- foreach (Port p in s.Ports) {
- checker.Check (ctx, p);
- CheckExtensions (ctx, checker, p.Extensions);
- }
- }
-
- foreach (Binding b in sd.Bindings)
- {
- checker.Check (ctx, b);
- CheckExtensions (ctx, checker, b.Extensions);
-
- foreach (OperationBinding oper in b.Operations) {
- CheckExtensions (ctx, checker, oper.Extensions);
-
- foreach (MessageBinding mb in oper.Faults) {
- checker.Check (ctx, mb);
- CheckExtensions (ctx, checker, mb.Extensions);
- }
-
- checker.Check (ctx, oper.Input);
- CheckExtensions (ctx, checker, oper.Input.Extensions);
-
- checker.Check (ctx, oper.Output);
- CheckExtensions (ctx, checker, oper.Output.Extensions);
- }
- }
-
- foreach (PortType pt in sd.PortTypes)
- {
- checker.Check (ctx, pt);
-
- foreach (Operation oper in pt.Operations) {
- checker.Check (ctx, oper);
- foreach (OperationMessage msg in oper.Messages)
- checker.Check (ctx, msg);
-
- foreach (OperationMessage msg in oper.Faults)
- checker.Check (ctx, msg);
- }
- }
-
- foreach (Message msg in sd.Messages)
- {
- checker.Check (ctx, msg);
- foreach (MessagePart part in msg.Parts)
- checker.Check (ctx, part);
- }
- }
-
- static void CheckExtensions (ConformanceCheckContext ctx, ConformanceChecker checker, ServiceDescriptionFormatExtensionCollection extensions)
- {
- foreach (ServiceDescriptionFormatExtension ext in extensions)
- checker.Check (ctx, ext);
- }
- }
- }
- #endif
|