< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Description.XmlSerializerMessageContractExporter
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Description/MessageContractExporter.cs
Line coverage
70%
Covered lines: 96
Uncovered lines: 40
Coverable lines: 136
Total lines: 2500
Line coverage: 70.5%
Branch coverage
66%
Covered branches: 45
Total branches: 68
Branch coverage: 66.1%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%11100%
IsRpcStyle()100%11100%
IsEncoded()100%11100%
OnExportMessageContract()50%4450%
ExportHeaders(...)37.5%8830%
ExportBody(...)100%88100%
ExportFaults(...)75%4485.71%
ExportFault(...)100%110%
ExportFaultElement(...)0%220%
ExportKnownTypes()100%11100%
GetExtensionData()100%11100%
.ctor(...)100%11100%
Equals(...)0%660%
GetHashCode()100%110%
ExportMembersMapping(...)72.22%181884.21%
Compile()100%11100%
MoveSchemas()100%6686.66%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Description/MessageContractExporter.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System;
 5using System.Collections.Generic;
 6using System.Diagnostics.CodeAnalysis;
 7using System.Globalization;
 8using System.IO;
 9using System.Reflection;
 10using System.Runtime;
 11using System.Runtime.Serialization;
 12using CoreWCF;
 13using CoreWCF.Dispatcher;
 14using System.Xml;
 15using System.Xml.Schema;
 16using System.Xml.Serialization;
 17using WsdlNS = System.Web.Services.Description;
 18using CoreWCF.Runtime;
 19using CoreWCF.Xml.Serialization;
 20using CoreWCF.Runtime.Serialization;
 21
 22namespace CoreWCF.Description
 23{
 24    internal abstract class MessageContractExporter
 25    {
 26        protected readonly WsdlContractConversionContext _contractContext;
 27        protected readonly WsdlExporter _exporter;
 28        protected readonly OperationDescription _operation;
 29        protected readonly IOperationBehavior _extension;
 30
 31        internal static void ExportMessageBinding(WsdlExporter exporter, WsdlEndpointConversionContext endpointContext, 
 32        {
 33            new MessageBindingExporter(exporter, endpointContext).ExportMessageBinding(operation, messageContractExporte
 34        }
 35
 36        protected abstract object OnExportMessageContract();
 37        protected abstract void ExportHeaders(int messageIndex, object state);
 38        protected abstract void ExportBody(int messageIndex, object state);
 39        protected abstract void ExportKnownTypes();
 40        protected abstract bool IsRpcStyle();
 41        protected abstract bool IsEncoded();
 42        protected abstract object GetExtensionData();
 43
 44        protected MessageExportContext ExportedMessages => GetMessageExportContext(_exporter);
 45
 46        private void AddElementToSchema(XmlSchemaElement element, string elementNs, XmlSchemaSet schemaSet)
 47        {
 48            OperationDescription parentOperation = _operation;
 49            if (parentOperation.OperationMethod != null)
 50            {
 51                XmlQualifiedName qname = new XmlQualifiedName(element.Name, elementNs);
 52
 53                OperationElement existingElement;
 54                if (ExportedMessages.ElementTypes.TryGetValue(qname, out existingElement))
 55                {
 56                    if (existingElement.Operation.OperationMethod == parentOperation.OperationMethod)
 57                    {
 58                        return;
 59                    }
 60
 61                    if (!SchemaHelper.IsMatch(element, existingElement.Element))
 62                    {
 63                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Forma
 64                    }
 65
 66                    return;
 67                }
 68                else
 69                {
 70                    ExportedMessages.ElementTypes.Add(qname, new OperationElement(element, parentOperation));
 71                }
 72            }
 73
 74            SchemaHelper.AddElementToSchema(element, SchemaHelper.GetSchema(elementNs, schemaSet), schemaSet);
 75        }
 76
 77        private static MessageExportContext GetMessageExportContext(WsdlExporter exporter)
 78        {
 79            object messageExportContext;
 80            if (!exporter.State.TryGetValue(typeof(MessageExportContext), out messageExportContext))
 81            {
 82                messageExportContext = new MessageExportContext();
 83                exporter.State[typeof(MessageExportContext)] = messageExportContext;
 84            }
 85
 86            return (MessageExportContext)messageExportContext;
 87        }
 88
 89        protected MessageContractExporter(WsdlExporter exporter, WsdlContractConversionContext context, OperationDescrip
 90        {
 91            _exporter = exporter;
 92            _contractContext = context;
 93            _operation = operation;
 94            _extension = extension;
 95        }
 96
 97        internal void ExportMessageContract()
 98        {
 99            if (_extension == null)
 100            {
 101                return;
 102            }
 103
 104            object state = OnExportMessageContract();
 105
 106            OperationFormatter.Validate(_operation, IsRpcStyle(), IsEncoded());
 107            ExportKnownTypes();
 108
 109            for (int messageIndex = 0; messageIndex < _operation.Messages.Count; messageIndex++)
 110            {
 111                ExportMessage(messageIndex, state);
 112            }
 113
 114            if (!_operation.IsOneWay)
 115            {
 116                ExportFaults(state);
 117            }
 118
 119            foreach (XmlSchema schema in _exporter.GeneratedXmlSchemas.Schemas())
 120            {
 121                EnsureXsdImport(schema.TargetNamespace, _contractContext.WsdlPortType.ServiceDescription);
 122            }
 123        }
 124
 125        private void ExportMessage(int messageIndex, object state)
 126        {
 127            try
 128            {
 129                MessageDescription description = _operation.Messages[messageIndex];
 130                WsdlNS.Message wsdlMessage;
 131
 132                if (CreateMessage(description, messageIndex, out wsdlMessage))
 133                {
 134                    if (description.IsUntypedMessage)
 135                    {
 136                        ExportAnyMessage(wsdlMessage, description.Body.ReturnValue ?? description.Body.Parts[0]);
 137                        return;
 138                    }
 139
 140                    bool isRequest = (messageIndex == 0);
 141                    StreamFormatter streamFormatter = StreamFormatter.Create(description, _operation.Name, isRequest);
 142                    if (streamFormatter != null)
 143                    {
 144                        ExportStreamBody(wsdlMessage, streamFormatter.WrapperName, streamFormatter.WrapperNamespace, str
 145                    }
 146                    else
 147                    {
 148                        ExportBody(messageIndex, state);
 149                    }
 150                }
 151                if (!description.IsUntypedMessage)
 152                {
 153                    ExportHeaders(messageIndex, state);
 154                }
 155            }
 156            finally
 157            {
 158                Compile();
 159            }
 160        }
 161
 162        protected virtual void ExportFaults(object state)
 163        {
 164            foreach (FaultDescription fault in _operation.Faults)
 165            {
 166                ExportFault(fault);
 167            }
 168        }
 169
 170        protected bool IsOperationInherited()
 171        {
 172            return _operation.DeclaringContract != _contractContext.Contract;
 173        }
 174
 175        private void ExportAnyMessage(WsdlNS.Message message, MessagePartDescription part)
 176        {
 177            XmlSchemaSet schemas = _exporter.GeneratedXmlSchemas;
 178            XmlSchema schema = SchemaHelper.GetSchema(DataContractSerializerMessageContractImporter.GenericMessageTypeNa
 179
 180            if (!schema.SchemaTypes.Contains(DataContractSerializerMessageContractImporter.GenericMessageTypeName))
 181            {
 182                XmlSchemaComplexType genericMessageType = new XmlSchemaComplexType();
 183                genericMessageType.Name = DataContractSerializerMessageContractImporter.GenericMessageTypeName.Name;
 184                XmlSchemaSequence bodySequence = new XmlSchemaSequence();
 185                genericMessageType.Particle = bodySequence;
 186
 187                XmlSchemaAny anyElement = new XmlSchemaAny();
 188                anyElement.MinOccurs = 0;
 189                anyElement.MaxOccurs = decimal.MaxValue;
 190                anyElement.Namespace = "##any";
 191
 192                bodySequence.Items.Add(anyElement);
 193
 194                SchemaHelper.AddTypeToSchema(genericMessageType, schema, schemas);
 195            }
 196
 197            string partName = string.IsNullOrEmpty(part.UniquePartName) ? part.Name : part.UniquePartName;
 198            WsdlNS.MessagePart wsdlPart = AddMessagePart(message, partName, XmlQualifiedName.Empty, DataContractSerializ
 199            part.UniquePartName = wsdlPart.Name;
 200        }
 201
 202        protected void ExportStreamBody(WsdlNS.Message message, string wrapperName, string wrapperNs, string partName, s
 203        {
 204            XmlSchemaSet schemas = _exporter.GeneratedXmlSchemas;
 205            XmlSchema schema = SchemaHelper.GetSchema(DataContractSerializerMessageContractImporter.StreamBodyTypeName.N
 206            if (!schema.SchemaTypes.Contains(DataContractSerializerMessageContractImporter.StreamBodyTypeName))
 207            {
 208                XmlSchemaSimpleType streamBodyType = new XmlSchemaSimpleType();
 209                streamBodyType.Name = DataContractSerializerMessageContractImporter.StreamBodyTypeName.Name;
 210                XmlSchemaSimpleTypeRestriction contentRestriction = new XmlSchemaSimpleTypeRestriction();
 211                contentRestriction.BaseTypeName = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Base64Binary).Qualified
 212                streamBodyType.Content = contentRestriction;
 213                SchemaHelper.AddTypeToSchema(streamBodyType, schema, schemas);
 214            }
 215
 216            XmlSchemaSequence wrapperSequence = null;
 217            if (!isRpc && wrapperName != null)
 218            {
 219                wrapperSequence = ExportWrappedPart(message, wrapperName, wrapperNs, schemas, skipSchemaExport);
 220            }
 221            MessagePartDescription streamPart = new MessagePartDescription(partName, partNs);
 222            ExportMessagePart(message, streamPart, DataContractSerializerMessageContractImporter.StreamBodyTypeName, nul
 223        }
 224
 225        private void ExportFault(FaultDescription fault)
 226        {
 227            WsdlNS.Message faultMessage = new WsdlNS.Message();
 228            faultMessage.Name = GetFaultMessageName(fault.Name);
 229
 230            XmlQualifiedName elementName = ExportFaultElement(fault);
 231            _contractContext.WsdlPortType.ServiceDescription.Messages.Add(faultMessage);
 232            AddMessagePart(faultMessage, "detail", elementName, null);
 233
 234            // create a wsdl:fault to put inside the wsdl:portType/wsdl:operation
 235            WsdlNS.OperationFault operationFault = _contractContext.GetOperationFault(fault);
 236            WsdlExporter.WSAddressingHelper.AddActionAttribute(fault.Action, operationFault, _exporter.PolicyVersion);
 237            operationFault.Message = new XmlQualifiedName(faultMessage.Name, faultMessage.ServiceDescription.TargetNames
 238        }
 239
 240        private XmlQualifiedName ExportFaultElement(FaultDescription fault)
 241        {
 242            XmlSchemaType xsdType;
 243            XmlQualifiedName typeName = ExportType(fault.DetailType, fault.Name, _operation.Name, out xsdType);
 244            XmlQualifiedName elementName;
 245            if (XmlName.IsNullOrEmpty(fault.ElementName))
 246            {
 247                elementName = DataContractExporter.GetRootElementName(fault.DetailType);
 248                if (elementName == null)
 249                {
 250                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR
 251                }
 252            }
 253            else
 254            {
 255                elementName = new XmlQualifiedName(fault.ElementName.EncodedName, fault.Namespace);
 256            }
 257
 258            ExportGlobalElement(elementName.Name, elementName.Namespace, true/*isNillable*/, typeName, xsdType, _exporte
 259            return elementName;
 260        }
 261
 262        protected IXsdDataContractExporter DataContractExporter
 263        {
 264            get
 265            {
 266                object dataContractExporter;
 267                if (!_exporter.State.TryGetValue(typeof(IXsdDataContractExporter), out dataContractExporter))
 268                {
 269                    dataContractExporter = XsdDataContractExporterFactory.Create(_exporter.GeneratedXmlSchemas);
 270                    _exporter.State.Add(typeof(IXsdDataContractExporter), dataContractExporter);
 271                }
 272
 273                return (IXsdDataContractExporter)dataContractExporter;
 274            }
 275        }
 276
 277        protected XmlQualifiedName ExportType(Type type, string partName, string operationName, out XmlSchemaType xsdTyp
 278        {
 279            xsdType = null;
 280            if (type == null)
 281            {
 282                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFx
 283            }
 284
 285            if (type == typeof(void))
 286            {
 287                return null;
 288            }
 289
 290            DataContractExporter.Export(type);
 291            XmlQualifiedName typeName = DataContractExporter.GetSchemaTypeName(type);
 292            if (IsNullOrEmpty(typeName))
 293            {
 294                xsdType = DataContractExporter.GetSchemaType(type);
 295            }
 296
 297            return typeName;
 298        }
 299
 300        protected XmlSchemaSet SchemaSet => _exporter.GeneratedXmlSchemas;
 301
 302        protected static WsdlNS.MessagePart AddMessagePart(WsdlNS.Message message, string partName, XmlQualifiedName ele
 303        {
 304            if (message.Parts[partName] != null)
 305            {
 306                if (IsNullOrEmpty(elementName))
 307                {
 308                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.SFxPart
 309                }
 310
 311                int i = 1;
 312                while (message.Parts[partName + i] != null)
 313                {
 314                    if (i == int.MaxValue)
 315                    {
 316                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.SFx
 317                    }
 318
 319                    i++;
 320                }
 321                partName = partName + i.ToString(CultureInfo.InvariantCulture);
 322            }
 323            WsdlNS.MessagePart part = new WsdlNS.MessagePart();
 324            part.Name = partName;
 325            part.Element = elementName;
 326            part.Type = typeName;
 327            message.Parts.Add(part);
 328            EnsureXsdImport(IsNullOrEmpty(elementName) ? typeName.Namespace : elementName.Namespace, message.ServiceDesc
 329            return part;
 330        }
 331
 332        private static void EnsureXsdImport(string ns, WsdlNS.ServiceDescription wsdl)
 333        {
 334            string refNs = wsdl.TargetNamespace;
 335            if (!refNs.EndsWith("/", StringComparison.Ordinal))
 336            {
 337                refNs = refNs + "/Imports";
 338            }
 339            else
 340            {
 341                refNs += "Imports";
 342            }
 343
 344            if (refNs == ns)
 345            {
 346                refNs = wsdl.TargetNamespace;
 347            }
 348
 349            XmlSchema xsd = GetContainedSchema(wsdl, refNs);
 350            if (xsd != null)
 351            {
 352                foreach (object include in xsd.Includes)
 353                {
 354                    XmlSchemaImport import = include as XmlSchemaImport;
 355                    if (import != null && SchemaHelper.NamespacesEqual(import.Namespace, ns))
 356                    {
 357                        return;
 358                    }
 359                }
 360            }
 361            else
 362            {
 363                xsd = new XmlSchema();
 364                xsd.TargetNamespace = refNs;
 365                wsdl.Types.Schemas.Add(xsd);
 366            }
 367
 368            XmlSchemaImport imp = new XmlSchemaImport();
 369            if (ns != null && ns.Length > 0)
 370            {
 371                imp.Namespace = ns;
 372            }
 373
 374            xsd.Includes.Add(imp);
 375        }
 376
 377        private static XmlSchema GetContainedSchema(WsdlNS.ServiceDescription wsdl, string ns)
 378        {
 379            foreach (XmlSchema xsd in wsdl.Types.Schemas)
 380            {
 381                if (SchemaHelper.NamespacesEqual(xsd.TargetNamespace, ns))
 382                {
 383                    return xsd;
 384                }
 385            }
 386
 387            return null;
 388        }
 389
 390
 391        protected static bool IsNullOrEmpty(XmlQualifiedName qname)
 392        {
 393            return qname == null || qname.IsEmpty;
 394        }
 395
 396        protected void ExportGlobalElement(string elementName, string elementNs, bool isNillable, XmlQualifiedName typeN
 397        {
 398#if DEBUG
 399            Fx.Assert(NamingHelper.IsValidNCName(elementName), "Name value has to be a valid NCName.");
 400            if (xsdType == null)
 401            {
 402                Fx.Assert(NamingHelper.IsValidNCName(typeName.Name), "Name value has to be a valid NCName.");
 403            }
 404#endif
 405            XmlSchemaElement element = new XmlSchemaElement();
 406            element.Name = elementName;
 407            if (xsdType != null)
 408            {
 409                element.SchemaType = xsdType;
 410            }
 411            else
 412            {
 413                element.SchemaTypeName = typeName;
 414            }
 415
 416            element.IsNillable = isNillable;
 417            AddElementToSchema(element, elementNs, schemaSet);
 418        }
 419
 420        private void ExportLocalElement(string wrapperNs, string elementName, string elementNs, XmlQualifiedName typeNam
 421        {
 422#if DEBUG
 423            Fx.Assert(NamingHelper.IsValidNCName(elementName), "Name value has to be a valid NCName.");
 424            if (xsdType == null)
 425            {
 426                Fx.Assert(NamingHelper.IsValidNCName(typeName.Name), "Name value has to be a valid NCName.");
 427            }
 428#endif
 429            XmlSchema schema = SchemaHelper.GetSchema(wrapperNs, schemaSet);
 430            XmlSchemaElement element = new XmlSchemaElement();
 431            if (elementNs == wrapperNs)
 432            {
 433                element.Name = elementName;
 434                if (xsdType != null)
 435                {
 436                    element.SchemaType = xsdType;
 437                }
 438                else
 439                {
 440                    element.SchemaTypeName = typeName;
 441                    SchemaHelper.AddImportToSchema(element.SchemaTypeName.Namespace, schema);
 442                }
 443
 444                SchemaHelper.AddElementForm(element, schema);
 445                element.IsNillable = isNillable;
 446            }
 447            else
 448            {
 449                element.RefName = new XmlQualifiedName(elementName, elementNs);
 450
 451                SchemaHelper.AddImportToSchema(elementNs, schema);
 452                ExportGlobalElement(elementName, elementNs, isNillable, typeName, xsdType, schemaSet);
 453            }
 454
 455            if (multiple)
 456            {
 457                element.MaxOccurs = decimal.MaxValue;
 458            }
 459
 460            if (isOptional)
 461            {
 462                element.MinOccurs = 0;
 463            }
 464
 465            sequence.Items.Add(element);
 466        }
 467
 468        private static readonly XmlSchemaSequence emptySequence = new XmlSchemaSequence();
 469        protected XmlSchemaSequence ExportWrappedPart(WsdlNS.Message message, string elementName, string elementNs, XmlS
 470        {
 471#if DEBUG
 472            Fx.Assert(NamingHelper.IsValidNCName(elementName), "Name value has to be a valid NCName.");
 473#endif
 474            AddMessagePart(message, "parameters", new XmlQualifiedName(elementName, elementNs), XmlQualifiedName.Empty);
 475            if (skipSchemaExport)
 476            {
 477                return emptySequence; //return empty to denote it is wrapped part
 478            }
 479
 480            XmlSchemaElement wrapperGlobalElement = new XmlSchemaElement();
 481            wrapperGlobalElement.Name = elementName;
 482
 483            XmlSchemaComplexType wrapperType = new XmlSchemaComplexType();
 484            wrapperGlobalElement.SchemaType = wrapperType; // generating an anonymous type for wrapper
 485
 486            XmlSchemaSequence rootSequence = new XmlSchemaSequence();
 487            wrapperType.Particle = rootSequence;
 488
 489            AddElementToSchema(wrapperGlobalElement, elementNs, schemaSet);
 490
 491            return rootSequence;
 492        }
 493
 494        protected bool CreateMessage(MessageDescription message, int messageIndex, out WsdlNS.Message wsdlMessage)
 495        {
 496            wsdlMessage = null;
 497            bool isNewMessage = true;
 498
 499            if (ExportedMessages.WsdlMessages.ContainsKey(new MessageDescriptionDictionaryKey(_contractContext.Contract,
 500            {
 501                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.MultipleCallsToExport
 502            }
 503
 504            TypedMessageKey typedMessageKey = null;
 505            OperationMessageKey messageKey = null;
 506            if (message.IsTypedMessage)
 507            {
 508                typedMessageKey = new TypedMessageKey(message.MessageType, _operation.DeclaringContract.Namespace, GetEx
 509                if (ExportedMessages.TypedMessages.TryGetValue(typedMessageKey, out wsdlMessage))
 510                {
 511                    isNewMessage = false;
 512                }
 513            }
 514            else if (_operation.OperationMethod != null)
 515            {
 516                messageKey = new OperationMessageKey(_operation, messageIndex);
 517                if (ExportedMessages.ParameterMessages.TryGetValue(messageKey, out wsdlMessage))
 518                {
 519                    isNewMessage = false;
 520                }
 521            }
 522
 523            WsdlNS.ServiceDescription wsdl = _contractContext.WsdlPortType.ServiceDescription;
 524            if (isNewMessage)
 525            {
 526                wsdlMessage = new WsdlNS.Message();
 527                wsdlMessage.Name = GetMessageName(message);
 528                wsdl.Messages.Add(wsdlMessage);
 529                if (message.IsTypedMessage)
 530                {
 531                    ExportedMessages.TypedMessages.Add(typedMessageKey, wsdlMessage);
 532                }
 533                else if (messageKey != null)
 534                {
 535                    ExportedMessages.ParameterMessages.Add(messageKey, wsdlMessage);
 536                }
 537            }
 538
 539            //Add Name to OperationMessage
 540            WsdlNS.OperationMessage wsdlOperationMessage = _contractContext.GetOperationMessage(message);
 541            wsdlOperationMessage.Message = new XmlQualifiedName(wsdlMessage.Name, wsdlMessage.ServiceDescription.TargetN
 542            ExportedMessages.WsdlMessages.Add(new MessageDescriptionDictionaryKey(_contractContext.Contract, message), w
 543
 544            return isNewMessage;
 545        }
 546
 547
 548        protected bool CreateHeaderMessage(MessageDescription message, out WsdlNS.Message wsdlMessage)
 549        {
 550            wsdlMessage = null;
 551
 552            if (ExportedMessages.WsdlHeaderMessages.ContainsKey(new MessageDescriptionDictionaryKey(_contractContext.Con
 553            {
 554                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.MultipleCallsToExport
 555            }
 556
 557            TypedMessageKey typedMessageKey = null;
 558            if (message.IsTypedMessage)
 559            {
 560                typedMessageKey = new TypedMessageKey(message.MessageType, _operation.DeclaringContract.Namespace, GetEx
 561                if (ExportedMessages.TypedHeaderMessages.TryGetValue(typedMessageKey, out wsdlMessage))
 562                {
 563                    ExportedMessages.WsdlHeaderMessages.Add(new MessageDescriptionDictionaryKey(_contractContext.Contrac
 564                    return false;
 565                }
 566            }
 567
 568            string messageName = GetHeaderMessageName(message);
 569            wsdlMessage = new WsdlNS.Message();
 570            wsdlMessage.Name = messageName;
 571            _contractContext.WsdlPortType.ServiceDescription.Messages.Add(wsdlMessage);
 572            if (message.IsTypedMessage)
 573            {
 574                ExportedMessages.TypedHeaderMessages.Add(typedMessageKey, wsdlMessage);
 575            }
 576
 577            ExportedMessages.WsdlHeaderMessages.Add(new MessageDescriptionDictionaryKey(_contractContext.Contract, messa
 578
 579            return true;
 580        }
 581
 582        private string GetMessageName(MessageDescription messageDescription)
 583        {
 584            string messageNameBase = XmlName.IsNullOrEmpty(messageDescription.MessageName) ? null : messageDescription.M
 585
 586            //If there wasn't one in the Message Description we create one.
 587            if (string.IsNullOrEmpty(messageNameBase))
 588            {
 589                string portTypeName = _contractContext.WsdlPortType.Name;
 590                string operationName = _contractContext.GetOperation(_operation).Name;
 591
 592                string callbackString = _operation.IsServerInitiated() ? "Callback" : string.Empty;
 593                // elenak: composing names have potential problem of generating name that looks like an encoded name, co
 594                if (messageDescription.Direction == MessageDirection.Input)
 595                {
 596                    messageNameBase = string.Format(CultureInfo.InvariantCulture,
 597                                        "{0}_{1}_Input{2}Message", portTypeName, operationName, callbackString);
 598                }
 599                else
 600                {
 601                    messageNameBase = string.Format(CultureInfo.InvariantCulture,
 602                                        "{0}_{1}_Output{2}Message", portTypeName, operationName, callbackString);
 603                }
 604            }
 605
 606            WsdlNS.ServiceDescription wsdl = _contractContext.WsdlPortType.ServiceDescription;
 607            return GetUniqueMessageName(wsdl, messageNameBase);
 608        }
 609
 610        private string GetHeaderMessageName(MessageDescription messageDescription)
 611        {
 612            WsdlNS.Message wsdlBodyMessage = ExportedMessages.WsdlMessages[new MessageDescriptionDictionaryKey(_contract
 613
 614            string messageNameBase = string.Format(CultureInfo.InvariantCulture,
 615                                        "{0}_Headers", wsdlBodyMessage.Name);
 616
 617            WsdlNS.ServiceDescription wsdl = _contractContext.WsdlPortType.ServiceDescription;
 618            return GetUniqueMessageName(wsdl, messageNameBase);
 619        }
 620
 621        protected string GetFaultMessageName(string faultName)
 622        {
 623            string portTypeName = _contractContext.WsdlPortType.Name;
 624            string operationName = _contractContext.GetOperation(_operation).Name;
 625            string faultNameBase = string.Format(CultureInfo.InvariantCulture, "{0}_{1}_{2}_FaultMessage", portTypeName,
 626
 627            WsdlNS.ServiceDescription wsdl = _contractContext.WsdlPortType.ServiceDescription;
 628            return GetUniqueMessageName(wsdl, faultNameBase);
 629        }
 630
 631        private static bool DoesMessageNameExist(string messageName, object wsdlObject)
 632        {
 633            return ((WsdlNS.ServiceDescription)wsdlObject).Messages[messageName] != null;
 634        }
 635
 636        private string GetUniqueMessageName(WsdlNS.ServiceDescription wsdl, string messageNameBase)
 637        {
 638            return NamingHelper.GetUniqueName(messageNameBase, DoesMessageNameExist, wsdl);
 639        }
 640
 641        protected void ExportMessagePart(WsdlNS.Message message, MessagePartDescription part, XmlQualifiedName typeName,
 642        {
 643            if (IsNullOrEmpty(typeName) && xsdType == null)
 644            {
 645                return;
 646            }
 647#if DEBUG
 648            if (xsdType == null)
 649            {
 650                Fx.Assert(NamingHelper.IsValidNCName(typeName.Name), "Name value has to be a valid NCName.");
 651            }
 652#endif
 653            string elementName = part.Name;
 654            string partName = string.IsNullOrEmpty(part.UniquePartName) ? elementName : part.UniquePartName;
 655
 656            WsdlNS.MessagePart wsdlPart = null;
 657            if (generateElement)
 658            {
 659                if (wrapperSequence != null)
 660                {
 661                    if (!skipSchemaExport)
 662                    {
 663                        ExportLocalElement(wrapperNs, partName, part.Namespace, typeName, xsdType, part.Multiple, isOpti
 664                    }
 665                }
 666                else
 667                {
 668                    if (!skipSchemaExport)
 669                    {
 670                        ExportGlobalElement(elementName, part.Namespace, isNillable, typeName, xsdType, schemaSet);
 671                    }
 672
 673                    wsdlPart = AddMessagePart(message, partName, new XmlQualifiedName(elementName, part.Namespace), XmlQ
 674                }
 675            }
 676            else
 677            {
 678                if (string.IsNullOrEmpty(typeName.Name))
 679                {
 680                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR
 681                }
 682
 683                wsdlPart = AddMessagePart(message, partName, XmlQualifiedName.Empty, typeName);
 684            }
 685
 686            if (wsdlPart != null)
 687            {
 688                part.UniquePartName = wsdlPart.Name;
 689            }
 690        }
 691
 692        protected void AddParameterOrder(MessageDescription message)
 693        {
 694            if (_operation == null)
 695            {
 696                return;
 697            }
 698
 699            WsdlNS.Operation wsdlOperation = _contractContext.GetOperation(_operation);
 700            if (wsdlOperation != null)
 701            {
 702                if (wsdlOperation.ParameterOrder == null)
 703                {
 704                    wsdlOperation.ParameterOrder = new string[GetParameterCount()];
 705                }
 706
 707                if (wsdlOperation.ParameterOrder.Length == 0)
 708                {
 709                    return;
 710                }
 711
 712                foreach (MessagePartDescription part in message.Body.Parts)
 713                {
 714                    ParameterInfo paramInfo = part.AdditionalAttributesProvider as ParameterInfo;
 715                    if (paramInfo != null && paramInfo.Position >= 0)
 716                    {
 717                        wsdlOperation.ParameterOrder[paramInfo.Position] = part.Name;
 718                    }
 719                }
 720            }
 721        }
 722
 723        private int GetParameterCount()
 724        {
 725            int count = -1;
 726            foreach (MessageDescription message in _operation.Messages)
 727            {
 728                foreach (MessagePartDescription part in message.Body.Parts)
 729                {
 730                    ParameterInfo paramInfo = part.AdditionalAttributesProvider as ParameterInfo;
 731                    if (paramInfo == null)
 732                    {
 733                        return 0;
 734                    }
 735
 736                    if (count < paramInfo.Position)
 737                    {
 738                        count = paramInfo.Position;
 739                    }
 740                }
 741            }
 742            return count + 1;
 743        }
 744
 745        protected virtual void Compile()
 746        {
 747            foreach (XmlSchema schema in SchemaSet.Schemas())
 748            {
 749                SchemaSet.Reprocess(schema);
 750            }
 751
 752            SchemaHelper.Compile(SchemaSet, _exporter.Errors);
 753        }
 754
 755        private class MessageBindingExporter
 756        {
 757            private readonly WsdlEndpointConversionContext _endpointContext;
 758            private readonly MessageExportContext _exportedMessages;
 759            private readonly EnvelopeVersion _soapVersion;
 760            private readonly WsdlExporter _exporter;
 761
 762            internal MessageBindingExporter(WsdlExporter exporter, WsdlEndpointConversionContext endpointContext)
 763            {
 764                _endpointContext = endpointContext;
 765                _exportedMessages = (MessageExportContext)exporter.State[typeof(MessageExportContext)];
 766                _soapVersion = SoapHelper.GetSoapVersion(endpointContext.WsdlBinding);
 767                _exporter = exporter;
 768            }
 769
 770            internal void ExportMessageBinding(OperationDescription operation, Type messageContractExporterType)
 771            {
 772                WsdlNS.OperationBinding wsdlOperationBinding = _endpointContext.GetOperationBinding(operation);
 773
 774                bool isRpc, isEncoded;
 775                if (!GetStyleAndUse(operation, messageContractExporterType, out isRpc, out isEncoded))
 776                {
 777                    return;
 778                }
 779
 780                WsdlNS.SoapOperationBinding soapOperationBinding = SoapHelper.GetOrCreateSoapOperationBinding(_endpointC
 781                if (soapOperationBinding == null)
 782                {
 783                    return;
 784                }
 785
 786                soapOperationBinding.Style = isRpc ? WsdlNS.SoapBindingStyle.Rpc : WsdlNS.SoapBindingStyle.Document;
 787                if (isRpc)
 788                {
 789                    WsdlNS.SoapBinding soapBinding = (WsdlNS.SoapBinding)_endpointContext.WsdlBinding.Extensions.Find(ty
 790                    soapBinding.Style = soapOperationBinding.Style;
 791                }
 792
 793                soapOperationBinding.SoapAction = operation.Messages[0].Action;
 794                foreach (MessageDescription message in operation.Messages)
 795                {
 796                    WsdlNS.MessageBinding wsdlMessageBinding = _endpointContext.GetMessageBinding(message);
 797                    WsdlNS.Message headerMessage;
 798                    if (_exportedMessages.WsdlHeaderMessages.TryGetValue(new MessageDescriptionDictionaryKey(_endpointCo
 799                    {
 800                        XmlQualifiedName wsdlHeaderMessageName = new XmlQualifiedName(headerMessage.Name, headerMessage.
 801                        foreach (MessageHeaderDescription header in message.Headers)
 802                        {
 803                            if (header.IsUnknownHeaderCollection)
 804                            {
 805                                continue;
 806                            }
 807
 808                            ExportMessageHeaderBinding(header, wsdlHeaderMessageName, isEncoded, wsdlMessageBinding);
 809                        }
 810                    }
 811
 812                    ExportMessageBodyBinding(message, isRpc, isEncoded, wsdlMessageBinding);
 813                }
 814
 815                foreach (FaultDescription fault in operation.Faults)
 816                {
 817                    ExportFaultBinding(fault, isEncoded, wsdlOperationBinding);
 818                }
 819            }
 820
 821            private void ExportFaultBinding(FaultDescription fault, bool isEncoded, WsdlNS.OperationBinding operationBin
 822            {
 823                SoapHelper.CreateSoapFaultBinding(fault.Name, _endpointContext, _endpointContext.GetFaultBinding(fault),
 824            }
 825
 826            private void ExportMessageBodyBinding(MessageDescription messageDescription, bool isRpc, bool isEncoded, Wsd
 827            {
 828                WsdlNS.SoapBodyBinding bodyBinding = SoapHelper.GetOrCreateSoapBodyBinding(_endpointContext, messageBind
 829
 830                if (bodyBinding == null)
 831                {
 832                    return;
 833                }
 834
 835                bodyBinding.Use = isEncoded ? WsdlNS.SoapBindingUse.Encoded : WsdlNS.SoapBindingUse.Literal;
 836                if (isRpc)
 837                {
 838                    string ns;
 839                    if (!ExportedMessages.WrapperNamespaces.TryGetValue(new MessageDescriptionDictionaryKey(_endpointCon
 840                    {
 841                        ns = messageDescription.Body.WrapperNamespace;
 842                    }
 843
 844                    bodyBinding.Namespace = ns;
 845                }
 846                if (isEncoded)
 847                {
 848                    bodyBinding.Encoding = XmlSerializerOperationFormatter.GetEncoding(_soapVersion);
 849                }
 850            }
 851
 852            private void ExportMessageHeaderBinding(MessageHeaderDescription header, XmlQualifiedName messageName, bool 
 853            {
 854#if DEBUG
 855                Fx.Assert(NamingHelper.IsValidNCName(messageName.Name), "Name value has to be a valid NCName.");
 856#endif
 857                WsdlNS.SoapHeaderBinding headerBinding = SoapHelper.CreateSoapHeaderBinding(_endpointContext, messageBin
 858                headerBinding.Part = string.IsNullOrEmpty(header.UniquePartName) ? header.Name : header.UniquePartName;
 859                headerBinding.Message = messageName;
 860                headerBinding.Use = isEncoded ? WsdlNS.SoapBindingUse.Encoded : WsdlNS.SoapBindingUse.Literal;
 861                if (isEncoded)
 862                {
 863                    headerBinding.Encoding = XmlSerializerOperationFormatter.GetEncoding(_soapVersion);
 864                }
 865            }
 866
 867            private static bool GetStyleAndUse(OperationDescription operation, Type messageContractExporterType, out boo
 868            {
 869                isRpc = isEncoded = false;
 870                if (messageContractExporterType == typeof(DataContractSerializerMessageContractExporter) || messageContr
 871                {
 872                    DataContractSerializerOperationBehavior dataContractSerializerBehavior = operation.Behaviors.Find<Da
 873                    if (dataContractSerializerBehavior != null)
 874                    {
 875                        isRpc = dataContractSerializerBehavior.DataContractFormatAttribute.Style == OperationFormatStyle
 876                        isEncoded = false;
 877                        return true;
 878                    }
 879
 880                    if (messageContractExporterType == typeof(DataContractSerializerMessageContractExporter))
 881                    {
 882                        return false;
 883                    }
 884                }
 885                if (messageContractExporterType == typeof(XmlSerializerMessageContractExporter) || messageContractExport
 886                {
 887                    XmlSerializerOperationBehavior xmlSerializerBehavior = operation.Behaviors.Find<XmlSerializerOperati
 888                    if (xmlSerializerBehavior != null)
 889                    {
 890                        isRpc = xmlSerializerBehavior.XmlSerializerFormatAttribute.Style == OperationFormatStyle.Rpc;
 891                        isEncoded = xmlSerializerBehavior.XmlSerializerFormatAttribute.IsEncoded;
 892                        return true;
 893                    }
 894
 895                    return false;
 896                }
 897
 898                return false;
 899            }
 900
 901            private MessageExportContext ExportedMessages => GetMessageExportContext(_exporter);
 902        }
 903
 904        protected class MessageExportContext
 905        {
 906            internal readonly Dictionary<MessageDescriptionDictionaryKey, WsdlNS.Message> WsdlMessages = new Dictionary<
 907            internal readonly Dictionary<MessageDescriptionDictionaryKey, WsdlNS.Message> WsdlHeaderMessages = new Dicti
 908            internal readonly Dictionary<MessageDescriptionDictionaryKey, string> WrapperNamespaces = new Dictionary<Mes
 909            internal readonly Dictionary<TypedMessageKey, WsdlNS.Message> TypedMessages = new Dictionary<TypedMessageKey
 910            internal readonly Dictionary<TypedMessageKey, WsdlNS.Message> TypedHeaderMessages = new Dictionary<TypedMess
 911            internal readonly Dictionary<OperationMessageKey, WsdlNS.Message> ParameterMessages = new Dictionary<Operati
 912            internal readonly Dictionary<XmlQualifiedName, OperationElement> ElementTypes = new Dictionary<XmlQualifiedN
 913        }
 914
 915        protected sealed class MessageDescriptionDictionaryKey
 916        {
 917            public readonly ContractDescription Contract;
 918            public readonly MessageDescription MessageDescription;
 919
 920            public MessageDescriptionDictionaryKey(ContractDescription contract, MessageDescription MessageDescription)
 921            {
 922                Contract = contract;
 923                this.MessageDescription = MessageDescription;
 924            }
 925
 926            public override bool Equals(object obj)
 927            {
 928                MessageDescriptionDictionaryKey key = obj as MessageDescriptionDictionaryKey;
 929                if (key != null && key.MessageDescription == MessageDescription && key.Contract == Contract)
 930                {
 931                    return true;
 932                }
 933
 934                return false;
 935            }
 936
 937            public override int GetHashCode()
 938            {
 939                return Contract.GetHashCode() ^ MessageDescription.GetHashCode();
 940            }
 941        }
 942
 943        internal sealed class TypedMessageKey
 944        {
 945            private readonly Type type;
 946            private readonly string contractNS;
 947            private readonly object extensionData;
 948
 949            public TypedMessageKey(Type type, string contractNS, object extensionData)
 950            {
 951                this.type = type;
 952                this.contractNS = contractNS;
 953                this.extensionData = extensionData;
 954            }
 955
 956            public override bool Equals(object obj)
 957            {
 958                TypedMessageKey key = obj as TypedMessageKey;
 959                if (key != null && key.type == type &&
 960                    key.contractNS == contractNS &&
 961                    key.extensionData.Equals(extensionData))
 962                {
 963                    return true;
 964                }
 965
 966                return false;
 967            }
 968
 969            public override int GetHashCode() => type.GetHashCode();
 970        }
 971
 972        internal sealed class OperationMessageKey
 973        {
 974            private readonly MethodInfo _methodInfo;
 975            private readonly int _messageIndex;
 976            private readonly ContractDescription _declaringContract;
 977
 978            public OperationMessageKey(OperationDescription operation, int messageIndex)
 979            {
 980                _methodInfo = operation.OperationMethod;
 981                _messageIndex = messageIndex;
 982                _declaringContract = operation.DeclaringContract;
 983            }
 984
 985            public override bool Equals(object obj)
 986            {
 987                OperationMessageKey key = obj as OperationMessageKey;
 988                if (key != null && key._methodInfo == _methodInfo &&
 989                    key._messageIndex == _messageIndex &&
 990                    key._declaringContract.Name == _declaringContract.Name &&
 991                    key._declaringContract.Namespace == _declaringContract.Namespace)
 992                {
 993                    return true;
 994                }
 995
 996                return false;
 997            }
 998
 999            public override int GetHashCode()
 1000            {
 1001                return _methodInfo.GetHashCode() ^ _messageIndex;
 1002            }
 1003        }
 1004
 1005        internal sealed class OperationElement
 1006        {
 1007            private readonly XmlSchemaElement element;
 1008            private readonly OperationDescription operation;
 1009            internal OperationElement(XmlSchemaElement element, OperationDescription operation)
 1010            {
 1011                this.element = element;
 1012                this.operation = operation;
 1013            }
 1014
 1015            internal XmlSchemaElement Element => element;
 1016            internal OperationDescription Operation => operation;
 1017        }
 1018    }
 1019
 1020    internal class DataContractSerializerMessageContractExporter : MessageContractExporter
 1021    {
 1022        internal DataContractSerializerMessageContractExporter(WsdlExporter exporter, WsdlContractConversionContext cont
 1023            : base(exporter, context, operation, extension)
 1024        {
 1025        }
 1026
 1027        protected override void Compile()
 1028        {
 1029            XmlSchema wsdl = StockSchemas.CreateWsdl();
 1030            XmlSchema soap = StockSchemas.CreateSoap();
 1031            XmlSchema soapEncoding = StockSchemas.CreateSoapEncoding();
 1032            XmlSchema fakeXsdSchema = StockSchemas.CreateFakeXsdSchema();
 1033
 1034            SchemaSet.Add(wsdl);
 1035            SchemaSet.Add(soap);
 1036            SchemaSet.Add(soapEncoding);
 1037            SchemaSet.Add(fakeXsdSchema);
 1038            base.Compile();
 1039            SchemaSet.Remove(wsdl);
 1040            SchemaSet.Remove(soap);
 1041            SchemaSet.Remove(soapEncoding);
 1042            SchemaSet.Remove(fakeXsdSchema);
 1043        }
 1044
 1045        protected override bool IsRpcStyle()
 1046        {
 1047            return ((DataContractSerializerOperationBehavior)_extension).DataContractFormatAttribute.Style == OperationF
 1048        }
 1049
 1050        protected override bool IsEncoded()
 1051        {
 1052            return false;
 1053        }
 1054
 1055        protected override object OnExportMessageContract()
 1056        {
 1057            return null;
 1058        }
 1059
 1060        protected override void ExportHeaders(int messageIndex, object state)
 1061        {
 1062            MessageDescription description = _operation.Messages[messageIndex];
 1063
 1064            if (description.Headers.Count > 0)
 1065            {
 1066                WsdlNS.Message wsdlMessage;
 1067                if (CreateHeaderMessage(description, out wsdlMessage))
 1068                {
 1069                    foreach (MessageHeaderDescription header in description.Headers)
 1070                    {
 1071                        if (header.IsUnknownHeaderCollection)
 1072                        {
 1073                            continue;
 1074                        }
 1075
 1076                        XmlSchemaType xsdType;
 1077                        bool isQueryable;
 1078                        Type dataContractType = DataContractSerializerOperationFormatter.GetSubstituteDataContractType(h
 1079                        XmlQualifiedName typeName = ExportType(dataContractType, header.Name, _operation.Name, out xsdTy
 1080                        ExportMessagePart(wsdlMessage, header, typeName, xsdType, true/*isOptional*/, IsTypeNullable(hea
 1081                    }
 1082                }
 1083            }
 1084        }
 1085
 1086        internal static bool IsTypeNullable(Type type)
 1087        {
 1088            return !type.IsValueType ||
 1089                    (type.IsGenericType &&
 1090                    type.GetGenericTypeDefinition() == typeof(Nullable<>));
 1091        }
 1092
 1093        protected override void ExportBody(int messageIndex, object state)
 1094        {
 1095            MessageDescription description = _operation.Messages[messageIndex];
 1096            WsdlNS.Message wsdlMessage = ExportedMessages.WsdlMessages[new MessageDescriptionDictionaryKey(_contractCont
 1097
 1098            DataContractFormatAttribute dataContractFormatAttribute = ((DataContractSerializerOperationBehavior)_extensi
 1099            XmlSchemaSequence wrapperSequence = null;
 1100            bool isWrapped = description.Body.WrapperName != null;
 1101            //bool isOperationInherited = IsOperationInherited(operation);
 1102            if (dataContractFormatAttribute.Style == OperationFormatStyle.Document && isWrapped)
 1103            {
 1104                wrapperSequence = ExportWrappedPart(wsdlMessage, description.Body.WrapperName, description.Body.WrapperN
 1105            }
 1106
 1107            XmlSchemaType xsdType;
 1108            if (OperationFormatter.IsValidReturnValue(description.Body.ReturnValue))
 1109            {
 1110                bool isQueryable;
 1111                Type dataContractType = DataContractSerializerOperationFormatter.GetSubstituteDataContractType(descripti
 1112                XmlQualifiedName typeName = ExportType(dataContractType, description.Body.ReturnValue.Name, _operation.N
 1113                ExportMessagePart(wsdlMessage, description.Body.ReturnValue, typeName, xsdType, true/*isOptional*/, IsTy
 1114            }
 1115
 1116            foreach (MessagePartDescription bodyPart in description.Body.Parts)
 1117            {
 1118                bool isQueryable;
 1119                Type dataContractType = DataContractSerializerOperationFormatter.GetSubstituteDataContractType(bodyPart.
 1120                XmlQualifiedName typeName = ExportType(dataContractType, bodyPart.Name, _operation.Name, out xsdType);
 1121                ExportMessagePart(wsdlMessage, bodyPart, typeName, xsdType, true/*isOptional*/, IsTypeNullable(bodyPart.
 1122            }
 1123
 1124            if (dataContractFormatAttribute.Style == OperationFormatStyle.Rpc)
 1125            {
 1126                AddParameterOrder(description);
 1127            }
 1128        }
 1129
 1130        protected override void ExportKnownTypes()
 1131        {
 1132            foreach (Type knownType in _operation.KnownTypes)
 1133            {
 1134                DataContractExporter.Export(knownType);
 1135            }
 1136        }
 1137
 1138        protected override object GetExtensionData()
 1139        {
 1140            return new ExtensionData(((DataContractSerializerOperationBehavior)_extension).DataContractFormatAttribute);
 1141        }
 1142
 1143        private class ExtensionData
 1144        {
 1145            private readonly DataContractFormatAttribute _dcFormatAttr;
 1146            internal ExtensionData(DataContractFormatAttribute dcFormatAttr)
 1147            {
 1148                _dcFormatAttr = dcFormatAttr;
 1149            }
 1150
 1151            public override bool Equals(object obj)
 1152            {
 1153                if (ReferenceEquals(_dcFormatAttr, obj))
 1154                {
 1155                    return true;
 1156                }
 1157
 1158                ExtensionData otherExtensionData = obj as ExtensionData;
 1159                if (otherExtensionData == null)
 1160                {
 1161                    return false;
 1162                }
 1163
 1164                return _dcFormatAttr.Style == otherExtensionData._dcFormatAttr.Style;
 1165            }
 1166
 1167            public override int GetHashCode()
 1168            {
 1169                return 1; //This is never called
 1170            }
 1171        }
 1172    }
 1173
 1174    internal class XmlSerializerMessageContractExporter : MessageContractExporter
 1175    {
 1176        internal XmlSerializerMessageContractExporter(WsdlExporter exporter, WsdlContractConversionContext context, Oper
 91177            : base(exporter, context, operation, extension)
 1178        {
 91179        }
 1180
 1181        protected override bool IsRpcStyle()
 1182        {
 91183            return ((XmlSerializerOperationBehavior)_extension).XmlSerializerFormatAttribute.Style == OperationFormatSty
 1184        }
 1185
 1186        protected override bool IsEncoded()
 1187        {
 91188            return ((XmlSerializerOperationBehavior)_extension).XmlSerializerFormatAttribute.IsEncoded;
 1189        }
 1190
 1191        protected override object OnExportMessageContract()
 1192        {
 91193            object result = Reflector.ReflectOperation(_operation);
 91194            if (result == null)
 1195            {
 1196                // If result is null, that means that XmlSerializerFormatAttribute wasn't available in reflection,
 1197                // so we need to get it from the XmlSerializerOperationBehavior instead
 01198                XmlSerializerOperationBehavior serializerBehavior = _extension as XmlSerializerOperationBehavior;
 01199                if (serializerBehavior != null)
 1200                {
 01201                    result = Reflector.ReflectOperation(_operation, serializerBehavior.XmlSerializerFormatAttribute);
 1202                }
 1203            }
 1204
 91205            return result;
 1206        }
 1207
 1208        protected override void ExportHeaders(int messageIndex, object state)
 1209        {
 181210            MessageDescription description = _operation.Messages[messageIndex];
 181211            if (description.Headers.Count > 0)
 1212            {
 1213
 01214                XmlSerializerOperationBehavior.Reflector.OperationReflector operationReflector = (XmlSerializerOperation
 1215                XmlMembersMapping membersMapping;
 01216                if (messageIndex == 0)
 1217                {
 01218                    membersMapping = operationReflector.Request.HeadersMapping;
 1219                }
 1220                else
 1221                {
 01222                    membersMapping = operationReflector.Reply.HeadersMapping;
 1223                }
 1224
 01225                if (membersMapping != null)
 1226                {
 1227                    WsdlNS.Message wsdlMessage;
 01228                    if (CreateHeaderMessage(description, out wsdlMessage))
 1229                    {
 01230                        ExportMembersMapping(membersMapping, wsdlMessage, false /*IsOperationInherited(operation)*/, ope
 1231                    }
 1232                }
 1233            }
 181234        }
 1235
 1236        protected override void ExportBody(int messageIndex, object state)
 1237        {
 181238            MessageDescription description = _operation.Messages[messageIndex];
 181239            MessageDescriptionDictionaryKey key = new MessageDescriptionDictionaryKey(_contractContext.Contract, descrip
 181240            WsdlNS.Message wsdlMessage = ExportedMessages.WsdlMessages[key];
 1241
 181242            XmlSerializerOperationBehavior.Reflector.OperationReflector operationReflector = (XmlSerializerOperationBeha
 1243            XmlMembersMapping membersMapping;
 181244            if (messageIndex == 0)
 1245            {
 91246                membersMapping = operationReflector.Request.BodyMapping;
 1247            }
 1248            else
 1249            {
 91250                membersMapping = operationReflector.Reply.BodyMapping;
 1251            }
 1252
 181253            if (membersMapping != null)
 1254            {
 181255                bool isDocWrapped = !operationReflector.IsRpc && description.Body.WrapperName != null;
 181256                ExportMembersMapping(membersMapping, wsdlMessage, false /*IsOperationInherited(operation)*/, operationRe
 181257                if (operationReflector.IsRpc)
 1258                {
 101259                    AddParameterOrder(_operation.Messages[messageIndex]);
 101260                    ExportedMessages.WrapperNamespaces.Add(key, membersMapping.Namespace);
 1261                }
 1262            }
 181263        }
 1264
 1265        protected override void ExportFaults(object state)
 1266        {
 91267            XmlSerializerOperationBehavior.Reflector.OperationReflector operationReflector = (XmlSerializerOperationBeha
 91268            if (operationReflector.Attribute.SupportFaults)
 1269            {
 101270                foreach (FaultDescription fault in _operation.Faults)
 1271                {
 01272                    ExportFault(fault, operationReflector);
 1273                }
 1274
 51275                Compile();
 1276            }
 1277            else
 1278            {
 41279                base.ExportFaults(state);
 1280            }
 41281        }
 1282
 1283        private void ExportFault(FaultDescription fault, XmlSerializerOperationBehavior.Reflector.OperationReflector ope
 1284        {
 01285            WsdlNS.Message faultMessage = new WsdlNS.Message();
 01286            faultMessage.Name = GetFaultMessageName(fault.Name);
 1287
 01288            XmlQualifiedName elementName = ExportFaultElement(fault, operationReflector);
 01289            _contractContext.WsdlPortType.ServiceDescription.Messages.Add(faultMessage);
 01290            AddMessagePart(faultMessage, "detail", elementName, null);
 1291
 1292            // create a wsdl:fault to put inside the wsdl:portType/wsdl:operation
 01293            WsdlNS.OperationFault operationFault = _contractContext.GetOperationFault(fault);
 01294            WsdlExporter.WSAddressingHelper.AddActionAttribute(fault.Action, operationFault, _exporter.PolicyVersion);
 01295            operationFault.Message = new XmlQualifiedName(faultMessage.Name, faultMessage.ServiceDescription.TargetNames
 01296        }
 1297
 1298        private XmlQualifiedName ExportFaultElement(FaultDescription fault, XmlSerializerOperationBehavior.Reflector.Ope
 1299        {
 1300            XmlQualifiedName elementName;
 01301            XmlMembersMapping mapping = operationReflector.ImportFaultElement(fault, out elementName);
 01302            if (operationReflector.IsEncoded)
 1303            {
 01304                SoapExporter.ExportMembersMapping(mapping);
 1305            }
 1306            else
 1307            {
 01308                XmlExporter.ExportMembersMapping(mapping);
 1309            }
 1310
 01311            return elementName;
 1312        }
 1313
 1314        protected override void ExportKnownTypes()
 1315        {
 91316        }
 1317
 1318        protected override object GetExtensionData()
 1319        {
 21320            return new ExtensionData(((XmlSerializerOperationBehavior)_extension).XmlSerializerFormatAttribute);
 1321        }
 1322
 1323        private class ExtensionData
 1324        {
 1325            private readonly XmlSerializerFormatAttribute xsFormatAttr;
 21326            internal ExtensionData(XmlSerializerFormatAttribute xsFormatAttr)
 1327            {
 21328                this.xsFormatAttr = xsFormatAttr;
 21329            }
 1330
 1331            public override bool Equals(object obj)
 1332            {
 01333                if (ReferenceEquals(xsFormatAttr, obj))
 1334                {
 01335                    return true;
 1336                }
 1337
 01338                ExtensionData otherExtensionData = obj as ExtensionData;
 01339                if (otherExtensionData == null)
 1340                {
 01341                    return false;
 1342                }
 1343
 01344                return xsFormatAttr.Style == otherExtensionData.xsFormatAttr.Style &&
 01345                    xsFormatAttr.Use == otherExtensionData.xsFormatAttr.Use;
 1346            }
 1347
 01348            public override int GetHashCode() => 1; //This is never called
 1349        }
 1350
 1351        private void ExportMembersMapping(XmlMembersMapping membersMapping, WsdlNS.Message message, bool skipSchemaExpor
 1352        {
 181353            if (!skipSchemaExport)
 1354            {
 181355                if (isEncoded)
 1356                {
 81357                    SoapExporter.ExportMembersMapping(membersMapping);
 1358                }
 1359                else
 1360                {
 101361                    XmlExporter.ExportMembersMapping(membersMapping, !isRpc);
 1362                }
 1363            }
 1364
 181365            if (isDocWrapped)
 1366            {
 81367                if (isHeader)
 1368                {
 1369                    Fx.Assert("Header cannot be Document Wrapped");
 01370                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Forma
 1371                }
 1372
 81373                AddMessagePart(message, "parameters", new XmlQualifiedName(membersMapping.XsdElementName, membersMapping
 81374                return;
 1375            }
 101376            bool generateElement = !isRpc && !isEncoded;
 421377            for (int i = 0; i < membersMapping.Count; i++)
 1378            {
 111379                XmlMemberMapping member = membersMapping[i];
 1380
 111381                string partName = (isHeader || generateElement) ? NamingHelper.XmlName(member.MemberName) : member.XsdEl
 111382                if (generateElement)
 1383                {
 01384                    AddMessagePart(message, partName, new XmlQualifiedName(member.XsdElementName, member.Namespace), Xml
 1385                }
 1386                else
 1387                {
 111388                    if (string.IsNullOrEmpty(member.TypeName))
 1389                    {
 01390                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Forma
 1391                    }
 1392
 111393                    AddMessagePart(message, partName, XmlQualifiedName.Empty, new XmlQualifiedName(member.TypeName, memb
 1394                }
 1395            }
 101396        }
 1397
 1398        private XmlSerializerOperationBehavior.Reflector Reflector
 1399        {
 1400            get
 1401            {
 1402                object reflector;
 91403                if (!_exporter.State.TryGetValue(typeof(XmlSerializerOperationBehavior.Reflector), out reflector))
 1404                {
 21405                    reflector = new XmlSerializerOperationBehavior.Reflector(_contractContext.Contract.Namespace, _contr
 21406                    _exporter.State.Add(typeof(XmlSerializerOperationBehavior.Reflector), reflector);
 1407                }
 1408
 91409                return (XmlSerializerOperationBehavior.Reflector)reflector;
 1410            }
 1411        }
 1412
 1413        private SoapSchemaExporter SoapExporter
 1414        {
 1415            get
 1416            {
 1417                object soapExporter;
 81418                if (!_exporter.State.TryGetValue(typeof(SoapSchemaExporter), out soapExporter))
 1419                {
 11420                    soapExporter = new SoapSchemaExporter(Schemas);
 11421                    _exporter.State.Add(typeof(SoapSchemaExporter), soapExporter);
 1422                }
 1423
 81424                return (SoapSchemaExporter)soapExporter;
 1425            }
 1426        }
 1427
 1428        private XmlSchemaExporter XmlExporter
 1429        {
 1430            get
 1431            {
 1432                object xmlExporter;
 101433                if (!_exporter.State.TryGetValue(typeof(XmlSchemaExporter), out xmlExporter))
 1434                {
 11435                    xmlExporter = new XmlSchemaExporter(Schemas);
 11436                    _exporter.State.Add(typeof(XmlSchemaExporter), xmlExporter);
 1437                }
 1438
 101439                return (XmlSchemaExporter)xmlExporter;
 1440            }
 1441        }
 1442
 1443        private XmlSchemas Schemas
 1444        {
 1445            get
 1446            {
 1447                object schemas;
 251448                if (!_exporter.State.TryGetValue(typeof(XmlSchemas), out schemas))
 1449                {
 21450                    schemas = new XmlSchemas();
 41451                    foreach (XmlSchema schema in SchemaSet.Schemas())
 1452                    {
 01453                        if (!((XmlSchemas)schemas).Contains(schema.TargetNamespace))
 1454                        {
 01455                            ((XmlSchemas)schemas).Add(schema);
 1456                        }
 1457                    }
 1458
 21459                    _exporter.State.Add(typeof(XmlSchemas), schemas);
 1460                }
 1461
 251462                return (XmlSchemas)schemas;
 1463            }
 1464        }
 1465
 1466        protected override void Compile()
 1467        {
 231468            XmlSchema wsdl = StockSchemas.CreateWsdl();
 231469            XmlSchema soap = StockSchemas.CreateSoap();
 231470            XmlSchema soapEncoding = StockSchemas.CreateSoapEncoding();
 231471            XmlSchema fakeXsdSchema = StockSchemas.CreateFakeXsdSchema();
 1472
 231473            MoveSchemas();
 231474            SchemaSet.Add(wsdl);
 231475            SchemaSet.Add(soap);
 231476            SchemaSet.Add(soapEncoding);
 231477            SchemaSet.Add(fakeXsdSchema);
 231478            base.Compile();
 231479            SchemaSet.Remove(wsdl);
 231480            SchemaSet.Remove(soap);
 231481            SchemaSet.Remove(soapEncoding);
 231482            SchemaSet.Remove(fakeXsdSchema);
 231483        }
 1484
 1485        private void MoveSchemas()
 1486        {
 231487            XmlSchemas schemas = Schemas;
 231488            XmlSchemaSet schemaSet = SchemaSet;
 231489            if (schemas != null)
 1490            {
 231491                schemas.Compile(
 231492                     (object sender, ValidationEventArgs args) =>
 231493                     {
 01494                         SchemaHelper.HandleSchemaValidationError(sender, args, _exporter.Errors);
 01495                     },
 231496                     false/*fullCompile*/
 231497                );
 981498                foreach (XmlSchema srcSchema in schemas)
 1499                {
 261500                    if (!schemaSet.Contains(srcSchema))
 1501                    {
 31502                        schemaSet.Add(srcSchema);
 31503                        schemaSet.Reprocess(srcSchema);
 1504                    }
 1505                }
 1506            }
 231507        }
 1508    }
 1509
 1510    internal static class StockSchemas
 1511    {
 1512        internal static XmlSchema CreateWsdl()
 1513        {
 1514            StringReader reader = new StringReader(wsdl);
 1515            return XmlSchema.Read(new XmlTextReader(reader) { DtdProcessing = DtdProcessing.Prohibit }, null);
 1516        }
 1517
 1518        internal static XmlSchema CreateSoap()
 1519        {
 1520            StringReader reader = new StringReader(soap);
 1521            return XmlSchema.Read(new XmlTextReader(reader) { DtdProcessing = DtdProcessing.Prohibit }, null);
 1522        }
 1523
 1524        internal static XmlSchema CreateSoapEncoding()
 1525        {
 1526            StringReader reader = new StringReader(soapEncoding);
 1527            return XmlSchema.Read(new XmlTextReader(reader) { DtdProcessing = DtdProcessing.Prohibit }, null);
 1528        }
 1529
 1530        internal static XmlSchema CreateFakeSoapEncoding()
 1531        {
 1532            StringReader reader = new StringReader(fakeSoapEncoding);
 1533            return XmlSchema.Read(new XmlTextReader(reader) { DtdProcessing = DtdProcessing.Prohibit }, null);
 1534        }
 1535
 1536        internal static XmlSchema CreateFakeXsdSchema()
 1537        {
 1538            StringReader reader = new StringReader(fakeXsd);
 1539            return XmlSchema.Read(new XmlTextReader(reader) { DtdProcessing = DtdProcessing.Prohibit }, null);
 1540        }
 1541
 1542        internal static XmlSchema CreateFakeXmlSchema()
 1543        {
 1544            StringReader reader = new StringReader(fakeXmlSchema);
 1545            return XmlSchema.Read(new XmlTextReader(reader) { DtdProcessing = DtdProcessing.Prohibit }, null);
 1546        }
 1547
 1548        internal static bool IsKnownSchema(string ns)
 1549        {
 1550            return ns == XmlSchema.Namespace || ns == "http://schemas.xmlsoap.org/wsdl/soap/" || ns == "http://schemas.x
 1551        }
 1552
 1553        internal const string WsdlNamespace = "http://schemas.xmlsoap.org/wsdl/";
 1554        internal const string SoapNamespace = "http://schemas.xmlsoap.org/wsdl/soap/";
 1555        internal const string SoapEncodingNamespace = "http://schemas.xmlsoap.org/soap/encoding/";
 1556        private const string wsdl = @"<?xml version='1.0' encoding='UTF-8' ?>
 1557<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'
 1558           xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
 1559           targetNamespace='http://schemas.xmlsoap.org/wsdl/'
 1560           elementFormDefault='qualified' >
 1561
 1562  <xs:complexType mixed='true' name='tDocumentation' >
 1563    <xs:sequence>
 1564      <xs:any minOccurs='0' maxOccurs='unbounded' processContents='lax' />
 1565    </xs:sequence>
 1566  </xs:complexType>
 1567
 1568  <xs:complexType name='tDocumented' >
 1569    <xs:annotation>
 1570      <xs:documentation>
 1571      This type is extended by  component types to allow them to be documented
 1572      </xs:documentation>
 1573    </xs:annotation>
 1574    <xs:sequence>
 1575      <xs:element name='documentation' type='wsdl:tDocumentation' minOccurs='0' />
 1576    </xs:sequence>
 1577  </xs:complexType>
 1578 <!-- allow extensibility via elements and attributes on all elements swa124 -->
 1579 <xs:complexType name='tExtensibleAttributesDocumented' abstract='true' >
 1580    <xs:complexContent>
 1581      <xs:extension base='wsdl:tDocumented' >
 1582        <xs:annotation>
 1583          <xs:documentation>
 1584          This type is extended by component types to allow attributes from other namespaces to be added.
 1585          </xs:documentation>
 1586        </xs:annotation>
 1587        <xs:sequence>
 1588          <xs:any namespace='##other' minOccurs='0' maxOccurs='unbounded' processContents='lax' />
 1589        </xs:sequence>
 1590        <xs:anyAttribute namespace='##other' processContents='lax' />
 1591      </xs:extension>
 1592    </xs:complexContent>
 1593  </xs:complexType>
 1594  <xs:complexType name='tExtensibleDocumented' abstract='true' >
 1595    <xs:complexContent>
 1596      <xs:extension base='wsdl:tDocumented' >
 1597        <xs:annotation>
 1598          <xs:documentation>
 1599          This type is extended by component types to allow elements from other namespaces to be added.
 1600          </xs:documentation>
 1601        </xs:annotation>
 1602        <xs:sequence>
 1603          <xs:any namespace='##other' minOccurs='0' maxOccurs='unbounded' processContents='lax' />
 1604        </xs:sequence>
 1605        <xs:anyAttribute namespace='##other' processContents='lax' />
 1606      </xs:extension>
 1607    </xs:complexContent>
 1608  </xs:complexType>
 1609  <!-- original wsdl removed as part of swa124 resolution
 1610  <xs:complexType name='tExtensibleAttributesDocumented' abstract='true' >
 1611    <xs:complexContent>
 1612      <xs:extension base='wsdl:tDocumented' >
 1613        <xs:annotation>
 1614          <xs:documentation>
 1615          This type is extended by component types to allow attributes from other namespaces to be added.
 1616          </xs:documentation>
 1617        </xs:annotation>
 1618        <xs:anyAttribute namespace='##other' processContents='lax' />
 1619      </xs:extension>
 1620    </xs:complexContent>
 1621  </xs:complexType>
 1622
 1623  <xs:complexType name='tExtensibleDocumented' abstract='true' >
 1624    <xs:complexContent>
 1625      <xs:extension base='wsdl:tDocumented' >
 1626        <xs:annotation>
 1627          <xs:documentation>
 1628          This type is extended by component types to allow elements from other namespaces to be added.
 1629          </xs:documentation>
 1630        </xs:annotation>
 1631        <xs:sequence>
 1632          <xs:any namespace='##other' minOccurs='0' maxOccurs='unbounded' processContents='lax' />
 1633        </xs:sequence>
 1634      </xs:extension>
 1635    </xs:complexContent>
 1636  </xs:complexType>
 1637 -->
 1638  <xs:element name='definitions' type='wsdl:tDefinitions' >
 1639    <xs:key name='message' >
 1640      <xs:selector xpath='wsdl:message' />
 1641      <xs:field xpath='@name' />
 1642    </xs:key>
 1643    <xs:key name='portType' >
 1644      <xs:selector xpath='wsdl:portType' />
 1645      <xs:field xpath='@name' />
 1646    </xs:key>
 1647    <xs:key name='binding' >
 1648      <xs:selector xpath='wsdl:binding' />
 1649      <xs:field xpath='@name' />
 1650    </xs:key>
 1651    <xs:key name='service' >
 1652      <xs:selector xpath='wsdl:service' />
 1653      <xs:field xpath='@name' />
 1654    </xs:key>
 1655    <xs:key name='import' >
 1656      <xs:selector xpath='wsdl:import' />
 1657      <xs:field xpath='@namespace' />
 1658    </xs:key>
 1659  </xs:element>
 1660
 1661  <xs:group name='anyTopLevelOptionalElement' >
 1662    <xs:annotation>
 1663      <xs:documentation>
 1664      Any top level optional element allowed to appear more then once - any child of definitions element except wsdl:typ
 1665      </xs:documentation>
 1666    </xs:annotation>
 1667    <xs:choice>
 1668      <xs:element name='import' type='wsdl:tImport' />
 1669      <xs:element name='types' type='wsdl:tTypes' />
 1670      <xs:element name='message'  type='wsdl:tMessage' >
 1671        <xs:unique name='part' >
 1672          <xs:selector xpath='wsdl:part' />
 1673          <xs:field xpath='@name' />
 1674        </xs:unique>
 1675      </xs:element>
 1676      <xs:element name='portType' type='wsdl:tPortType' />
 1677      <xs:element name='binding'  type='wsdl:tBinding' />
 1678      <xs:element name='service'  type='wsdl:tService' >
 1679        <xs:unique name='port' >
 1680          <xs:selector xpath='wsdl:port' />
 1681          <xs:field xpath='@name' />
 1682        </xs:unique>
 1683      </xs:element>
 1684    </xs:choice>
 1685  </xs:group>
 1686
 1687  <xs:complexType name='tDefinitions' >
 1688    <xs:complexContent>
 1689      <xs:extension base='wsdl:tExtensibleDocumented' >
 1690        <xs:sequence>
 1691          <xs:group ref='wsdl:anyTopLevelOptionalElement'  minOccurs='0'   maxOccurs='unbounded' />
 1692        </xs:sequence>
 1693        <xs:attribute name='targetNamespace' type='xs:anyURI' use='optional' />
 1694        <xs:attribute name='name' type='xs:NCName' use='optional' />
 1695      </xs:extension>
 1696    </xs:complexContent>
 1697  </xs:complexType>
 1698
 1699  <xs:complexType name='tImport' >
 1700    <xs:complexContent>
 1701      <xs:extension base='wsdl:tExtensibleAttributesDocumented' >
 1702        <xs:attribute name='namespace' type='xs:anyURI' use='required' />
 1703        <xs:attribute name='location' type='xs:anyURI' use='required' />
 1704      </xs:extension>
 1705    </xs:complexContent>
 1706  </xs:complexType>
 1707
 1708  <xs:complexType name='tTypes' >
 1709    <xs:complexContent>
 1710      <xs:extension base='wsdl:tExtensibleDocumented' />
 1711    </xs:complexContent>
 1712  </xs:complexType>
 1713
 1714  <xs:complexType name='tMessage' >
 1715    <xs:complexContent>
 1716      <xs:extension base='wsdl:tExtensibleDocumented' >
 1717        <xs:sequence>
 1718          <xs:element name='part' type='wsdl:tPart' minOccurs='0' maxOccurs='unbounded' />
 1719        </xs:sequence>
 1720        <xs:attribute name='name' type='xs:NCName' use='required' />
 1721      </xs:extension>
 1722    </xs:complexContent>
 1723  </xs:complexType>
 1724
 1725  <xs:complexType name='tPart' >
 1726    <xs:complexContent>
 1727      <xs:extension base='wsdl:tExtensibleAttributesDocumented' >
 1728        <xs:attribute name='name' type='xs:NCName' use='required' />
 1729        <xs:attribute name='element' type='xs:QName' use='optional' />
 1730        <xs:attribute name='type' type='xs:QName' use='optional' />
 1731      </xs:extension>
 1732    </xs:complexContent>
 1733  </xs:complexType>
 1734
 1735  <xs:complexType name='tPortType' >
 1736    <xs:complexContent>
 1737      <xs:extension base='wsdl:tExtensibleAttributesDocumented' >
 1738        <xs:sequence>
 1739          <xs:element name='operation' type='wsdl:tOperation' minOccurs='0' maxOccurs='unbounded' />
 1740        </xs:sequence>
 1741        <xs:attribute name='name' type='xs:NCName' use='required' />
 1742      </xs:extension>
 1743    </xs:complexContent>
 1744  </xs:complexType>
 1745
 1746  <xs:complexType name='tOperation' >
 1747    <xs:complexContent>
 1748      <xs:extension base='wsdl:tExtensibleDocumented' >
 1749        <xs:sequence>
 1750          <xs:choice>
 1751            <xs:group ref='wsdl:request-response-or-one-way-operation' />
 1752            <xs:group ref='wsdl:solicit-response-or-notification-operation' />
 1753          </xs:choice>
 1754        </xs:sequence>
 1755        <xs:attribute name='name' type='xs:NCName' use='required' />
 1756        <xs:attribute name='parameterOrder' type='xs:NMTOKENS' use='optional' />
 1757      </xs:extension>
 1758    </xs:complexContent>
 1759  </xs:complexType>
 1760
 1761  <xs:group name='request-response-or-one-way-operation' >
 1762    <xs:sequence>
 1763      <xs:element name='input' type='wsdl:tParam' />
 1764      <xs:sequence minOccurs='0' >
 1765        <xs:element name='output' type='wsdl:tParam' />
 1766        <xs:element name='fault' type='wsdl:tFault' minOccurs='0' maxOccurs='unbounded' />
 1767      </xs:sequence>
 1768    </xs:sequence>
 1769  </xs:group>
 1770
 1771  <xs:group name='solicit-response-or-notification-operation' >
 1772    <xs:sequence>
 1773      <xs:element name='output' type='wsdl:tParam' />
 1774      <xs:sequence minOccurs='0' >
 1775        <xs:element name='input' type='wsdl:tParam' />
 1776        <xs:element name='fault' type='wsdl:tFault' minOccurs='0' maxOccurs='unbounded' />
 1777      </xs:sequence>
 1778    </xs:sequence>
 1779  </xs:group>
 1780
 1781  <xs:complexType name='tParam' >
 1782    <xs:complexContent>
 1783      <xs:extension base='wsdl:tExtensibleAttributesDocumented' >
 1784        <xs:attribute name='name' type='xs:NCName' use='optional' />
 1785        <xs:attribute name='message' type='xs:QName' use='required' />
 1786      </xs:extension>
 1787    </xs:complexContent>
 1788  </xs:complexType>
 1789
 1790  <xs:complexType name='tFault' >
 1791    <xs:complexContent>
 1792      <xs:extension base='wsdl:tExtensibleAttributesDocumented' >
 1793        <xs:attribute name='name' type='xs:NCName'  use='required' />
 1794        <xs:attribute name='message' type='xs:QName' use='required' />
 1795      </xs:extension>
 1796    </xs:complexContent>
 1797  </xs:complexType>
 1798
 1799  <xs:complexType name='tBinding' >
 1800    <xs:complexContent>
 1801      <xs:extension base='wsdl:tExtensibleDocumented' >
 1802        <xs:sequence>
 1803          <xs:element name='operation' type='wsdl:tBindingOperation' minOccurs='0' maxOccurs='unbounded' />
 1804        </xs:sequence>
 1805        <xs:attribute name='name' type='xs:NCName' use='required' />
 1806        <xs:attribute name='type' type='xs:QName' use='required' />
 1807      </xs:extension>
 1808    </xs:complexContent>
 1809  </xs:complexType>
 1810
 1811  <xs:complexType name='tBindingOperationMessage' >
 1812    <xs:complexContent>
 1813      <xs:extension base='wsdl:tExtensibleDocumented' >
 1814        <xs:attribute name='name' type='xs:NCName' use='optional' />
 1815      </xs:extension>
 1816    </xs:complexContent>
 1817  </xs:complexType>
 1818
 1819  <xs:complexType name='tBindingOperationFault' >
 1820    <xs:complexContent>
 1821      <xs:extension base='wsdl:tExtensibleDocumented' >
 1822        <xs:attribute name='name' type='xs:NCName' use='required' />
 1823      </xs:extension>
 1824    </xs:complexContent>
 1825  </xs:complexType>
 1826
 1827  <xs:complexType name='tBindingOperation' >
 1828    <xs:complexContent>
 1829      <xs:extension base='wsdl:tExtensibleDocumented' >
 1830        <xs:sequence>
 1831          <xs:element name='input' type='wsdl:tBindingOperationMessage' minOccurs='0' />
 1832          <xs:element name='output' type='wsdl:tBindingOperationMessage' minOccurs='0' />
 1833          <xs:element name='fault' type='wsdl:tBindingOperationFault' minOccurs='0' maxOccurs='unbounded' />
 1834        </xs:sequence>
 1835        <xs:attribute name='name' type='xs:NCName' use='required' />
 1836      </xs:extension>
 1837    </xs:complexContent>
 1838  </xs:complexType>
 1839
 1840  <xs:complexType name='tService' >
 1841    <xs:complexContent>
 1842      <xs:extension base='wsdl:tExtensibleDocumented' >
 1843        <xs:sequence>
 1844          <xs:element name='port' type='wsdl:tPort' minOccurs='0' maxOccurs='unbounded' />
 1845        </xs:sequence>
 1846        <xs:attribute name='name' type='xs:NCName' use='required' />
 1847      </xs:extension>
 1848    </xs:complexContent>
 1849  </xs:complexType>
 1850
 1851  <xs:complexType name='tPort' >
 1852    <xs:complexContent>
 1853      <xs:extension base='wsdl:tExtensibleDocumented' >
 1854        <xs:attribute name='name' type='xs:NCName' use='required' />
 1855        <xs:attribute name='binding' type='xs:QName' use='required' />
 1856      </xs:extension>
 1857    </xs:complexContent>
 1858  </xs:complexType>
 1859
 1860  <xs:attribute name='arrayType' type='xs:string' />
 1861  <xs:attribute name='required' type='xs:boolean' />
 1862  <xs:complexType name='tExtensibilityElement' abstract='true' >
 1863    <xs:attribute ref='wsdl:required' use='optional' />
 1864  </xs:complexType>
 1865
 1866</xs:schema>";
 1867        private const string soap = @"<?xml version='1.0' encoding='UTF-8' ?>
 1868<xs:schema xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/' targetNamesp
 1869  <xs:import namespace='http://schemas.xmlsoap.org/wsdl/' />
 1870  <xs:simpleType name='encodingStyle'>
 1871    <xs:annotation>
 1872      <xs:documentation>
 1873      'encodingStyle' indicates any canonicalization conventions followed in the contents of the containing element.  Fo
 1874      </xs:documentation>
 1875    </xs:annotation>
 1876    <xs:list itemType='xs:anyURI' />
 1877  </xs:simpleType>
 1878  <xs:element name='binding' type='soap:tBinding' />
 1879  <xs:complexType name='tBinding'>
 1880    <xs:complexContent mixed='false'>
 1881      <xs:extension base='wsdl:tExtensibilityElement'>
 1882        <xs:attribute name='transport' type='xs:anyURI' use='required' />
 1883        <xs:attribute name='style' type='soap:tStyleChoice' use='optional' />
 1884      </xs:extension>
 1885    </xs:complexContent>
 1886  </xs:complexType>
 1887  <xs:simpleType name='tStyleChoice'>
 1888    <xs:restriction base='xs:string'>
 1889      <xs:enumeration value='rpc' />
 1890      <xs:enumeration value='document' />
 1891    </xs:restriction>
 1892  </xs:simpleType>
 1893  <xs:element name='operation' type='soap:tOperation' />
 1894  <xs:complexType name='tOperation'>
 1895    <xs:complexContent mixed='false'>
 1896      <xs:extension base='wsdl:tExtensibilityElement'>
 1897        <xs:attribute name='soapAction' type='xs:anyURI' use='optional' />
 1898        <xs:attribute name='style' type='soap:tStyleChoice' use='optional' />
 1899      </xs:extension>
 1900    </xs:complexContent>
 1901  </xs:complexType>
 1902  <xs:element name='body' type='soap:tBody' />
 1903  <xs:attributeGroup name='tBodyAttributes'>
 1904    <xs:attribute name='encodingStyle' type='soap:encodingStyle' use='optional' />
 1905    <xs:attribute name='use' type='soap:useChoice' use='optional' />
 1906    <xs:attribute name='namespace' type='xs:anyURI' use='optional' />
 1907  </xs:attributeGroup>
 1908  <xs:complexType name='tBody'>
 1909    <xs:complexContent mixed='false'>
 1910      <xs:extension base='wsdl:tExtensibilityElement'>
 1911        <xs:attribute name='parts' type='xs:NMTOKENS' use='optional' />
 1912        <xs:attributeGroup ref='soap:tBodyAttributes' />
 1913      </xs:extension>
 1914    </xs:complexContent>
 1915  </xs:complexType>
 1916  <xs:simpleType name='useChoice'>
 1917    <xs:restriction base='xs:string'>
 1918      <xs:enumeration value='literal' />
 1919      <xs:enumeration value='encoded' />
 1920    </xs:restriction>
 1921  </xs:simpleType>
 1922  <xs:element name='fault' type='soap:tFault' />
 1923  <xs:complexType name='tFaultRes' abstract='true'>
 1924    <xs:complexContent mixed='false'>
 1925      <xs:restriction base='soap:tBody'>
 1926        <xs:attribute ref='wsdl:required' use='optional' />
 1927        <xs:attribute name='parts' type='xs:NMTOKENS' use='prohibited' />
 1928        <xs:attributeGroup ref='soap:tBodyAttributes' />
 1929      </xs:restriction>
 1930    </xs:complexContent>
 1931  </xs:complexType>
 1932  <xs:complexType name='tFault'>
 1933    <xs:complexContent mixed='false'>
 1934      <xs:extension base='soap:tFaultRes'>
 1935        <xs:attribute name='name' type='xs:NCName' use='required' />
 1936      </xs:extension>
 1937    </xs:complexContent>
 1938  </xs:complexType>
 1939  <xs:element name='header' type='soap:tHeader' />
 1940  <xs:attributeGroup name='tHeaderAttributes'>
 1941    <xs:attribute name='message' type='xs:QName' use='required' />
 1942    <xs:attribute name='part' type='xs:NMTOKEN' use='required' />
 1943    <xs:attribute name='use' type='soap:useChoice' use='required' />
 1944    <xs:attribute name='encodingStyle' type='soap:encodingStyle' use='optional' />
 1945    <xs:attribute name='namespace' type='xs:anyURI' use='optional' />
 1946  </xs:attributeGroup>
 1947  <xs:complexType name='tHeader'>
 1948    <xs:complexContent mixed='false'>
 1949      <xs:extension base='wsdl:tExtensibilityElement'>
 1950        <xs:sequence>
 1951          <xs:element minOccurs='0' maxOccurs='unbounded' ref='soap:headerfault' />
 1952        </xs:sequence>
 1953        <xs:attributeGroup ref='soap:tHeaderAttributes' />
 1954      </xs:extension>
 1955    </xs:complexContent>
 1956  </xs:complexType>
 1957  <xs:element name='headerfault' type='soap:tHeaderFault' />
 1958  <xs:complexType name='tHeaderFault'>
 1959    <xs:attributeGroup ref='soap:tHeaderAttributes' />
 1960  </xs:complexType>
 1961  <xs:element name='address' type='soap:tAddress' />
 1962  <xs:complexType name='tAddress'>
 1963    <xs:complexContent mixed='false'>
 1964      <xs:extension base='wsdl:tExtensibilityElement'>
 1965        <xs:attribute name='location' type='xs:anyURI' use='required' />
 1966      </xs:extension>
 1967    </xs:complexContent>
 1968  </xs:complexType>
 1969</xs:schema>";
 1970        private const string soapEncoding = @"<?xml version='1.0' encoding='UTF-8' ?>
 1971<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'
 1972           xmlns:tns='http://schemas.xmlsoap.org/soap/encoding/'
 1973           targetNamespace='http://schemas.xmlsoap.org/soap/encoding/' >
 1974
 1975 <xs:attribute name='root' >
 1976   <xs:simpleType>
 1977     <xs:restriction base='xs:boolean'>
 1978       <xs:pattern value='0|1' />
 1979     </xs:restriction>
 1980   </xs:simpleType>
 1981 </xs:attribute>
 1982
 1983  <xs:attributeGroup name='commonAttributes' >
 1984    <xs:attribute name='id' type='xs:ID' />
 1985    <xs:attribute name='href' type='xs:anyURI' />
 1986    <xs:anyAttribute namespace='##other' processContents='lax' />
 1987  </xs:attributeGroup>
 1988
 1989  <xs:simpleType name='arrayCoordinate' >
 1990    <xs:restriction base='xs:string' />
 1991  </xs:simpleType>
 1992
 1993  <xs:attribute name='arrayType' type='xs:string' />
 1994  <xs:attribute name='offset' type='tns:arrayCoordinate' />
 1995
 1996  <xs:attributeGroup name='arrayAttributes' >
 1997    <xs:attribute ref='tns:arrayType' />
 1998    <xs:attribute ref='tns:offset' />
 1999  </xs:attributeGroup>
 2000
 2001  <xs:attribute name='position' type='tns:arrayCoordinate' />
 2002
 2003  <xs:attributeGroup name='arrayMemberAttributes' >
 2004    <xs:attribute ref='tns:position' />
 2005  </xs:attributeGroup>
 2006
 2007  <xs:group name='Array' >
 2008    <xs:sequence>
 2009      <xs:any namespace='##any' minOccurs='0' maxOccurs='unbounded' processContents='lax' />
 2010    </xs:sequence>
 2011  </xs:group>
 2012
 2013  <xs:element name='Array' type='tns:Array' />
 2014  <xs:complexType name='Array' >
 2015    <xs:group ref='tns:Array' minOccurs='0' />
 2016    <xs:attributeGroup ref='tns:arrayAttributes' />
 2017    <xs:attributeGroup ref='tns:commonAttributes' />
 2018  </xs:complexType>
 2019  <xs:element name='Struct' type='tns:Struct' />
 2020  <xs:group name='Struct' >
 2021    <xs:sequence>
 2022      <xs:any namespace='##any' minOccurs='0' maxOccurs='unbounded' processContents='lax' />
 2023    </xs:sequence>
 2024  </xs:group>
 2025
 2026  <xs:complexType name='Struct' >
 2027    <xs:group ref='tns:Struct' minOccurs='0' />
 2028    <xs:attributeGroup ref='tns:commonAttributes'/>
 2029  </xs:complexType>
 2030
 2031  <xs:simpleType name='base64' >
 2032    <xs:restriction base='xs:base64Binary' />
 2033  </xs:simpleType>
 2034
 2035  <xs:element name='duration' type='tns:duration' />
 2036  <xs:complexType name='duration' >
 2037    <xs:simpleContent>
 2038      <xs:extension base='xs:duration' >
 2039        <xs:attributeGroup ref='tns:commonAttributes' />
 2040      </xs:extension>
 2041    </xs:simpleContent>
 2042  </xs:complexType>
 2043
 2044  <xs:element name='dateTime' type='tns:dateTime' />
 2045  <xs:complexType name='dateTime' >
 2046    <xs:simpleContent>
 2047      <xs:extension base='xs:dateTime' >
 2048        <xs:attributeGroup ref='tns:commonAttributes' />
 2049      </xs:extension>
 2050    </xs:simpleContent>
 2051  </xs:complexType>
 2052
 2053
 2054
 2055  <xs:element name='NOTATION' type='tns:NOTATION' />
 2056  <xs:complexType name='NOTATION' >
 2057    <xs:simpleContent>
 2058      <xs:extension base='xs:QName' >
 2059        <xs:attributeGroup ref='tns:commonAttributes' />
 2060      </xs:extension>
 2061    </xs:simpleContent>
 2062  </xs:complexType>
 2063
 2064
 2065  <xs:element name='time' type='tns:time' />
 2066  <xs:complexType name='time' >
 2067    <xs:simpleContent>
 2068      <xs:extension base='xs:time' >
 2069        <xs:attributeGroup ref='tns:commonAttributes' />
 2070      </xs:extension>
 2071    </xs:simpleContent>
 2072  </xs:complexType>
 2073
 2074  <xs:element name='date' type='tns:date' />
 2075  <xs:complexType name='date' >
 2076    <xs:simpleContent>
 2077      <xs:extension base='xs:date' >
 2078        <xs:attributeGroup ref='tns:commonAttributes' />
 2079      </xs:extension>
 2080    </xs:simpleContent>
 2081  </xs:complexType>
 2082
 2083  <xs:element name='gYearMonth' type='tns:gYearMonth' />
 2084  <xs:complexType name='gYearMonth' >
 2085    <xs:simpleContent>
 2086      <xs:extension base='xs:gYearMonth' >
 2087        <xs:attributeGroup ref='tns:commonAttributes' />
 2088      </xs:extension>
 2089    </xs:simpleContent>
 2090  </xs:complexType>
 2091
 2092  <xs:element name='gYear' type='tns:gYear' />
 2093  <xs:complexType name='gYear' >
 2094    <xs:simpleContent>
 2095      <xs:extension base='xs:gYear' >
 2096        <xs:attributeGroup ref='tns:commonAttributes' />
 2097      </xs:extension>
 2098    </xs:simpleContent>
 2099  </xs:complexType>
 2100
 2101  <xs:element name='gMonthDay' type='tns:gMonthDay' />
 2102  <xs:complexType name='gMonthDay' >
 2103    <xs:simpleContent>
 2104      <xs:extension base='xs:gMonthDay' >
 2105        <xs:attributeGroup ref='tns:commonAttributes' />
 2106      </xs:extension>
 2107    </xs:simpleContent>
 2108  </xs:complexType>
 2109
 2110  <xs:element name='gDay' type='tns:gDay' />
 2111  <xs:complexType name='gDay' >
 2112    <xs:simpleContent>
 2113      <xs:extension base='xs:gDay' >
 2114        <xs:attributeGroup ref='tns:commonAttributes' />
 2115      </xs:extension>
 2116    </xs:simpleContent>
 2117  </xs:complexType>
 2118
 2119  <xs:element name='gMonth' type='tns:gMonth' />
 2120  <xs:complexType name='gMonth' >
 2121    <xs:simpleContent>
 2122      <xs:extension base='xs:gMonth' >
 2123        <xs:attributeGroup ref='tns:commonAttributes' />
 2124      </xs:extension>
 2125    </xs:simpleContent>
 2126  </xs:complexType>
 2127
 2128  <xs:element name='boolean' type='tns:boolean' />
 2129  <xs:complexType name='boolean' >
 2130    <xs:simpleContent>
 2131      <xs:extension base='xs:boolean' >
 2132        <xs:attributeGroup ref='tns:commonAttributes' />
 2133      </xs:extension>
 2134    </xs:simpleContent>
 2135  </xs:complexType>
 2136
 2137  <xs:element name='base64Binary' type='tns:base64Binary' />
 2138  <xs:complexType name='base64Binary' >
 2139    <xs:simpleContent>
 2140      <xs:extension base='xs:base64Binary' >
 2141        <xs:attributeGroup ref='tns:commonAttributes' />
 2142      </xs:extension>
 2143    </xs:simpleContent>
 2144  </xs:complexType>
 2145
 2146  <xs:element name='hexBinary' type='tns:hexBinary' />
 2147  <xs:complexType name='hexBinary' >
 2148    <xs:simpleContent>
 2149     <xs:extension base='xs:hexBinary' >
 2150       <xs:attributeGroup ref='tns:commonAttributes' />
 2151     </xs:extension>
 2152    </xs:simpleContent>
 2153  </xs:complexType>
 2154
 2155  <xs:element name='float' type='tns:float' />
 2156  <xs:complexType name='float' >
 2157    <xs:simpleContent>
 2158      <xs:extension base='xs:float' >
 2159        <xs:attributeGroup ref='tns:commonAttributes' />
 2160      </xs:extension>
 2161    </xs:simpleContent>
 2162  </xs:complexType>
 2163
 2164  <xs:element name='double' type='tns:double' />
 2165  <xs:complexType name='double' >
 2166    <xs:simpleContent>
 2167      <xs:extension base='xs:double' >
 2168        <xs:attributeGroup ref='tns:commonAttributes' />
 2169      </xs:extension>
 2170    </xs:simpleContent>
 2171  </xs:complexType>
 2172
 2173  <xs:element name='anyURI' type='tns:anyURI' />
 2174  <xs:complexType name='anyURI' >
 2175    <xs:simpleContent>
 2176      <xs:extension base='xs:anyURI' >
 2177        <xs:attributeGroup ref='tns:commonAttributes' />
 2178      </xs:extension>
 2179    </xs:simpleContent>
 2180  </xs:complexType>
 2181
 2182  <xs:element name='QName' type='tns:QName' />
 2183  <xs:complexType name='QName' >
 2184    <xs:simpleContent>
 2185      <xs:extension base='xs:QName' >
 2186        <xs:attributeGroup ref='tns:commonAttributes' />
 2187      </xs:extension>
 2188    </xs:simpleContent>
 2189  </xs:complexType>
 2190
 2191
 2192  <xs:element name='string' type='tns:string' />
 2193  <xs:complexType name='string' >
 2194    <xs:simpleContent>
 2195      <xs:extension base='xs:string' >
 2196        <xs:attributeGroup ref='tns:commonAttributes' />
 2197      </xs:extension>
 2198    </xs:simpleContent>
 2199  </xs:complexType>
 2200
 2201  <xs:element name='normalizedString' type='tns:normalizedString' />
 2202  <xs:complexType name='normalizedString' >
 2203    <xs:simpleContent>
 2204      <xs:extension base='xs:normalizedString' >
 2205        <xs:attributeGroup ref='tns:commonAttributes' />
 2206      </xs:extension>
 2207    </xs:simpleContent>
 2208  </xs:complexType>
 2209
 2210  <xs:element name='token' type='tns:token' />
 2211  <xs:complexType name='token' >
 2212    <xs:simpleContent>
 2213      <xs:extension base='xs:token' >
 2214        <xs:attributeGroup ref='tns:commonAttributes' />
 2215      </xs:extension>
 2216    </xs:simpleContent>
 2217  </xs:complexType>
 2218
 2219  <xs:element name='language' type='tns:language' />
 2220  <xs:complexType name='language' >
 2221    <xs:simpleContent>
 2222      <xs:extension base='xs:language' >
 2223        <xs:attributeGroup ref='tns:commonAttributes' />
 2224      </xs:extension>
 2225    </xs:simpleContent>
 2226  </xs:complexType>
 2227
 2228  <xs:element name='Name' type='tns:Name' />
 2229  <xs:complexType name='Name' >
 2230    <xs:simpleContent>
 2231      <xs:extension base='xs:Name' >
 2232        <xs:attributeGroup ref='tns:commonAttributes' />
 2233      </xs:extension>
 2234    </xs:simpleContent>
 2235  </xs:complexType>
 2236
 2237  <xs:element name='NMTOKEN' type='tns:NMTOKEN' />
 2238  <xs:complexType name='NMTOKEN' >
 2239    <xs:simpleContent>
 2240      <xs:extension base='xs:NMTOKEN' >
 2241        <xs:attributeGroup ref='tns:commonAttributes' />
 2242      </xs:extension>
 2243    </xs:simpleContent>
 2244  </xs:complexType>
 2245
 2246  <xs:element name='NCName' type='tns:NCName' />
 2247  <xs:complexType name='NCName' >
 2248    <xs:simpleContent>
 2249      <xs:extension base='xs:NCName' >
 2250        <xs:attributeGroup ref='tns:commonAttributes' />
 2251      </xs:extension>
 2252    </xs:simpleContent>
 2253  </xs:complexType>
 2254
 2255  <xs:element name='NMTOKENS' type='tns:NMTOKENS' />
 2256  <xs:complexType name='NMTOKENS' >
 2257    <xs:simpleContent>
 2258      <xs:extension base='xs:NMTOKENS' >
 2259        <xs:attributeGroup ref='tns:commonAttributes' />
 2260      </xs:extension>
 2261    </xs:simpleContent>
 2262  </xs:complexType>
 2263
 2264  <xs:element name='ID' type='tns:ID' />
 2265  <xs:complexType name='ID' >
 2266    <xs:simpleContent>
 2267      <xs:extension base='xs:ID' >
 2268        <xs:attributeGroup ref='tns:commonAttributes' />
 2269      </xs:extension>
 2270    </xs:simpleContent>
 2271  </xs:complexType>
 2272
 2273  <xs:element name='IDREF' type='tns:IDREF' />
 2274  <xs:complexType name='IDREF' >
 2275    <xs:simpleContent>
 2276      <xs:extension base='xs:IDREF' >
 2277        <xs:attributeGroup ref='tns:commonAttributes' />
 2278      </xs:extension>
 2279    </xs:simpleContent>
 2280  </xs:complexType>
 2281
 2282  <xs:element name='ENTITY' type='tns:ENTITY' />
 2283  <xs:complexType name='ENTITY' >
 2284    <xs:simpleContent>
 2285      <xs:extension base='xs:ENTITY' >
 2286        <xs:attributeGroup ref='tns:commonAttributes' />
 2287      </xs:extension>
 2288    </xs:simpleContent>
 2289  </xs:complexType>
 2290
 2291  <xs:element name='IDREFS' type='tns:IDREFS' />
 2292  <xs:complexType name='IDREFS' >
 2293    <xs:simpleContent>
 2294      <xs:extension base='xs:IDREFS' >
 2295        <xs:attributeGroup ref='tns:commonAttributes' />
 2296      </xs:extension>
 2297    </xs:simpleContent>
 2298  </xs:complexType>
 2299
 2300  <xs:element name='ENTITIES' type='tns:ENTITIES' />
 2301  <xs:complexType name='ENTITIES' >
 2302    <xs:simpleContent>
 2303      <xs:extension base='xs:ENTITIES' >
 2304        <xs:attributeGroup ref='tns:commonAttributes' />
 2305      </xs:extension>
 2306    </xs:simpleContent>
 2307  </xs:complexType>
 2308
 2309  <xs:element name='decimal' type='tns:decimal' />
 2310  <xs:complexType name='decimal' >
 2311    <xs:simpleContent>
 2312      <xs:extension base='xs:decimal' >
 2313        <xs:attributeGroup ref='tns:commonAttributes' />
 2314      </xs:extension>
 2315    </xs:simpleContent>
 2316  </xs:complexType>
 2317
 2318  <xs:element name='integer' type='tns:integer' />
 2319  <xs:complexType name='integer' >
 2320    <xs:simpleContent>
 2321      <xs:extension base='xs:integer' >
 2322        <xs:attributeGroup ref='tns:commonAttributes' />
 2323      </xs:extension>
 2324    </xs:simpleContent>
 2325  </xs:complexType>
 2326
 2327  <xs:element name='nonPositiveInteger' type='tns:nonPositiveInteger' />
 2328  <xs:complexType name='nonPositiveInteger' >
 2329    <xs:simpleContent>
 2330      <xs:extension base='xs:nonPositiveInteger' >
 2331        <xs:attributeGroup ref='tns:commonAttributes' />
 2332      </xs:extension>
 2333    </xs:simpleContent>
 2334  </xs:complexType>
 2335
 2336  <xs:element name='negativeInteger' type='tns:negativeInteger' />
 2337  <xs:complexType name='negativeInteger' >
 2338    <xs:simpleContent>
 2339      <xs:extension base='xs:negativeInteger' >
 2340        <xs:attributeGroup ref='tns:commonAttributes' />
 2341      </xs:extension>
 2342    </xs:simpleContent>
 2343  </xs:complexType>
 2344
 2345  <xs:element name='long' type='tns:long' />
 2346  <xs:complexType name='long' >
 2347    <xs:simpleContent>
 2348      <xs:extension base='xs:long' >
 2349        <xs:attributeGroup ref='tns:commonAttributes' />
 2350      </xs:extension>
 2351    </xs:simpleContent>
 2352  </xs:complexType>
 2353
 2354  <xs:element name='int' type='tns:int' />
 2355  <xs:complexType name='int' >
 2356    <xs:simpleContent>
 2357      <xs:extension base='xs:int' >
 2358        <xs:attributeGroup ref='tns:commonAttributes' />
 2359      </xs:extension>
 2360    </xs:simpleContent>
 2361  </xs:complexType>
 2362
 2363  <xs:element name='short' type='tns:short' />
 2364  <xs:complexType name='short' >
 2365    <xs:simpleContent>
 2366      <xs:extension base='xs:short' >
 2367        <xs:attributeGroup ref='tns:commonAttributes' />
 2368      </xs:extension>
 2369    </xs:simpleContent>
 2370  </xs:complexType>
 2371
 2372  <xs:element name='byte' type='tns:byte' />
 2373  <xs:complexType name='byte' >
 2374    <xs:simpleContent>
 2375      <xs:extension base='xs:byte' >
 2376        <xs:attributeGroup ref='tns:commonAttributes' />
 2377      </xs:extension>
 2378    </xs:simpleContent>
 2379  </xs:complexType>
 2380
 2381  <xs:element name='nonNegativeInteger' type='tns:nonNegativeInteger' />
 2382  <xs:complexType name='nonNegativeInteger' >
 2383    <xs:simpleContent>
 2384      <xs:extension base='xs:nonNegativeInteger' >
 2385        <xs:attributeGroup ref='tns:commonAttributes' />
 2386      </xs:extension>
 2387    </xs:simpleContent>
 2388  </xs:complexType>
 2389
 2390  <xs:element name='unsignedLong' type='tns:unsignedLong' />
 2391  <xs:complexType name='unsignedLong' >
 2392    <xs:simpleContent>
 2393      <xs:extension base='xs:unsignedLong' >
 2394        <xs:attributeGroup ref='tns:commonAttributes' />
 2395      </xs:extension>
 2396    </xs:simpleContent>
 2397  </xs:complexType>
 2398
 2399  <xs:element name='unsignedInt' type='tns:unsignedInt' />
 2400  <xs:complexType name='unsignedInt' >
 2401    <xs:simpleContent>
 2402      <xs:extension base='xs:unsignedInt' >
 2403        <xs:attributeGroup ref='tns:commonAttributes' />
 2404      </xs:extension>
 2405    </xs:simpleContent>
 2406  </xs:complexType>
 2407
 2408  <xs:element name='unsignedShort' type='tns:unsignedShort' />
 2409  <xs:complexType name='unsignedShort' >
 2410    <xs:simpleContent>
 2411      <xs:extension base='xs:unsignedShort' >
 2412        <xs:attributeGroup ref='tns:commonAttributes' />
 2413      </xs:extension>
 2414    </xs:simpleContent>
 2415  </xs:complexType>
 2416
 2417  <xs:element name='unsignedByte' type='tns:unsignedByte' />
 2418  <xs:complexType name='unsignedByte' >
 2419    <xs:simpleContent>
 2420      <xs:extension base='xs:unsignedByte' >
 2421        <xs:attributeGroup ref='tns:commonAttributes' />
 2422      </xs:extension>
 2423    </xs:simpleContent>
 2424  </xs:complexType>
 2425
 2426  <xs:element name='positiveInteger' type='tns:positiveInteger' />
 2427  <xs:complexType name='positiveInteger' >
 2428    <xs:simpleContent>
 2429      <xs:extension base='xs:positiveInteger' >
 2430        <xs:attributeGroup ref='tns:commonAttributes' />
 2431      </xs:extension>
 2432    </xs:simpleContent>
 2433  </xs:complexType>
 2434
 2435  <xs:element name='anyType' />
 2436</xs:schema>";
 2437        private const string fakeXsd = @"<?xml version='1.0' encoding='UTF-8' ?>
 2438<xsd:schema targetNamespace=""http://www.w3.org/2001/XMLSchema"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
 2439    <xsd:element name=""schema"">
 2440    <xsd:complexType />
 2441    </xsd:element>
 2442</xsd:schema>";
 2443        private const string fakeXmlSchema = @"<xs:schema targetNamespace='http://www.w3.org/XML/1998/namespace' xmlns:x
 2444 <xs:attribute name='lang' type='xs:language'/>
 2445 <xs:attribute name='space'>
 2446  <xs:simpleType>
 2447   <xs:restriction base='xs:NCName'>
 2448    <xs:enumeration value='default'/>
 2449    <xs:enumeration value='preserve'/>
 2450   </xs:restriction>
 2451  </xs:simpleType>
 2452 </xs:attribute>
 2453 <xs:attribute name='base' type='xs:anyURI'/>
 2454 <xs:attribute name='id' type='xs:ID' />
 2455 <xs:attributeGroup name='specialAttrs'>
 2456  <xs:attribute ref='xml:base'/>
 2457  <xs:attribute ref='xml:lang'/>
 2458  <xs:attribute ref='xml:space'/>
 2459 </xs:attributeGroup>
 2460</xs:schema>";
 2461        private const string fakeSoapEncoding = @"<?xml version='1.0' encoding='UTF-8' ?>
 2462<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'
 2463           xmlns:tns='http://schemas.xmlsoap.org/soap/encoding/'
 2464           targetNamespace='http://schemas.xmlsoap.org/soap/encoding/' >
 2465
 2466  <xs:attributeGroup name='commonAttributes' >
 2467    <xs:attribute name='id' type='xs:ID' />
 2468    <xs:attribute name='href' type='xs:anyURI' />
 2469    <xs:anyAttribute namespace='##other' processContents='lax' />
 2470  </xs:attributeGroup>
 2471
 2472  <xs:simpleType name='arrayCoordinate' >
 2473    <xs:restriction base='xs:string' />
 2474  </xs:simpleType>
 2475
 2476  <xs:attribute name='arrayType' type='xs:string' />
 2477  <xs:attribute name='offset' type='tns:arrayCoordinate' />
 2478
 2479  <xs:attributeGroup name='arrayAttributes' >
 2480    <xs:attribute ref='tns:arrayType' />
 2481    <xs:attribute ref='tns:offset' />
 2482  </xs:attributeGroup>
 2483
 2484  <xs:group name='Array' >
 2485    <xs:sequence>
 2486      <xs:any namespace='##any' minOccurs='0' maxOccurs='unbounded' processContents='lax' />
 2487    </xs:sequence>
 2488  </xs:group>
 2489
 2490  <xs:element name='Array' type='tns:Array' />
 2491  <xs:complexType name='Array' >
 2492    <xs:group ref='tns:Array' minOccurs='0' />
 2493    <xs:attributeGroup ref='tns:arrayAttributes' />
 2494    <xs:attributeGroup ref='tns:commonAttributes' />
 2495  </xs:complexType>
 2496</xs:schema>";
 2497
 2498
 2499    }
 2500}