Ejemplo n.º 1
0
        public SoapServerMethod(Type serverType, LogicalMethodInfo methodInfo)
        {
            this.methodInfo = methodInfo;

            //
            // Set up the XmlImporter, the SoapImporter, and acquire
            // the ServiceAttribute on the serverType for use in
            // creating a SoapReflectedMethod.
            //
            WebServiceAttribute serviceAttribute = WebServiceReflector.GetAttribute(serverType);
            string serviceNamespace        = serviceAttribute.Namespace;
            bool   serviceDefaultIsEncoded = SoapReflector.ServiceDefaultIsEncoded(serverType);

            SoapReflectionImporter soapImporter = SoapReflector.CreateSoapImporter(serviceNamespace, serviceDefaultIsEncoded);
            XmlReflectionImporter  xmlImporter  = SoapReflector.CreateXmlImporter(serviceNamespace, serviceDefaultIsEncoded);

            //
            // Add some types relating to the methodInfo into the two importers
            //
            SoapReflector.IncludeTypes(methodInfo, soapImporter);
            WebMethodReflector.IncludeTypes(methodInfo, xmlImporter);

            //
            // Create a SoapReflectedMethod by reflecting on the
            // LogicalMethodInfo passed to us.
            //
            SoapReflectedMethod soapMethod = SoapReflector.ReflectMethod(methodInfo, false, xmlImporter, soapImporter, serviceNamespace);

            //
            // Most of the fields in this class are ----ed in from the reflected information
            //
            ImportReflectedMethod(soapMethod);
            ImportSerializers(soapMethod, GetServerTypeEvidence(serverType));
            ImportHeaderSerializers(soapMethod);
        }
Ejemplo n.º 2
0
        public void TestConstructors()
        {
            WebServiceAttribute attribute;

            attribute = new WebServiceAttribute();
            Assert.AreEqual(String.Empty, attribute.Description);
            Assert.AreEqual(String.Empty, attribute.Name);
            Assert.AreEqual("http://tempuri.org/", attribute.Namespace);
        }
Ejemplo n.º 3
0
        /// <include file='doc\ServiceDescriptionReflector.uex' path='docs/doc[@for="ServiceDescriptionReflector.Reflect"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public void Reflect(Type type, string url)
        {
            serviceType = type;
            serviceUrl  = url;

            serviceAttr = WebServiceReflector.GetAttribute(type);

            methods = WebMethodReflector.GetMethods(type);
            CheckForDuplicateMethods(methods);

            descriptionsWithPost = descriptions;
            schemasWithPost      = schemas;

            if (reflectorsWithPost != null)
            {
                ReflectInternal(reflectorsWithPost);

                descriptions = new ServiceDescriptionCollection();
                schemas      = new XmlSchemas();
            }

            ReflectInternal(reflectors);

            if (serviceAttr.Description != null && serviceAttr.Description.Length > 0)
            {
                ServiceDescription.Documentation = serviceAttr.Description;
            }

            // need to preprocess all exported schemas to make sure that IXmlSerializable schemas are Merged and the resulting set is valid
            ServiceDescription.Types.Schemas.Compile(null, false);

            if (ServiceDescriptions.Count > 1)
            {
                // if defining interfaces, we move all schemas to the external collection
                // since the types therein may be referenced from any of the sdls
                Schemas.Add(ServiceDescription.Types.Schemas);
                ServiceDescription.Types.Schemas.Clear();
            }
            else if (ServiceDescription.Types.Schemas.Count > 0)
            {
                XmlSchema[] descriptionSchemas = new XmlSchema[ServiceDescription.Types.Schemas.Count];
                ServiceDescription.Types.Schemas.CopyTo(descriptionSchemas, 0);
                foreach (XmlSchema schema in descriptionSchemas)
                {
                    // we always move dataset schemas to the external schema's collection.
                    if (XmlSchemas.IsDataSet(schema))
                    {
                        ServiceDescription.Types.Schemas.Remove(schema);
                        Schemas.Add(schema);
                    }
                }
            }
        }
        public void CreatesWebServiceAttributeWithNoDecoratedClassAndMinimalConfig()
        {
            wse.ObjectName = "CreatesWebServiceAttributeWithNoDecoratedClassAndMinimalConfig";
            wse.TargetName = "noDecoratedService";
            wse.AfterPropertiesSet();

            Type proxyType = wse.GetExportedType();
            object[] attrs = proxyType.GetCustomAttributes(typeof(WebServiceAttribute), true);
            Assert.IsNotEmpty(attrs);
            Assert.AreEqual(1, attrs.Length);

            WebServiceAttribute wsa = attrs[0] as WebServiceAttribute;
            Assert.AreEqual("CreatesWebServiceAttributeWithNoDecoratedClassAndMinimalConfig", wsa.Name);
            Assert.AreEqual(string.Empty, wsa.Description);
            Assert.AreEqual(WebServiceAttribute.DefaultNamespace, wsa.Namespace);
        }
        public void OverridesExistingWebServiceAttributeWithDecoratedClass()
        {
            wse.ObjectName = "OverridesExistingWebServiceAttributeWithDecoratedClass";
            wse.TargetName = "decoratedService";
            wse.AfterPropertiesSet();

            Type proxyType = wse.GetExportedType();
            object[] attrs = proxyType.GetCustomAttributes(typeof(WebServiceAttribute), true);
            Assert.IsNotEmpty(attrs);
            Assert.AreEqual(1, attrs.Length);

            WebServiceAttribute wsa = attrs[0] as WebServiceAttribute;
            Assert.AreEqual("OverridesExistingWebServiceAttributeWithDecoratedClass", wsa.Name);
            Assert.AreEqual(string.Empty, wsa.Description);
            Assert.AreEqual(WebServiceAttribute.DefaultNamespace, wsa.Namespace);
        }
        public void AppliesCustomAttributeBuilderToType()
        {
            wse.ObjectName = "AppliesCustomAttributeBuilderToType";
            wse.TargetName = "noDecoratedService";
            wse.TypeAttributes = new CustomAttributeBuilder[] { 
                new CustomAttributeBuilder(typeof(WebServiceAttribute).GetConstructor(Type.EmptyTypes), ObjectUtils.EmptyObjects) };
            wse.AfterPropertiesSet();

            Type proxyType = wse.GetExportedType();

            object[] attrs = proxyType.GetCustomAttributes(typeof(WebServiceAttribute), true);
            Assert.IsNotEmpty(attrs);
            Assert.AreEqual(1, attrs.Length);

            WebServiceAttribute wsa = attrs[0] as WebServiceAttribute;
            Assert.AreEqual("AppliesCustomAttributeBuilderToType", wsa.Name);
        }
        public void CreatesWebServiceAttributeWithNoDecoratedClassAndFullConfig()
        {
            wse.ObjectName = "CreatesWebServiceAttributeWithNoDecoratedClassAndFullConfig";
            wse.TargetName = "noDecoratedService";
            wse.Name = "My web service name";
            wse.Description = "My web service description";
            wse.Namespace = "http://www.springframework.net";
            wse.AfterPropertiesSet();

            Type proxyType = wse.GetExportedType();
            object[] attrs = proxyType.GetCustomAttributes(typeof(WebServiceAttribute), true);
            Assert.IsNotEmpty(attrs);
            Assert.AreEqual(1, attrs.Length);

            WebServiceAttribute wsa = attrs[0] as WebServiceAttribute;
            Assert.AreEqual(wse.Name, wsa.Name);
            Assert.AreEqual(wse.Description, wsa.Description);
            Assert.AreEqual(wse.Namespace, wsa.Namespace);
        }
