< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Description.SoapHelper
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Description/SoapHelper.cs
Line coverage
45%
Covered lines: 126
Uncovered lines: 154
Coverable lines: 280
Total lines: 695
Line coverage: 45%
Branch coverage
45%
Covered branches: 85
Total branches: 188
Branch coverage: 45.2%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Description/SoapHelper.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.Collections.Generic;
 5using System.Xml;
 6using CoreWCF.Dispatcher;
 7using CoreWCF.Runtime;
 8using WsdlNS = System.Web.Services.Description;
 9
 10namespace CoreWCF.Description
 11{
 12    internal static class SoapHelper
 13    {
 114        private static readonly object s_soapVersionStateKey = typeof(Dictionary<WsdlNS.Binding, EnvelopeVersion>);
 15        private static XmlDocument s_xmlDocument;
 16
 17        private static XmlDocument Document
 18        {
 19            get
 20            {
 021                if (s_xmlDocument == null)
 22                {
 023                    s_xmlDocument = new XmlDocument();
 24                }
 25
 026                return s_xmlDocument;
 27            }
 28        }
 29
 30        private static XmlAttribute CreateLocalAttribute(string name, string value)
 31        {
 032            XmlAttribute attribute = Document.CreateAttribute(name);
 033            attribute.Value = value;
 034            return attribute;
 35        }
 36        //// -----------------------------------------------------------------------------------------------------------
 37        //// Developers Note: We go through a little song and dance here to Get or Create an exsisting SoapBinding from 
 38        //// Extensions for a number of reasons:
 39        ////      1. Multiple Extensions may contribute to the settings in the soap binding and so to make this work wit
 40        ////          relying on ordering, we need the GetOrCreate method.
 41        ////      2. There are diffrent classes for different SOAP versions and the extensions that determines the versi
 42        ////          also un-ordered so when we finally figure out the version we may need to recreate the BindingExten
 43        ////          clone it.
 44
 45        internal static WsdlNS.SoapAddressBinding GetOrCreateSoapAddressBinding(WsdlNS.Binding wsdlBinding, WsdlNS.Port 
 46        {
 3247            if (GetSoapVersionState(wsdlBinding, exporter) == EnvelopeVersion.None)
 48            {
 049                return null;
 50            }
 51
 3252            WsdlNS.SoapAddressBinding existingSoapAddressBinding = GetSoapAddressBinding(wsdlPort);
 3253            EnvelopeVersion version = GetSoapVersion(wsdlBinding);
 54
 3255            if (existingSoapAddressBinding != null)
 56            {
 057                return existingSoapAddressBinding;
 58            }
 59
 3260            WsdlNS.SoapAddressBinding soapAddressBinding = CreateSoapAddressBinding(version, wsdlPort);
 3261            return soapAddressBinding;
 62        }
 63
 64        public static WsdlNS.SoapBinding GetOrCreateSoapBinding(WsdlEndpointConversionContext endpointContext, WsdlExpor
 65        {
 3266            if (GetSoapVersionState(endpointContext.WsdlBinding, exporter) == EnvelopeVersion.None)
 67            {
 068                return null;
 69            }
 70
 3271            WsdlNS.SoapBinding existingSoapBinding = GetSoapBinding(endpointContext);
 3272            if (existingSoapBinding != null)
 73            {
 3274                return existingSoapBinding;
 75            }
 76
 077            EnvelopeVersion version = GetSoapVersion(endpointContext.WsdlBinding);
 078            WsdlNS.SoapBinding soapBinding = CreateSoapBinding(version, endpointContext.WsdlBinding);
 079            return soapBinding;
 80        }
 81
 82        internal static WsdlNS.SoapOperationBinding GetOrCreateSoapOperationBinding(WsdlEndpointConversionContext endpoi
 83        {
 15984            if (GetSoapVersionState(endpointContext.WsdlBinding, exporter) == EnvelopeVersion.None)
 85            {
 086                return null;
 87            }
 88
 15989            WsdlNS.SoapOperationBinding existingSoapOperationBinding = GetSoapOperationBinding(endpointContext, operatio
 15990            WsdlNS.OperationBinding wsdlOperationBinding = endpointContext.GetOperationBinding(operation);
 15991            EnvelopeVersion version = GetSoapVersion(endpointContext.WsdlBinding);
 92
 15993            if (existingSoapOperationBinding != null)
 94            {
 15995                return existingSoapOperationBinding;
 96            }
 97
 098            WsdlNS.SoapOperationBinding soapOperationBinding = CreateSoapOperationBinding(version, wsdlOperationBinding)
 099            return soapOperationBinding;
 100        }
 101
 102        internal static WsdlNS.SoapBodyBinding GetOrCreateSoapBodyBinding(WsdlEndpointConversionContext endpointContext,
 103        {
 318104            if (GetSoapVersionState(endpointContext.WsdlBinding, exporter) == EnvelopeVersion.None)
 105            {
 0106                return null;
 107            }
 108
 318109            WsdlNS.SoapBodyBinding existingSoapBodyBinding = GetSoapBodyBinding(endpointContext, wsdlMessageBinding);
 318110            EnvelopeVersion version = GetSoapVersion(endpointContext.WsdlBinding);
 111
 318112            if (existingSoapBodyBinding != null)
 113            {
 0114                return existingSoapBodyBinding;
 115            }
 116
 318117            WsdlNS.SoapBodyBinding soapBodyBinding = CreateSoapBodyBinding(version, wsdlMessageBinding);
 318118            return soapBodyBinding;
 119        }
 120
 121        internal static WsdlNS.SoapHeaderBinding CreateSoapHeaderBinding(WsdlEndpointConversionContext endpointContext, 
 122        {
 0123            EnvelopeVersion version = GetSoapVersion(endpointContext.WsdlBinding);
 124
 0125            WsdlNS.SoapHeaderBinding soapHeaderBinding = CreateSoapHeaderBinding(version, wsdlMessageBinding);
 0126            return soapHeaderBinding;
 127        }
 128
 129        internal static void CreateSoapFaultBinding(string name, WsdlEndpointConversionContext endpointContext, WsdlNS.F
 130        {
 0131            EnvelopeVersion version = GetSoapVersion(endpointContext.WsdlBinding);
 0132            XmlElement fault = CreateSoapFaultBinding(version);
 0133            fault.Attributes.Append(CreateLocalAttribute("name", name));
 0134            fault.Attributes.Append(CreateLocalAttribute("use", isEncoded ? "encoded" : "literal"));
 0135            wsdlFaultBinding.Extensions.Add(fault);
 0136        }
 137
 138        internal static void SetSoapVersion(WsdlEndpointConversionContext endpointContext, WsdlExporter exporter, Envelo
 139        {
 32140            SetSoapVersionState(endpointContext.WsdlBinding, exporter, version);
 141
 142            //Convert all SOAP extensions to the right version.
 32143            if (endpointContext.WsdlPort != null)
 144            {
 32145                SoapConverter.ConvertExtensions(endpointContext.WsdlPort.Extensions, version, SoapConverter.ConvertSoapA
 146            }
 147
 32148            SoapConverter.ConvertExtensions(endpointContext.WsdlBinding.Extensions, version, SoapConverter.ConvertSoapBi
 149
 382150            foreach (WsdlNS.OperationBinding operationBinding in endpointContext.WsdlBinding.Operations)
 151            {
 159152                SoapConverter.ConvertExtensions(operationBinding.Extensions, version, SoapConverter.ConvertSoapOperation
 153
 154                //Messages
 155                {
 159156                    if (operationBinding.Input != null)
 157                    {
 159158                        SoapConverter.ConvertExtensions(operationBinding.Input.Extensions, version, SoapConverter.Conver
 159                    }
 160
 159161                    if (operationBinding.Output != null)
 162                    {
 159163                        SoapConverter.ConvertExtensions(operationBinding.Output.Extensions, version, SoapConverter.Conve
 164                    }
 165
 318166                    foreach (WsdlNS.MessageBinding faultBinding in operationBinding.Faults)
 167                    {
 0168                        SoapConverter.ConvertExtensions(faultBinding.Extensions, version, SoapConverter.ConvertSoapMessa
 169                    }
 170                }
 171            }
 172
 32173        }
 174
 175        internal static EnvelopeVersion GetSoapVersion(WsdlNS.Binding wsdlBinding)
 176        {
 2532177            foreach (object o in wsdlBinding.Extensions)
 178            {
 916179                if (o is WsdlNS.SoapBinding)
 180                {
 636181                    return o is WsdlNS.Soap12Binding ? EnvelopeVersion.Soap12 : EnvelopeVersion.Soap11;
 182                }
 183            }
 184
 32185            return EnvelopeVersion.Soap12;
 636186        }
 187
 188        private static void SetSoapVersionState(WsdlNS.Binding wsdlBinding, WsdlExporter exporter, EnvelopeVersion versi
 189        {
 32190            object versions = null;
 191
 32192            if (!exporter.State.TryGetValue(s_soapVersionStateKey, out versions))
 193            {
 24194                versions = new Dictionary<WsdlNS.Binding, EnvelopeVersion>();
 24195                exporter.State[s_soapVersionStateKey] = versions;
 196            }
 197
 32198            ((Dictionary<WsdlNS.Binding, EnvelopeVersion>)versions)[wsdlBinding] = version;
 32199        }
 200
 201        private static EnvelopeVersion GetSoapVersionState(WsdlNS.Binding wsdlBinding, WsdlExporter exporter)
 202        {
 203            object versions;
 541204            if (exporter.State.TryGetValue(s_soapVersionStateKey, out versions))
 205            {
 517206                if (versions != null && ((Dictionary<WsdlNS.Binding, EnvelopeVersion>)versions).ContainsKey(wsdlBinding)
 207                {
 509208                    return ((Dictionary<WsdlNS.Binding, EnvelopeVersion>)versions)[wsdlBinding];
 209                }
 210            }
 211
 32212            return null;
 213        }
 214
 215        private static class SoapConverter
 216        {
 217            // This could be simplified if we used generics.
 218            internal static void ConvertExtensions(WsdlNS.ServiceDescriptionFormatExtensionCollection extensions, Envelo
 219            {
 541220                bool foundOne = false;
 1174221                for (int i = extensions.Count - 1; i >= 0; i--)
 222                {
 46223                    object o = extensions[i];
 46224                    if (conversionMethod(ref o, version))
 225                    {
 32226                        if (o == null)
 227                        {
 0228                            extensions.Remove(extensions[i]);
 229                        }
 230                        else
 231                        {
 32232                            extensions[i] = o;
 233                        }
 234
 32235                        foundOne = true;
 236                    }
 237                }
 238
 541239                if (!foundOne)
 240                {
 509241                    object o = null;
 509242                    conversionMethod(ref o, version);
 509243                    if (o != null)
 244                    {
 191245                        extensions.Add(o);
 246                    }
 247                }
 541248            }
 249
 250            // This is the delegate implemented by the 4 methods below. It is expected to:
 251            // If given a null reference for src, a new instance of the extension can be set.
 252            internal delegate bool ConvertExtension(ref object src, EnvelopeVersion version);
 253
 254            internal static bool ConvertSoapBinding(ref object src, EnvelopeVersion version)
 255            {
 46256                WsdlNS.SoapBinding binding = src as WsdlNS.SoapBinding;
 257
 46258                if (src != null)
 259                {
 14260                    if (binding == null)
 261                    {
 14262                        return false; // not a soap object
 263                    }
 0264                    else if (GetBindingVersion<WsdlNS.Soap12Binding>(src) == version)
 265                    {
 0266                        return true; // matched but same version; no change
 267                    }
 268                }
 269
 32270                if (version == EnvelopeVersion.None)
 271                {
 0272                    src = null;
 0273                    return true;
 274                }
 275
 32276                WsdlNS.SoapBinding dest = version == EnvelopeVersion.Soap12 ? new WsdlNS.Soap12Binding() : new WsdlNS.So
 32277                if (binding != null)
 278                {
 0279                    dest.Required = binding.Required;
 0280                    dest.Style = binding.Style;
 0281                    dest.Transport = binding.Transport;
 282                }
 283
 32284                src = dest;
 32285                return true;
 286            }
 287
 288            internal static bool ConvertSoapAddressBinding(ref object src, EnvelopeVersion version)
 289            {
 32290                WsdlNS.SoapAddressBinding binding = src as WsdlNS.SoapAddressBinding;
 291
 32292                if (src != null)
 293                {
 32294                    if (binding == null)
 295                    {
 0296                        return false; // no match
 297                    }
 32298                    else if (GetBindingVersion<WsdlNS.Soap12AddressBinding>(src) == version)
 299                    {
 11300                        return true; // matched but same version; no change
 301                    }
 302                }
 303
 21304                if (version == EnvelopeVersion.None)
 305                {
 0306                    src = null;
 0307                    return true;
 308                }
 309
 21310                WsdlNS.SoapAddressBinding dest = version == EnvelopeVersion.Soap12 ? new WsdlNS.Soap12AddressBinding() :
 21311                if (binding != null)
 312                {
 21313                    dest.Required = binding.Required;
 21314                    dest.Location = binding.Location;
 315                }
 316
 21317                src = dest;
 21318                return true;
 319            }
 320
 321
 322            //    // returns true if src is an expected type; updates src in place; should handle null
 323            internal static bool ConvertSoapOperationBinding(ref object src, EnvelopeVersion version)
 324            {
 159325                WsdlNS.SoapOperationBinding binding = src as WsdlNS.SoapOperationBinding;
 326
 159327                if (src != null)
 328                {
 0329                    if (binding == null)
 330                    {
 0331                        return false; // no match
 332                    }
 0333                    else if (GetBindingVersion<WsdlNS.Soap12OperationBinding>(src) == version)
 334                    {
 0335                        return true; // matched but same version
 336                    }
 337                }
 338
 159339                if (version == EnvelopeVersion.None)
 340                {
 0341                    src = null;
 0342                    return true;
 343                }
 344
 159345                WsdlNS.SoapOperationBinding dest = version == EnvelopeVersion.Soap12 ? new WsdlNS.Soap12OperationBinding
 159346                if (src != null)
 347                {
 0348                    dest.Required = binding.Required;
 0349                    dest.Style = binding.Style;
 0350                    dest.SoapAction = binding.SoapAction;
 351                }
 352
 159353                src = dest;
 159354                return true;
 355            }
 356
 357            internal static bool ConvertSoapMessageBinding(ref object src, EnvelopeVersion version)
 358            {
 318359                WsdlNS.SoapBodyBinding body = src as WsdlNS.SoapBodyBinding;
 318360                if (body != null)
 361                {
 0362                    src = ConvertSoapBodyBinding(body, version);
 0363                    return true;
 364                }
 365
 318366                WsdlNS.SoapHeaderBinding header = src as WsdlNS.SoapHeaderBinding;
 318367                if (header != null)
 368                {
 0369                    src = ConvertSoapHeaderBinding(header, version);
 0370                    return true;
 371                }
 372
 318373                WsdlNS.SoapFaultBinding fault = src as WsdlNS.SoapFaultBinding;
 318374                if (fault != null)
 375                {
 0376                    src = ConvertSoapFaultBinding(fault, version);
 0377                    return true;
 378                }
 379
 318380                XmlElement element = src as XmlElement;
 318381                if (element != null)
 382                {
 0383                    if (IsSoapFaultBinding(element))
 384                    {
 0385                        src = ConvertSoapFaultBinding(element, version);
 0386                        return true;
 387                    }
 388                }
 389
 318390                return src == null; // "match" only if nothing passed in
 391            }
 392
 393            private static WsdlNS.SoapBodyBinding ConvertSoapBodyBinding(WsdlNS.SoapBodyBinding src, EnvelopeVersion ver
 394            {
 0395                if (version == EnvelopeVersion.None)
 396                {
 0397                    return null;
 398                }
 399
 0400                EnvelopeVersion srcVersion = GetBindingVersion<WsdlNS.Soap12BodyBinding>(src);
 0401                if (srcVersion == version)
 402                {
 0403                    return src;
 404                }
 405
 0406                WsdlNS.SoapBodyBinding dest = version == EnvelopeVersion.Soap12 ? new WsdlNS.Soap12BodyBinding() : new W
 0407                if (src != null)
 408                {
 0409                    if (XmlSerializerOperationFormatter.GetEncoding(srcVersion) == src.Encoding)
 410                    {
 0411                        dest.Encoding = XmlSerializerOperationFormatter.GetEncoding(version);
 412                    }
 413
 0414                    dest.Encoding = XmlSerializerOperationFormatter.GetEncoding(version);
 0415                    dest.Namespace = src.Namespace;
 0416                    dest.Parts = src.Parts;
 0417                    dest.PartsString = src.PartsString;
 0418                    dest.Use = src.Use;
 0419                    dest.Required = src.Required;
 420                }
 421
 0422                return dest;
 423            }
 424
 425            private static XmlElement ConvertSoapFaultBinding(XmlElement src, EnvelopeVersion version)
 426            {
 0427                if (src == null)
 428                {
 0429                    return null;
 430                }
 431
 0432                if (version == EnvelopeVersion.Soap12)
 433                {
 0434                    if (src.NamespaceURI == WsdlNS.Soap12Binding.Namespace)
 435                    {
 0436                        return src;
 437                    }
 438                }
 0439                else if (version == EnvelopeVersion.Soap11)
 440                {
 0441                    if (src.NamespaceURI == WsdlNS.SoapBinding.Namespace)
 442                    {
 0443                        return src;
 444                    }
 445                }
 446                else
 447                {
 0448                    return null;
 449                }
 450
 0451                XmlElement dest = CreateSoapFaultBinding(version);
 0452                if (src.HasAttributes)
 453                {
 0454                    foreach (XmlAttribute attribute in src.Attributes)
 455                    {
 0456                        dest.SetAttribute(attribute.Name, attribute.Value);
 457                    }
 458                }
 459
 0460                return dest;
 461            }
 462
 463            private static WsdlNS.SoapFaultBinding ConvertSoapFaultBinding(WsdlNS.SoapFaultBinding src, EnvelopeVersion 
 464            {
 0465                if (version == EnvelopeVersion.None)
 466                {
 0467                    return null;
 468                }
 469
 0470                if (GetBindingVersion<WsdlNS.Soap12FaultBinding>(src) == version)
 471                {
 0472                    return src;
 473                }
 474
 0475                WsdlNS.SoapFaultBinding dest = version == EnvelopeVersion.Soap12 ? new WsdlNS.Soap12FaultBinding() : new
 0476                if (src != null)
 477                {
 0478                    dest.Encoding = src.Encoding;
 0479                    dest.Name = src.Name;
 0480                    dest.Namespace = src.Namespace;
 0481                    dest.Use = src.Use;
 0482                    dest.Required = src.Required;
 483                }
 484
 0485                return dest;
 486            }
 487
 488            private static WsdlNS.SoapHeaderBinding ConvertSoapHeaderBinding(WsdlNS.SoapHeaderBinding src, EnvelopeVersi
 489            {
 0490                if (version == EnvelopeVersion.None)
 491                {
 0492                    return null;
 493                }
 494
 0495                if (GetBindingVersion<WsdlNS.Soap12HeaderBinding>(src) == version)
 496                {
 0497                    return src;
 498                }
 499
 0500                WsdlNS.SoapHeaderBinding dest = version == EnvelopeVersion.Soap12 ? new WsdlNS.Soap12HeaderBinding() : n
 0501                if (src != null)
 502                {
 0503                    dest.Fault = src.Fault;
 0504                    dest.MapToProperty = src.MapToProperty;
 0505                    dest.Message = src.Message;
 0506                    dest.Part = src.Part;
 0507                    dest.Encoding = src.Encoding;
 0508                    dest.Namespace = src.Namespace;
 0509                    dest.Use = src.Use;
 0510                    dest.Required = src.Required;
 511                }
 512
 0513                return dest;
 514            }
 515
 516            internal static EnvelopeVersion GetBindingVersion<T12>(object src)
 517            {
 32518                return src is T12 ? EnvelopeVersion.Soap12 : EnvelopeVersion.Soap11;
 519            }
 520        }
 521
 522        private static WsdlNS.SoapAddressBinding CreateSoapAddressBinding(EnvelopeVersion version, WsdlNS.Port wsdlPort)
 523        {
 32524            WsdlNS.SoapAddressBinding soapAddressBinding = null;
 525
 32526            if (version == EnvelopeVersion.Soap12)
 527            {
 32528                soapAddressBinding = new WsdlNS.Soap12AddressBinding();
 529            }
 0530            else if (version == EnvelopeVersion.Soap11)
 531            {
 0532                soapAddressBinding = new WsdlNS.SoapAddressBinding();
 533            }
 534
 535            Fx.Assert(soapAddressBinding != null, "EnvelopeVersion is not recognized. Please update the SoapHelper class
 536
 32537            wsdlPort.Extensions.Add(soapAddressBinding);
 32538            return soapAddressBinding;
 539        }
 540
 541        internal static WsdlNS.SoapBinding CreateSoapBinding(EnvelopeVersion version, WsdlNS.Binding wsdlBinding)
 542        {
 0543            WsdlNS.SoapBinding soapBinding = null;
 544
 0545            if (version == EnvelopeVersion.Soap12)
 546            {
 0547                soapBinding = new WsdlNS.Soap12Binding();
 548            }
 0549            else if (version == EnvelopeVersion.Soap11)
 550            {
 0551                soapBinding = new WsdlNS.SoapBinding();
 552            }
 553
 554            Fx.Assert(soapBinding != null, "EnvelopeVersion is not recognized. Please update the SoapHelper class");
 555
 0556            wsdlBinding.Extensions.Add(soapBinding);
 0557            return soapBinding;
 558        }
 559
 560        private static WsdlNS.SoapOperationBinding CreateSoapOperationBinding(EnvelopeVersion version, WsdlNS.OperationB
 561        {
 0562            WsdlNS.SoapOperationBinding soapOperationBinding = null;
 563
 0564            if (version == EnvelopeVersion.Soap12)
 565            {
 0566                soapOperationBinding = new WsdlNS.Soap12OperationBinding();
 567            }
 0568            else if (version == EnvelopeVersion.Soap11)
 569            {
 0570                soapOperationBinding = new WsdlNS.SoapOperationBinding();
 571            }
 572
 573            Fx.Assert(soapOperationBinding != null, "EnvelopeVersion is not recognized. Please update the SoapHelper cla
 574
 0575            wsdlOperationBinding.Extensions.Add(soapOperationBinding);
 0576            return soapOperationBinding;
 577        }
 578
 579        private static WsdlNS.SoapBodyBinding CreateSoapBodyBinding(EnvelopeVersion version, WsdlNS.MessageBinding wsdlM
 580        {
 318581            WsdlNS.SoapBodyBinding soapBodyBinding = null;
 582
 318583            if (version == EnvelopeVersion.Soap12)
 584            {
 110585                soapBodyBinding = new WsdlNS.Soap12BodyBinding();
 586            }
 208587            else if (version == EnvelopeVersion.Soap11)
 588            {
 208589                soapBodyBinding = new WsdlNS.SoapBodyBinding();
 590            }
 591
 592            Fx.Assert(soapBodyBinding != null, "EnvelopeVersion is not recognized. Please update the SoapHelper class");
 593
 318594            wsdlMessageBinding.Extensions.Add(soapBodyBinding);
 318595            return soapBodyBinding;
 596        }
 597
 598        private static WsdlNS.SoapHeaderBinding CreateSoapHeaderBinding(EnvelopeVersion version, WsdlNS.MessageBinding w
 599        {
 0600            WsdlNS.SoapHeaderBinding soapHeaderBinding = null;
 601
 0602            if (version == EnvelopeVersion.Soap12)
 603            {
 0604                soapHeaderBinding = new WsdlNS.Soap12HeaderBinding();
 605            }
 0606            else if (version == EnvelopeVersion.Soap11)
 607            {
 0608                soapHeaderBinding = new WsdlNS.SoapHeaderBinding();
 609            }
 610
 611            Fx.Assert(soapHeaderBinding != null, "EnvelopeVersion is not recognized. Please update the SoapHelper class"
 612
 0613            wsdlMessageBinding.Extensions.Add(soapHeaderBinding);
 0614            return soapHeaderBinding;
 615        }
 616
 617        private static XmlElement CreateSoapFaultBinding(EnvelopeVersion version)
 618        {
 0619            string prefix = null;
 0620            string ns = null;
 0621            if (version == EnvelopeVersion.Soap12)
 622            {
 0623                ns = WsdlNS.Soap12Binding.Namespace;
 0624                prefix = "soap12";
 625            }
 0626            else if (version == EnvelopeVersion.Soap11)
 627            {
 0628                ns = WsdlNS.SoapBinding.Namespace;
 0629                prefix = "soap";
 630            }
 631
 632            Fx.Assert(ns != null, "EnvelopeVersion is not recognized. Please update the SoapHelper class");
 0633            return Document.CreateElement(prefix, "fault", ns);
 634        }
 635
 636        public static WsdlNS.SoapAddressBinding GetSoapAddressBinding(WsdlNS.Port wsdlPort)
 637        {
 64638            foreach (object o in wsdlPort.Extensions)
 639            {
 0640                if (o is WsdlNS.SoapAddressBinding binding)
 641                {
 0642                    return binding;
 643                }
 644            }
 645
 32646            return null;
 0647        }
 648
 649        internal static WsdlNS.SoapBinding GetSoapBinding(WsdlEndpointConversionContext endpointContext)
 650        {
 124651            foreach (object o in endpointContext.WsdlBinding.Extensions)
 652            {
 46653                if (o is WsdlNS.SoapBinding binding)
 654                {
 32655                    return binding;
 656                }
 657            }
 658
 0659            return null;
 32660        }
 661
 662        private static WsdlNS.SoapOperationBinding GetSoapOperationBinding(WsdlEndpointConversionContext endpointContext
 663        {
 159664            WsdlNS.OperationBinding wsdlOperationBinding = endpointContext.GetOperationBinding(operation);
 665
 477666            foreach (object o in wsdlOperationBinding.Extensions)
 667            {
 159668                if (o is WsdlNS.SoapOperationBinding binding)
 669                {
 159670                    return binding;
 671                }
 672            }
 673
 0674            return null;
 159675        }
 676
 677        private static WsdlNS.SoapBodyBinding GetSoapBodyBinding(WsdlEndpointConversionContext endpointContext, WsdlNS.M
 678        {
 636679            foreach (object o in wsdlMessageBinding.Extensions)
 680            {
 0681                if (o is WsdlNS.SoapBodyBinding binding)
 682                {
 0683                    return binding;
 684                }
 685            }
 686
 318687            return null;
 0688        }
 689
 690        internal static bool IsSoapFaultBinding(XmlElement element)
 691        {
 0692            return element != null && element.LocalName == "fault" && (element.NamespaceURI == WsdlNS.Soap12Binding.Name
 693        }
 694    }
 695}

Methods/Properties

.cctor()
Document()
CreateLocalAttribute(System.String,System.String)
GetOrCreateSoapAddressBinding(System.Web.Services.Description.Binding,System.Web.Services.Description.Port,CoreWCF.Description.WsdlExporter)
GetOrCreateSoapBinding(CoreWCF.Description.WsdlEndpointConversionContext,CoreWCF.Description.WsdlExporter)
GetOrCreateSoapOperationBinding(CoreWCF.Description.WsdlEndpointConversionContext,CoreWCF.Description.OperationDescription,CoreWCF.Description.WsdlExporter)
GetOrCreateSoapBodyBinding(CoreWCF.Description.WsdlEndpointConversionContext,System.Web.Services.Description.MessageBinding,CoreWCF.Description.WsdlExporter)
CreateSoapHeaderBinding(CoreWCF.Description.WsdlEndpointConversionContext,System.Web.Services.Description.MessageBinding)
CreateSoapFaultBinding(System.String,CoreWCF.Description.WsdlEndpointConversionContext,System.Web.Services.Description.FaultBinding,System.Boolean)
SetSoapVersion(CoreWCF.Description.WsdlEndpointConversionContext,CoreWCF.Description.WsdlExporter,CoreWCF.EnvelopeVersion)
GetSoapVersion(System.Web.Services.Description.Binding)
SetSoapVersionState(System.Web.Services.Description.Binding,CoreWCF.Description.WsdlExporter,CoreWCF.EnvelopeVersion)
GetSoapVersionState(System.Web.Services.Description.Binding,CoreWCF.Description.WsdlExporter)
ConvertExtensions(System.Web.Services.Description.ServiceDescriptionFormatExtensionCollection,CoreWCF.EnvelopeVersion,CoreWCF.Description.SoapHelper/SoapConverter/ConvertExtension)
ConvertSoapBinding(System.Object&,CoreWCF.EnvelopeVersion)
ConvertSoapAddressBinding(System.Object&,CoreWCF.EnvelopeVersion)
ConvertSoapOperationBinding(System.Object&,CoreWCF.EnvelopeVersion)
ConvertSoapMessageBinding(System.Object&,CoreWCF.EnvelopeVersion)
ConvertSoapBodyBinding(System.Web.Services.Description.SoapBodyBinding,CoreWCF.EnvelopeVersion)
ConvertSoapFaultBinding(System.Xml.XmlElement,CoreWCF.EnvelopeVersion)
ConvertSoapFaultBinding(System.Web.Services.Description.SoapFaultBinding,CoreWCF.EnvelopeVersion)
ConvertSoapHeaderBinding(System.Web.Services.Description.SoapHeaderBinding,CoreWCF.EnvelopeVersion)
GetBindingVersion(System.Object)
CreateSoapAddressBinding(CoreWCF.EnvelopeVersion,System.Web.Services.Description.Port)
CreateSoapBinding(CoreWCF.EnvelopeVersion,System.Web.Services.Description.Binding)
CreateSoapOperationBinding(CoreWCF.EnvelopeVersion,System.Web.Services.Description.OperationBinding)
CreateSoapBodyBinding(CoreWCF.EnvelopeVersion,System.Web.Services.Description.MessageBinding)
CreateSoapHeaderBinding(CoreWCF.EnvelopeVersion,System.Web.Services.Description.MessageBinding)
CreateSoapFaultBinding(CoreWCF.EnvelopeVersion)
GetSoapAddressBinding(System.Web.Services.Description.Port)
GetSoapBinding(CoreWCF.Description.WsdlEndpointConversionContext)
GetSoapOperationBinding(CoreWCF.Description.WsdlEndpointConversionContext,CoreWCF.Description.OperationDescription)
GetSoapBodyBinding(CoreWCF.Description.WsdlEndpointConversionContext,System.Web.Services.Description.MessageBinding)
IsSoapFaultBinding(System.Xml.XmlElement)