Ejemplo n.º 8
0
        public void ProxyWebServiceAttribute()
        {
            IProxyTypeBuilder builder = GetProxyBuilder();

            builder.TargetType = typeof(ClassWithWebServiceAttribute);

            Type proxy = builder.BuildProxyType();

            Assert.IsNotNull(proxy, "The proxy generated by a (valid) call to BuildProxy() was null.");

            object[] attrs = proxy.GetCustomAttributes(false);
            Assert.IsNotNull(attrs, "Should have had 1 attribute applied to the target type.");
            Assert.AreEqual(1, attrs.Length, "Should have had 1 attribute applied to the target type.");
            Assert.AreEqual(typeof(WebServiceAttribute), attrs[0].GetType(), "Wrong System.Type of Attribute applied to the target type.");

            WebServiceAttribute wsa = attrs[0] as WebServiceAttribute;

            Assert.AreEqual("blah", wsa.Name);
            Assert.AreEqual("http://mynamespace.com", wsa.Namespace);
        }
        public void TestHeaderGeneration()
        {
            ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.ServiceContractDsl.Tests.xml");

            Service rootElement = CreateDefaultService();

            rootElement.Namespace = ServiceNamespace;
            AsmxService extender = new AsmxService();

            extender.ModelElement      = rootElement;
            rootElement.ObjectExtender = extender;
            string content = RunTemplate(rootElement);

            Type generatedType = CompileAndGetType(content);

            Assert.AreEqual <Type>(typeof(System.Web.Services.WebService), generatedType.BaseType.BaseType);
            WebServiceAttribute serviceBehavior = TypeAsserter.AssertAttribute <WebServiceAttribute>(generatedType);

            Assert.AreEqual <string>(ServiceName, serviceBehavior.Name);
            Assert.AreEqual <string>(ServiceNamespace, serviceBehavior.Namespace);
        }
Ejemplo n.º 10
0
 public void Reflect(Type type, string url)
 {
     this.serviceType = type;
     this.serviceUrl  = url;
     this.serviceAttr = WebServiceReflector.GetAttribute(type);
     this.methods     = WebMethodReflector.GetMethods(type);
     this.CheckForDuplicateMethods(this.methods);
     this.descriptionsWithPost = this.descriptions;
     this.schemasWithPost      = this.schemas;
     if (this.reflectorsWithPost != null)
     {
         this.ReflectInternal(this.reflectorsWithPost);
         this.descriptions = new ServiceDescriptionCollection();
         this.schemas      = new XmlSchemas();
     }
     this.ReflectInternal(this.reflectors);
     if ((this.serviceAttr.Description != null) && (this.serviceAttr.Description.Length > 0))
     {
         this.ServiceDescription.Documentation = this.serviceAttr.Description;
     }
     this.ServiceDescription.Types.Schemas.Compile(null, false);
     if (this.ServiceDescriptions.Count > 1)
     {
         this.Schemas.Add(this.ServiceDescription.Types.Schemas);
         this.ServiceDescription.Types.Schemas.Clear();
     }
     else if (this.ServiceDescription.Types.Schemas.Count > 0)
     {
         XmlSchema[] array = new XmlSchema[this.ServiceDescription.Types.Schemas.Count];
         this.ServiceDescription.Types.Schemas.CopyTo(array, 0);
         foreach (XmlSchema schema in array)
         {
             if (XmlSchemas.IsDataSet(schema))
             {
                 this.ServiceDescription.Types.Schemas.Remove(schema);
                 this.Schemas.Add(schema);
             }
         }
     }
 }
Ejemplo n.º 11
0
        /// <include file='doc\ServiceDescriptionReflector.uex' path='docs/doc[@for="ServiceDescriptionReflector.Reflect"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public void Reflect(Type type, string url)
        {
            serviceType = type;
            serviceUrl  = url;

            serviceAttr = WebServiceReflector.GetAttribute(type);

            methods = WebMethodReflector.GetMethods(type);
            CheckForDuplicateMethods(methods);

            descriptionsWithPost = descriptions;
            schemasWithPost      = schemas;

            if (reflectorsWithPost != null)
            {
                ReflectInternal(reflectorsWithPost);

                descriptions = new ServiceDescriptionCollection();
                schemas      = new XmlSchemas();
            }

            ReflectInternal(reflectors);

            XmlSchema[] descriptionSchemas = new XmlSchema[ServiceDescription.Types.Schemas.Count];
            ServiceDescription.Types.Schemas.CopyTo(descriptionSchemas, 0);
            // if defining interfaces, we move all schemas to the external collection
            // since the types therein may be referenced from any of the sdls
            bool externalizeSchemas = ServiceDescriptions.Count > 1;

            foreach (XmlSchema schema in descriptionSchemas)
            {
                // we always move dataset schemas to the external schema's collection.
                if (externalizeSchemas || XmlSchemas.IsDataSet(schema))
                {
                    ServiceDescription.Types.Schemas.Remove(schema);
                    Schemas.Add(schema);
                }
            }
        }
Ejemplo n.º 12
0
        internal static object[] GetInitializers(LogicalMethodInfo[] methodInfos)
        {
            if (methodInfos.Length == 0)
            {
                return(new object[0]);
            }
            WebServiceAttribute serviceAttribute = WebServiceReflector.GetAttribute(methodInfos);
            bool serviceDefaultIsEncoded         = SoapReflector.ServiceDefaultIsEncoded(WebServiceReflector.GetMostDerivedType(methodInfos));
            XmlReflectionImporter importer       = SoapReflector.CreateXmlImporter(serviceAttribute.Namespace, serviceDefaultIsEncoded);

            WebMethodReflector.IncludeTypes(methodInfos, importer);
            ArrayList mappings = new ArrayList();

            for (int i = 0; i < methodInfos.Length; i++)
            {
                LogicalMethodInfo methodInfo = methodInfos[i];
                Type type = methodInfo.ReturnType;
                if (IsSupported(type))
                {
                    XmlAttributes  a       = new XmlAttributes(methodInfo.ReturnTypeCustomAttributeProvider);
                    XmlTypeMapping mapping = importer.ImportTypeMapping(type, a.XmlRoot);
                    mappings.Add(mapping);
                }
            }
            XmlSerializer[] serializers  = XmlSerializer.FromMappings((XmlMapping[])mappings.ToArray(typeof(XmlMapping)));
            object[]        initializers = new object[methodInfos.Length];
            int             count        = 0;

            for (int i = 0; i < initializers.Length; i++)
            {
                if (IsSupported(methodInfos[i].ReturnType))
                {
                    initializers[i] = serializers[count++];
                }
            }
            return(initializers);
        }
Ejemplo n.º 13
0
        public LogicalTypeInfo(Type t)
        {
            this.Type = t;

            object [] o = Type.GetCustomAttributes(typeof(WebServiceAttribute), false);
            if (o.Length == 1)
            {
                WebServiceAttribute a = (WebServiceAttribute)o [0];
                WebServiceName      = (a.Name != string.Empty) ? a.Name : Type.Name;
                WebServiceNamespace = (a.Namespace != string.Empty) ? a.Namespace : WebServiceAttribute.DefaultNamespace;
                Description         = a.Description;
            }
            else
            {
                WebServiceName      = Type.Name;
                WebServiceNamespace = WebServiceAttribute.DefaultNamespace;
            }

            // Determine the namespaces for literal and encoded schema types

            bindingUse = SoapBindingUse.Literal;

            o = t.GetCustomAttributes(typeof(SoapDocumentServiceAttribute), true);
            if (o.Length > 0)
            {
                SoapDocumentServiceAttribute at = (SoapDocumentServiceAttribute)o[0];
                bindingUse = at.Use;
                if (bindingUse == SoapBindingUse.Default)
                {
                    bindingUse = SoapBindingUse.Literal;
                }
                routingStyle = at.RoutingStyle;
            }
            else if (t.GetCustomAttributes(typeof(SoapRpcServiceAttribute), true).Length > 0)
            {
                o = t.GetCustomAttributes(typeof(SoapRpcServiceAttribute), true);
                SoapRpcServiceAttribute at = (SoapRpcServiceAttribute)o[0];
#if NET_2_0
                bindingUse = at.Use;
#else
                bindingUse = SoapBindingUse.Encoded;
#endif
                routingStyle = at.RoutingStyle;
                if (bindingUse == SoapBindingUse.Default)
                {
                    bindingUse = SoapBindingUse.Encoded;
                }
            }
            else
            {
                routingStyle = SoapServiceRoutingStyle.SoapAction;
            }
            string sep = WebServiceNamespace.EndsWith("/") ? "" : "/";

            WebServiceAbstractNamespace = WebServiceNamespace + sep + "AbstractTypes";
#if NET_2_0
            MethodInfo [] type_methods;
            if (typeof(WebClientProtocol).IsAssignableFrom(Type))
            {
                type_methods = Type.GetMethods(BindingFlags.Instance | BindingFlags.Public);
            }
            else
            {
                MethodInfo [] all_type_methods = Type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                ArrayList     list             = new ArrayList(all_type_methods.Length);
                foreach (MethodInfo mi in all_type_methods)
                {
                    if (mi.IsPublic && mi.GetCustomAttributes(typeof(WebMethodAttribute), false).Length > 0)
                    {
                        list.Add(mi);
                    }
                    else
                    {
                        foreach (Type ifaceType in Type.GetInterfaces())
                        {
                            if (ifaceType.GetCustomAttributes(typeof(WebServiceBindingAttribute), false).Length > 0)
                            {
                                MethodInfo found = FindInInterface(ifaceType, mi);
                                if (found != null)
                                {
                                    if (found.GetCustomAttributes(typeof(WebMethodAttribute), false).Length > 0)
                                    {
                                        list.Add(found);
                                    }

                                    break;
                                }
                            }
                        }
                    }
                }
                type_methods = (MethodInfo [])list.ToArray(typeof(MethodInfo));
            }
#else
            MethodInfo [] type_methods = Type.GetMethods(BindingFlags.Instance | BindingFlags.Public);
#endif
            logicalMethods = LogicalMethodInfo.Create(type_methods, LogicalMethodTypes.Sync);
        }
        internal static object[] GetInitializers(LogicalMethodInfo[] methodInfos)
        {
            if (methodInfos.Length == 0)
            {
                return(new object[0]);
            }
            WebServiceAttribute serviceAttribute = WebServiceReflector.GetAttribute(methodInfos);
            bool serviceDefaultIsEncoded         = SoapReflector.ServiceDefaultIsEncoded(WebServiceReflector.GetMostDerivedType(methodInfos));
            XmlReflectionImporter importer       = SoapReflector.CreateXmlImporter(serviceAttribute.Namespace, serviceDefaultIsEncoded);

            WebMethodReflector.IncludeTypes(methodInfos, importer);
            ArrayList mappings = new ArrayList();

            bool[] supported = new bool[methodInfos.Length];
            for (int i = 0; i < methodInfos.Length; i++)
            {
                LogicalMethodInfo methodInfo = methodInfos[i];
                Type type = methodInfo.ReturnType;
                if (IsSupported(type) && HttpServerProtocol.AreUrlParametersSupported(methodInfo))
                {
                    XmlAttributes  a       = new XmlAttributes(methodInfo.ReturnTypeCustomAttributeProvider);
                    XmlTypeMapping mapping = importer.ImportTypeMapping(type, a.XmlRoot);
                    mapping.SetKey(methodInfo.GetKey() + ":Return");
                    mappings.Add(mapping);
                    supported[i] = true;
                }
            }
            if (mappings.Count == 0)
            {
                return(new object[0]);
            }

            XmlMapping[] xmlMappings = (XmlMapping[])mappings.ToArray(typeof(XmlMapping));
            Evidence     evidence    = GetEvidenceForType(methodInfos[0].DeclaringType);

            TraceMethod caller = Tracing.On ? new TraceMethod(typeof(XmlReturn), "GetInitializers", methodInfos) : null;

            if (Tracing.On)
            {
                Tracing.Enter(Tracing.TraceId(Res.TraceCreateSerializer), caller, new TraceMethod(typeof(XmlSerializer), "FromMappings", xmlMappings, evidence));
            }
            XmlSerializer[] serializers = null;
            if (AppDomain.CurrentDomain.IsHomogenous)
            {
                serializers = XmlSerializer.FromMappings(xmlMappings);
            }
            else
            {
#pragma warning disable 618 // If we're in a non-homogenous domain, legacy CAS mode is enabled, so passing through evidence will not fail
                serializers = XmlSerializer.FromMappings(xmlMappings, evidence);
#pragma warning restore 618
            }

            if (Tracing.On)
            {
                Tracing.Exit(Tracing.TraceId(Res.TraceCreateSerializer), caller);
            }

            object[] initializers = new object[methodInfos.Length];
            int      count        = 0;
            for (int i = 0; i < initializers.Length; i++)
            {
                if (supported[i])
                {
                    initializers[i] = serializers[count++];
                }
            }
            return(initializers);
        }
Ejemplo n.º 15
0
        internal static object[] GetInitializers(LogicalMethodInfo[] methodInfos)
        {
            if (methodInfos.Length == 0)
            {
                return(new object[0]);
            }
            WebServiceAttribute attribute  = WebServiceReflector.GetAttribute(methodInfos);
            bool serviceDefaultIsEncoded   = SoapReflector.ServiceDefaultIsEncoded(WebServiceReflector.GetMostDerivedType(methodInfos));
            XmlReflectionImporter importer = SoapReflector.CreateXmlImporter(attribute.Namespace, serviceDefaultIsEncoded);

            WebMethodReflector.IncludeTypes(methodInfos, importer);
            ArrayList list = new ArrayList();

            bool[] flagArray = new bool[methodInfos.Length];
            for (int i = 0; i < methodInfos.Length; i++)
            {
                LogicalMethodInfo methodInfo = methodInfos[i];
                Type returnType = methodInfo.ReturnType;
                if (IsSupported(returnType) && HttpServerProtocol.AreUrlParametersSupported(methodInfo))
                {
                    XmlAttributes  attributes = new XmlAttributes(methodInfo.ReturnTypeCustomAttributeProvider);
                    XmlTypeMapping mapping    = importer.ImportTypeMapping(returnType, attributes.XmlRoot);
                    mapping.SetKey(methodInfo.GetKey() + ":Return");
                    list.Add(mapping);
                    flagArray[i] = true;
                }
            }
            if (list.Count == 0)
            {
                return(new object[0]);
            }
            XmlMapping[] mappings        = (XmlMapping[])list.ToArray(typeof(XmlMapping));
            Evidence     evidenceForType = GetEvidenceForType(methodInfos[0].DeclaringType);
            TraceMethod  caller          = Tracing.On ? new TraceMethod(typeof(XmlReturn), "GetInitializers", methodInfos) : null;

            if (Tracing.On)
            {
                Tracing.Enter(Tracing.TraceId("TraceCreateSerializer"), caller, new TraceMethod(typeof(XmlSerializer), "FromMappings", new object[] { mappings, evidenceForType }));
            }
            XmlSerializer[] serializerArray = null;
            if (AppDomain.CurrentDomain.IsHomogenous)
            {
                serializerArray = XmlSerializer.FromMappings(mappings);
            }
            else
            {
                serializerArray = XmlSerializer.FromMappings(mappings, evidenceForType);
            }
            if (Tracing.On)
            {
                Tracing.Exit(Tracing.TraceId("TraceCreateSerializer"), caller);
            }
            object[] objArray = new object[methodInfos.Length];
            int      num2     = 0;

            for (int j = 0; j < objArray.Length; j++)
            {
                if (flagArray[j])
                {
                    objArray[j] = serializerArray[num2++];
                }
            }
            return(objArray);
        }
Ejemplo n.º 16
0
        internal SoapServerType(Type type, ProtocolsEnum versionsSupported) : base(type)
        {
            this.versionsSupported = versionsSupported;
            bool soap11 = (versionsSupported & ProtocolsEnum.HttpSoap) != 0;
            bool soap12 = (versionsSupported & ProtocolsEnum.HttpSoap12) != 0;

            LogicalMethodInfo[] methodInfos      = WebMethodReflector.GetMethods(type);
            ArrayList           mappings         = new ArrayList();
            WebServiceAttribute serviceAttribute = WebServiceReflector.GetAttribute(type);
            object soapServiceAttribute          = SoapReflector.GetSoapServiceAttribute(type);

            routingOnSoapAction     = SoapReflector.GetSoapServiceRoutingStyle(soapServiceAttribute) == SoapServiceRoutingStyle.SoapAction;
            serviceNamespace        = serviceAttribute.Namespace;
            serviceDefaultIsEncoded = SoapReflector.ServiceDefaultIsEncoded(type);
            SoapReflectionImporter soapImporter = SoapReflector.CreateSoapImporter(serviceNamespace, serviceDefaultIsEncoded);
            XmlReflectionImporter  xmlImporter  = SoapReflector.CreateXmlImporter(serviceNamespace, serviceDefaultIsEncoded);

            SoapReflector.IncludeTypes(methodInfos, soapImporter);
            WebMethodReflector.IncludeTypes(methodInfos, xmlImporter);
            SoapReflectedMethod[] soapMethods = new SoapReflectedMethod[methodInfos.Length];

            SoapExtensionType[] extensionTypes = WebServicesConfiguration.Current.SoapExtensionTypes;
            ArrayList           highPri        = new ArrayList();
            ArrayList           lowPri         = new ArrayList();

            for (int i = 0; i < extensionTypes.Length; i++)
            {
                SoapReflectedExtension extension = new SoapReflectedExtension(extensionTypes[i].Type, null, extensionTypes[i].Priority);
                if (extensionTypes[i].Group == SoapExtensionType.PriorityGroup.High)
                {
                    highPri.Add(extension);
                }
                else
                {
                    lowPri.Add(extension);
                }
            }
            HighPriExtensions = (SoapReflectedExtension[])highPri.ToArray(typeof(SoapReflectedExtension));
            LowPriExtensions  = (SoapReflectedExtension[])lowPri.ToArray(typeof(SoapReflectedExtension));
            Array.Sort(HighPriExtensions);
            Array.Sort(LowPriExtensions);
            HighPriExtensionInitializers = SoapReflectedExtension.GetInitializers(type, HighPriExtensions);
            LowPriExtensionInitializers  = SoapReflectedExtension.GetInitializers(type, LowPriExtensions);

            for (int i = 0; i < methodInfos.Length; i++)
            {
                LogicalMethodInfo   methodInfo = methodInfos[i];
                SoapReflectedMethod soapMethod = SoapReflector.ReflectMethod(methodInfo, false, xmlImporter, soapImporter, serviceAttribute.Namespace);
                mappings.Add(soapMethod.requestMappings);
                if (soapMethod.responseMappings != null)
                {
                    mappings.Add(soapMethod.responseMappings);
                }
                mappings.Add(soapMethod.inHeaderMappings);
                if (soapMethod.outHeaderMappings != null)
                {
                    mappings.Add(soapMethod.outHeaderMappings);
                }
                soapMethods[i] = soapMethod;
            }

            XmlSerializer[] serializers = XmlSerializer.FromMappings((XmlMapping[])mappings.ToArray(typeof(XmlMapping)));
            int             count       = 0;

            for (int i = 0; i < soapMethods.Length; i++)
            {
                SoapServerMethod    serverMethod = new SoapServerMethod();
                SoapReflectedMethod soapMethod   = soapMethods[i];
                serverMethod.parameterSerializer = serializers[count++];
                if (soapMethod.responseMappings != null)
                {
                    serverMethod.returnSerializer = serializers[count++];
                }
                serverMethod.inHeaderSerializer = serializers[count++];
                if (soapMethod.outHeaderMappings != null)
                {
                    serverMethod.outHeaderSerializer = serializers[count++];
                }
                serverMethod.methodInfo            = soapMethod.methodInfo;
                serverMethod.action                = soapMethod.action;
                serverMethod.extensions            = soapMethod.extensions;
                serverMethod.extensionInitializers = SoapReflectedExtension.GetInitializers(serverMethod.methodInfo, soapMethod.extensions);
                serverMethod.oneWay                = soapMethod.oneWay;
                serverMethod.rpc        = soapMethod.rpc;
                serverMethod.use        = soapMethod.use;
                serverMethod.paramStyle = soapMethod.paramStyle;
                ArrayList inHeaders  = new ArrayList();
                ArrayList outHeaders = new ArrayList();
                for (int j = 0; j < soapMethod.headers.Length; j++)
                {
                    SoapHeaderMapping   mapping    = new SoapHeaderMapping();
                    SoapReflectedHeader soapHeader = soapMethod.headers[j];
                    mapping.memberInfo = soapHeader.memberInfo;
                    mapping.repeats    = soapHeader.repeats;
                    mapping.custom     = soapHeader.custom;
                    mapping.direction  = soapHeader.direction;
                    mapping.headerType = soapHeader.headerType;
                    if (mapping.direction == SoapHeaderDirection.In)
                    {
                        inHeaders.Add(mapping);
                    }
                    else if (mapping.direction == SoapHeaderDirection.Out)
                    {
                        outHeaders.Add(mapping);
                    }
                    else
                    {
                        inHeaders.Add(mapping);
                        outHeaders.Add(mapping);
                    }
                }
                serverMethod.inHeaderMappings = (SoapHeaderMapping[])inHeaders.ToArray(typeof(SoapHeaderMapping));
                if (serverMethod.outHeaderSerializer != null)
                {
                    serverMethod.outHeaderMappings = (SoapHeaderMapping[])outHeaders.ToArray(typeof(SoapHeaderMapping));
                }

                // check feasibility of routing on request element for soap 1.1
                if (soap11 && !routingOnSoapAction && soapMethod.requestElementName.IsEmpty)
                {
                    throw new SoapException(Res.GetString(Res.TheMethodDoesNotHaveARequestElementEither1, serverMethod.methodInfo.Name), new XmlQualifiedName(Soap.ClientCode, Soap.Namespace));
                }

                // we can lookup methods by action or request element
                if (methods[soapMethod.action] == null)
                {
                    methods[soapMethod.action] = serverMethod;
                }
                else
                {
                    // duplicate soap actions not allowed in soap 1.1 if we're routing on soap action
                    if (soap11 && routingOnSoapAction)
                    {
                        SoapServerMethod duplicateMethod = (SoapServerMethod)methods[soapMethod.action];
                        throw new SoapException(Res.GetString(Res.TheMethodsAndUseTheSameSoapActionWhenTheService3, serverMethod.methodInfo.Name, duplicateMethod.methodInfo.Name, soapMethod.action), new XmlQualifiedName(Soap.ClientCode, Soap.Namespace));
                    }
                    duplicateMethods[soapMethod.action] = serverMethod;
                }

                if (methods[soapMethod.requestElementName] == null)
                {
                    methods[soapMethod.requestElementName] = serverMethod;
                }
                else
                {
                    // duplicate request elements not allowed in soap 1.1 if we're routing on request element
                    if (soap11 && !routingOnSoapAction)
                    {
                        SoapServerMethod duplicateMethod = (SoapServerMethod)methods[soapMethod.requestElementName];
                        throw new SoapException(Res.GetString(Res.TheMethodsAndUseTheSameRequestElementXmlns4, serverMethod.methodInfo.Name, duplicateMethod.methodInfo.Name, soapMethod.requestElementName.Name, soapMethod.requestElementName.Namespace), new XmlQualifiedName(Soap.ClientCode, Soap.Namespace));
                    }
                    duplicateMethods[soapMethod.requestElementName] = serverMethod;
                }
            }
        }
        public SoapServerType(Type type, WebServiceProtocols protocolsSupported) : base(type)
        {
            this.methods            = new Hashtable();
            this.duplicateMethods   = new Hashtable();
            this.protocolsSupported = protocolsSupported;
            bool flag = (protocolsSupported & WebServiceProtocols.HttpSoap) != WebServiceProtocols.Unknown;

            LogicalMethodInfo[] methods   = WebMethodReflector.GetMethods(type);
            ArrayList           list      = new ArrayList();
            WebServiceAttribute attribute = WebServiceReflector.GetAttribute(type);
            object soapServiceAttribute   = SoapReflector.GetSoapServiceAttribute(type);

            this.routingOnSoapAction     = SoapReflector.GetSoapServiceRoutingStyle(soapServiceAttribute) == SoapServiceRoutingStyle.SoapAction;
            this.serviceNamespace        = attribute.Namespace;
            this.serviceDefaultIsEncoded = SoapReflector.ServiceDefaultIsEncoded(type);
            SoapReflectionImporter importer  = SoapReflector.CreateSoapImporter(this.serviceNamespace, this.serviceDefaultIsEncoded);
            XmlReflectionImporter  importer2 = SoapReflector.CreateXmlImporter(this.serviceNamespace, this.serviceDefaultIsEncoded);

            SoapReflector.IncludeTypes(methods, importer);
            WebMethodReflector.IncludeTypes(methods, importer2);
            SoapReflectedMethod[] methodArray = new SoapReflectedMethod[methods.Length];
            SoapExtensionTypeElementCollection soapExtensionTypes = WebServicesSection.Current.SoapExtensionTypes;
            ArrayList list2 = new ArrayList();
            ArrayList list3 = new ArrayList();

            for (int i = 0; i < soapExtensionTypes.Count; i++)
            {
                SoapExtensionTypeElement element = soapExtensionTypes[i];
                if (element != null)
                {
                    SoapReflectedExtension extension = new SoapReflectedExtension(element.Type, null, element.Priority);
                    if (element.Group == PriorityGroup.High)
                    {
                        list2.Add(extension);
                    }
                    else
                    {
                        list3.Add(extension);
                    }
                }
            }
            this.HighPriExtensions = (SoapReflectedExtension[])list2.ToArray(typeof(SoapReflectedExtension));
            this.LowPriExtensions  = (SoapReflectedExtension[])list3.ToArray(typeof(SoapReflectedExtension));
            Array.Sort <SoapReflectedExtension>(this.HighPriExtensions);
            Array.Sort <SoapReflectedExtension>(this.LowPriExtensions);
            this.HighPriExtensionInitializers = SoapReflectedExtension.GetInitializers(type, this.HighPriExtensions);
            this.LowPriExtensionInitializers  = SoapReflectedExtension.GetInitializers(type, this.LowPriExtensions);
            for (int j = 0; j < methods.Length; j++)
            {
                LogicalMethodInfo   methodInfo = methods[j];
                SoapReflectedMethod method     = SoapReflector.ReflectMethod(methodInfo, false, importer2, importer, attribute.Namespace);
                list.Add(method.requestMappings);
                if (method.responseMappings != null)
                {
                    list.Add(method.responseMappings);
                }
                list.Add(method.inHeaderMappings);
                if (method.outHeaderMappings != null)
                {
                    list.Add(method.outHeaderMappings);
                }
                methodArray[j] = method;
            }
            XmlMapping[] mappings = (XmlMapping[])list.ToArray(typeof(XmlMapping));
            TraceMethod  caller   = Tracing.On ? new TraceMethod(this, ".ctor", new object[] { type, protocolsSupported }) : null;

            if (Tracing.On)
            {
                Tracing.Enter(Tracing.TraceId("TraceCreateSerializer"), caller, new TraceMethod(typeof(XmlSerializer), "FromMappings", new object[] { mappings, base.Evidence }));
            }
            XmlSerializer[] serializerArray = null;
            if (AppDomain.CurrentDomain.IsHomogenous)
            {
                serializerArray = XmlSerializer.FromMappings(mappings);
            }
            else
            {
                serializerArray = XmlSerializer.FromMappings(mappings, base.Evidence);
            }
            if (Tracing.On)
            {
                Tracing.Exit(Tracing.TraceId("TraceCreateSerializer"), caller);
            }
            int num3 = 0;

            for (int k = 0; k < methodArray.Length; k++)
            {
                SoapServerMethod    method3 = new SoapServerMethod();
                SoapReflectedMethod method4 = methodArray[k];
                method3.parameterSerializer = serializerArray[num3++];
                if (method4.responseMappings != null)
                {
                    method3.returnSerializer = serializerArray[num3++];
                }
                method3.inHeaderSerializer = serializerArray[num3++];
                if (method4.outHeaderMappings != null)
                {
                    method3.outHeaderSerializer = serializerArray[num3++];
                }
                method3.methodInfo            = method4.methodInfo;
                method3.action                = method4.action;
                method3.extensions            = method4.extensions;
                method3.extensionInitializers = SoapReflectedExtension.GetInitializers(method3.methodInfo, method4.extensions);
                method3.oneWay                = method4.oneWay;
                method3.rpc        = method4.rpc;
                method3.use        = method4.use;
                method3.paramStyle = method4.paramStyle;
                method3.wsiClaims  = (method4.binding == null) ? WsiProfiles.None : method4.binding.ConformsTo;
                ArrayList list4 = new ArrayList();
                ArrayList list5 = new ArrayList();
                for (int m = 0; m < method4.headers.Length; m++)
                {
                    SoapHeaderMapping   mapping = new SoapHeaderMapping();
                    SoapReflectedHeader header  = method4.headers[m];
                    mapping.memberInfo = header.memberInfo;
                    mapping.repeats    = header.repeats;
                    mapping.custom     = header.custom;
                    mapping.direction  = header.direction;
                    mapping.headerType = header.headerType;
                    if (mapping.direction == SoapHeaderDirection.In)
                    {
                        list4.Add(mapping);
                    }
                    else if (mapping.direction == SoapHeaderDirection.Out)
                    {
                        list5.Add(mapping);
                    }
                    else
                    {
                        list4.Add(mapping);
                        list5.Add(mapping);
                    }
                }
                method3.inHeaderMappings = (SoapHeaderMapping[])list4.ToArray(typeof(SoapHeaderMapping));
                if (method3.outHeaderSerializer != null)
                {
                    method3.outHeaderMappings = (SoapHeaderMapping[])list5.ToArray(typeof(SoapHeaderMapping));
                }
                if ((flag && !this.routingOnSoapAction) && method4.requestElementName.IsEmpty)
                {
                    throw new SoapException(System.Web.Services.Res.GetString("TheMethodDoesNotHaveARequestElementEither1", new object[] { method3.methodInfo.Name }), new XmlQualifiedName("Client", "http://schemas.xmlsoap.org/soap/envelope/"));
                }
                if (this.methods[method4.action] == null)
                {
                    this.methods[method4.action] = method3;
                }
                else
                {
                    if (flag && this.routingOnSoapAction)
                    {
                        SoapServerMethod method5 = (SoapServerMethod)this.methods[method4.action];
                        throw new SoapException(System.Web.Services.Res.GetString("TheMethodsAndUseTheSameSoapActionWhenTheService3", new object[] { method3.methodInfo.Name, method5.methodInfo.Name, method4.action }), new XmlQualifiedName("Client", "http://schemas.xmlsoap.org/soap/envelope/"));
                    }
                    this.duplicateMethods[method4.action] = method3;
                }
                if (this.methods[method4.requestElementName] == null)
                {
                    this.methods[method4.requestElementName] = method3;
                }
                else
                {
                    if (flag && !this.routingOnSoapAction)
                    {
                        SoapServerMethod method6 = (SoapServerMethod)this.methods[method4.requestElementName];
                        throw new SoapException(System.Web.Services.Res.GetString("TheMethodsAndUseTheSameRequestElementXmlns4", new object[] { method3.methodInfo.Name, method6.methodInfo.Name, method4.requestElementName.Name, method4.requestElementName.Namespace }), new XmlQualifiedName("Client", "http://schemas.xmlsoap.org/soap/envelope/"));
                    }
                    this.duplicateMethods[method4.requestElementName] = method3;
                }
            }
        }