private static Array CombineExtensionsHelper(Array array1, Array array2, Array array3, Type elementType) { int length = array1.Length + array2.Length + array3.Length; if (length == 0) { return(null); } Array result = null; if (elementType == typeof(SoapReflectedExtension)) { result = new SoapReflectedExtension[length]; } else if (elementType == typeof(object)) { result = new object[length]; } else { throw new ArgumentException(Res.GetString(Res.ElementTypeMustBeObjectOrSoapReflectedException), "elementType"); } int pos = 0; Array.Copy(array1, 0, result, pos, array1.Length); pos += array1.Length; Array.Copy(array2, 0, result, pos, array2.Length); pos += array2.Length; Array.Copy(array3, 0, result, pos, array3.Length); return(result); }
private static Array CombineExtensionsHelper(Array array1, Array array2, Array array3, Type elementType) { int num = (array1.Length + array2.Length) + array3.Length; if (num == 0) { return(null); } Array destinationArray = null; if (elementType == typeof(SoapReflectedExtension)) { destinationArray = new SoapReflectedExtension[num]; } else { if (elementType != typeof(object)) { throw new ArgumentException(System.Web.Services.Res.GetString("ElementTypeMustBeObjectOrSoapReflectedException"), "elementType"); } destinationArray = new object[num]; } int destinationIndex = 0; Array.Copy(array1, 0, destinationArray, destinationIndex, array1.Length); destinationIndex += array1.Length; Array.Copy(array2, 0, destinationArray, destinationIndex, array2.Length); destinationIndex += array2.Length; Array.Copy(array3, 0, destinationArray, destinationIndex, array3.Length); return(destinationArray); }
internal static object[] GetInitializers(LogicalMethodInfo methodInfo, SoapReflectedExtension[] extensions) { object[] objArray = new object[extensions.Length]; for (int i = 0; i < objArray.Length; i++) { objArray[i] = extensions[i].GetInitializer(methodInfo); } return objArray; }
internal static object[] GetInitializers(Type serviceType, SoapReflectedExtension[] extensions) { object[] objArray = new object[extensions.Length]; for (int i = 0; i < objArray.Length; i++) { objArray[i] = extensions[i].GetInitializer(serviceType); } return objArray; }
private void ImportReflectedMethod(SoapReflectedMethod soapMethod) { this.action = soapMethod.action; this.extensions = soapMethod.extensions; this.extensionInitializers = SoapReflectedExtension.GetInitializers(this.methodInfo, soapMethod.extensions); this.oneWay = soapMethod.oneWay; this.rpc = soapMethod.rpc; this.use = soapMethod.use; this.paramStyle = soapMethod.paramStyle; this.wsiClaims = soapMethod.binding == null ? WsiProfiles.None : soapMethod.binding.ConformsTo; }
internal SoapClientType(Type type) { LogicalMethodInfo[] methodInfos = LogicalMethodInfo.Create(type.GetMethods(BindingFlags.Public | BindingFlags.Instance), LogicalMethodTypes.Sync); ArrayList mappings = new ArrayList(); ArrayList soapMethodList = new ArrayList(); this.binding = WebServiceBindingReflector.GetAttribute(type); if (this.binding == null) { throw new InvalidOperationException(Res.GetString(Res.WebClientBindingAttributeRequired)); } // Note: Service namespace is taken from WebserviceBindingAttribute and not WebserviceAttribute because // the generated proxy does not have a WebServiceAttribute; however all have a WebServiceBindingAttribute. serviceNamespace = binding.Namespace; serviceDefaultIsEncoded = SoapReflector.ServiceDefaultIsEncoded(type); SoapReflectionImporter soapImporter = SoapReflector.CreateSoapImporter(serviceNamespace, serviceDefaultIsEncoded); XmlReflectionImporter xmlImporter = SoapReflector.CreateXmlImporter(serviceNamespace, serviceDefaultIsEncoded); WebMethodReflector.IncludeTypes(methodInfos, xmlImporter); SoapReflector.IncludeTypes(methodInfos, soapImporter); 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, true, xmlImporter, soapImporter, serviceNamespace); if (soapMethod == null) { continue; } soapMethodList.Add(soapMethod); mappings.Add(soapMethod.requestMappings); if (soapMethod.responseMappings != null) { mappings.Add(soapMethod.responseMappings); } mappings.Add(soapMethod.inHeaderMappings); if (soapMethod.outHeaderMappings != null) { mappings.Add(soapMethod.outHeaderMappings); } } XmlSerializer[] serializers = XmlSerializer.FromMappings((XmlMapping[])mappings.ToArray(typeof(XmlMapping))); int count = 0; for (int i = 0; i < soapMethodList.Count; i++) { SoapReflectedMethod soapMethod = (SoapReflectedMethod)soapMethodList[i]; SoapClientMethod clientMethod = new SoapClientMethod(); clientMethod.parameterSerializer = serializers[count++]; if (soapMethod.responseMappings != null) { clientMethod.returnSerializer = serializers[count++]; } clientMethod.inHeaderSerializer = serializers[count++]; if (soapMethod.outHeaderMappings != null) { clientMethod.outHeaderSerializer = serializers[count++]; } clientMethod.action = soapMethod.action; clientMethod.oneWay = soapMethod.oneWay; clientMethod.rpc = soapMethod.rpc; clientMethod.use = soapMethod.use; clientMethod.paramStyle = soapMethod.paramStyle; clientMethod.methodInfo = soapMethod.methodInfo; clientMethod.extensions = soapMethod.extensions; clientMethod.extensionInitializers = SoapReflectedExtension.GetInitializers(clientMethod.methodInfo, soapMethod.extensions); 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) != 0) { inHeaders.Add(mapping); } if ((mapping.direction & (SoapHeaderDirection.Out | SoapHeaderDirection.Fault)) != 0) { outHeaders.Add(mapping); } } clientMethod.inHeaderMappings = (SoapHeaderMapping[])inHeaders.ToArray(typeof(SoapHeaderMapping)); if (clientMethod.outHeaderSerializer != null) { clientMethod.outHeaderMappings = (SoapHeaderMapping[])outHeaders.ToArray(typeof(SoapHeaderMapping)); } methods.Add(soapMethod.name, clientMethod); } }
public SoapServerType(Type type, WebServiceProtocols protocolsSupported) : base(type) { this.protocolsSupported = protocolsSupported; bool soap11 = (protocolsSupported & WebServiceProtocols.HttpSoap) != 0; bool soap12 = (protocolsSupported & WebServiceProtocols.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]; SoapExtensionTypeElementCollection extensionTypes = WebServicesSection.Current.SoapExtensionTypes; ArrayList highPri = new ArrayList(); ArrayList lowPri = new ArrayList(); for (int i = 0; i < extensionTypes.Count; i++) { SoapExtensionTypeElement element = extensionTypes[i]; if (element == null) continue; SoapReflectedExtension extension = new SoapReflectedExtension(element.Type, null, element.Priority); if (element.Group == 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; } XmlMapping[] xmlMappings = (XmlMapping[])mappings.ToArray(typeof(XmlMapping)); TraceMethod caller = Tracing.On ? new TraceMethod(this, ".ctor", type, protocolsSupported) : null; if (Tracing.On) Tracing.Enter(Tracing.TraceId(Res.TraceCreateSerializer), caller, new TraceMethod(typeof(XmlSerializer), "FromMappings", xmlMappings, this.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), this.Evidence); #pragma warning restore 618 } if (Tracing.On) Tracing.Exit(Tracing.TraceId(Res.TraceCreateSerializer), caller); 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; serverMethod.wsiClaims = soapMethod.binding == null ? WsiProfiles.None : soapMethod.binding.ConformsTo; 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.Code.Client, 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.Code.Client, 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.Code.Client, Soap.Namespace)); } duplicateMethods[soapMethod.requestElementName] = serverMethod; } } }
internal static object[] GetInitializers(Type serviceType, SoapReflectedExtension[] extensions) { object[] initializers = new object[extensions.Length]; for (int i = 0; i < initializers.Length; i++) initializers[i] = extensions[i].GetInitializer(serviceType); return initializers; }
internal static object[] GetInitializers(LogicalMethodInfo methodInfo, SoapReflectedExtension[] extensions) { object[] initializers = new object[extensions.Length]; for (int i = 0; i < initializers.Length; i++) initializers[i] = extensions[i].GetInitializer(methodInfo); return initializers; }
internal SoapClientType(Type type) { this.binding = WebServiceBindingReflector.GetAttribute(type); if (this.binding == null) { throw new InvalidOperationException(Res.GetString(Res.WebClientBindingAttributeRequired)); } // Note: Service namespace is taken from WebserviceBindingAttribute and not WebserviceAttribute because // the generated proxy does not have a WebServiceAttribute; however all have a WebServiceBindingAttribute. serviceNamespace = binding.Namespace; serviceDefaultIsEncoded = SoapReflector.ServiceDefaultIsEncoded(type); ArrayList soapMethodList = new ArrayList(); ArrayList mappings = new ArrayList(); GenerateXmlMappings(type, soapMethodList, serviceNamespace, serviceDefaultIsEncoded, mappings); XmlMapping[] xmlMappings = (XmlMapping[])mappings.ToArray(typeof(XmlMapping)); TraceMethod caller = Tracing.On ? new TraceMethod(this, ".ctor", type) : null; if (Tracing.On) { Tracing.Enter(Tracing.TraceId(Res.TraceCreateSerializer), caller, new TraceMethod(typeof(XmlSerializer), "FromMappings", xmlMappings, type)); } XmlSerializer[] serializers = XmlSerializer.FromMappings(xmlMappings, type); if (Tracing.On) { Tracing.Exit(Tracing.TraceId(Res.TraceCreateSerializer), caller); } SoapExtensionTypeElementCollection extensionTypes = WebServicesSection.Current.SoapExtensionTypes; ArrayList highPri = new ArrayList(); ArrayList lowPri = new ArrayList(); for (int i = 0; i < extensionTypes.Count; i++) { SoapExtensionTypeElement element = extensionTypes[i]; SoapReflectedExtension extension = new SoapReflectedExtension(extensionTypes[i].Type, null, extensionTypes[i].Priority); if (extensionTypes[i].Group == 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); int count = 0; for (int i = 0; i < soapMethodList.Count; i++) { SoapReflectedMethod soapMethod = (SoapReflectedMethod)soapMethodList[i]; SoapClientMethod clientMethod = new SoapClientMethod(); clientMethod.parameterSerializer = serializers[count++]; if (soapMethod.responseMappings != null) { clientMethod.returnSerializer = serializers[count++]; } clientMethod.inHeaderSerializer = serializers[count++]; if (soapMethod.outHeaderMappings != null) { clientMethod.outHeaderSerializer = serializers[count++]; } clientMethod.action = soapMethod.action; clientMethod.oneWay = soapMethod.oneWay; clientMethod.rpc = soapMethod.rpc; clientMethod.use = soapMethod.use; clientMethod.paramStyle = soapMethod.paramStyle; clientMethod.methodInfo = soapMethod.methodInfo; clientMethod.extensions = soapMethod.extensions; clientMethod.extensionInitializers = SoapReflectedExtension.GetInitializers(clientMethod.methodInfo, soapMethod.extensions); 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) != 0) { inHeaders.Add(mapping); } if ((mapping.direction & (SoapHeaderDirection.Out | SoapHeaderDirection.Fault)) != 0) { outHeaders.Add(mapping); } } clientMethod.inHeaderMappings = (SoapHeaderMapping[])inHeaders.ToArray(typeof(SoapHeaderMapping)); if (clientMethod.outHeaderSerializer != null) { clientMethod.outHeaderMappings = (SoapHeaderMapping[])outHeaders.ToArray(typeof(SoapHeaderMapping)); } methods.Add(soapMethod.name, clientMethod); } }
internal static SoapExtension[] InitializeExtensions(SoapReflectedExtension[] reflectedExtensions, object[] extensionInitializers) { if (reflectedExtensions == null) return (SoapExtension[]) null; SoapExtension[] soapExtensionArray = new SoapExtension[reflectedExtensions.Length]; for (int index = 0; index < soapExtensionArray.Length; ++index) soapExtensionArray[index] = reflectedExtensions[index].CreateInstance(extensionInitializers[index]); return soapExtensionArray; }
internal SoapClientType(Type type) { this.binding = WebServiceBindingReflector.GetAttribute(type); if (this.binding == null) throw new InvalidOperationException(Res.GetString(Res.WebClientBindingAttributeRequired)); // Note: Service namespace is taken from WebserviceBindingAttribute and not WebserviceAttribute because // the generated proxy does not have a WebServiceAttribute; however all have a WebServiceBindingAttribute. serviceNamespace = binding.Namespace; serviceDefaultIsEncoded = SoapReflector.ServiceDefaultIsEncoded(type); ArrayList soapMethodList = new ArrayList(); ArrayList mappings = new ArrayList(); GenerateXmlMappings(type, soapMethodList, serviceNamespace, serviceDefaultIsEncoded, mappings); XmlMapping[] xmlMappings = (XmlMapping[])mappings.ToArray(typeof(XmlMapping)); TraceMethod caller = Tracing.On ? new TraceMethod(this, ".ctor", type) : null; if (Tracing.On) Tracing.Enter(Tracing.TraceId(Res.TraceCreateSerializer), caller, new TraceMethod(typeof(XmlSerializer), "FromMappings", xmlMappings, type)); XmlSerializer[] serializers = XmlSerializer.FromMappings(xmlMappings, type); if (Tracing.On) Tracing.Exit(Tracing.TraceId(Res.TraceCreateSerializer), caller); SoapExtensionTypeElementCollection extensionTypes = WebServicesSection.Current.SoapExtensionTypes; ArrayList highPri = new ArrayList(); ArrayList lowPri = new ArrayList(); for (int i = 0; i < extensionTypes.Count; i++) { SoapExtensionTypeElement element = extensionTypes[i]; SoapReflectedExtension extension = new SoapReflectedExtension(extensionTypes[i].Type, null, extensionTypes[i].Priority); if (extensionTypes[i].Group == 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); int count = 0; for (int i = 0; i < soapMethodList.Count; i++) { SoapReflectedMethod soapMethod = (SoapReflectedMethod)soapMethodList[i]; SoapClientMethod clientMethod = new SoapClientMethod(); clientMethod.parameterSerializer = serializers[count++]; if (soapMethod.responseMappings != null) clientMethod.returnSerializer = serializers[count++]; clientMethod.inHeaderSerializer = serializers[count++]; if (soapMethod.outHeaderMappings != null) clientMethod.outHeaderSerializer = serializers[count++]; clientMethod.action = soapMethod.action; clientMethod.oneWay = soapMethod.oneWay; clientMethod.rpc = soapMethod.rpc; clientMethod.use = soapMethod.use; clientMethod.paramStyle = soapMethod.paramStyle; clientMethod.methodInfo = soapMethod.methodInfo; clientMethod.extensions = soapMethod.extensions; clientMethod.extensionInitializers = SoapReflectedExtension.GetInitializers(clientMethod.methodInfo, soapMethod.extensions); 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) != 0) inHeaders.Add(mapping); if ((mapping.direction & (SoapHeaderDirection.Out | SoapHeaderDirection.Fault)) != 0) outHeaders.Add(mapping); } clientMethod.inHeaderMappings = (SoapHeaderMapping[])inHeaders.ToArray(typeof(SoapHeaderMapping)); if (clientMethod.outHeaderSerializer != null) clientMethod.outHeaderMappings = (SoapHeaderMapping[])outHeaders.ToArray(typeof(SoapHeaderMapping)); methods.Add(soapMethod.name, clientMethod); } }
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; } } }
internal SoapClientType(Type type) { this.binding = WebServiceBindingReflector.GetAttribute(type); if (this.binding == null) { throw new InvalidOperationException(Res.GetString("WebClientBindingAttributeRequired")); } this.serviceNamespace = this.binding.Namespace; this.serviceDefaultIsEncoded = SoapReflector.ServiceDefaultIsEncoded(type); ArrayList soapMethodList = new ArrayList(); ArrayList mappings = new ArrayList(); GenerateXmlMappings(type, soapMethodList, this.serviceNamespace, this.serviceDefaultIsEncoded, mappings); XmlMapping[] mappingArray = (XmlMapping[])mappings.ToArray(typeof(XmlMapping)); TraceMethod caller = Tracing.On ? new TraceMethod(this, ".ctor", new object[] { type }) : null; if (Tracing.On) { Tracing.Enter(Tracing.TraceId("TraceCreateSerializer"), caller, new TraceMethod(typeof(XmlSerializer), "FromMappings", new object[] { mappingArray, type })); } XmlSerializer[] serializerArray = XmlSerializer.FromMappings(mappingArray, type); if (Tracing.On) { Tracing.Exit(Tracing.TraceId("TraceCreateSerializer"), caller); } SoapExtensionTypeElementCollection soapExtensionTypes = WebServicesSection.Current.SoapExtensionTypes; ArrayList list3 = new ArrayList(); ArrayList list4 = new ArrayList(); for (int i = 0; i < soapExtensionTypes.Count; i++) { SoapExtensionTypeElement element1 = soapExtensionTypes[i]; SoapReflectedExtension extension = new SoapReflectedExtension(soapExtensionTypes[i].Type, null, soapExtensionTypes[i].Priority); if (soapExtensionTypes[i].Group == PriorityGroup.High) { list3.Add(extension); } else { list4.Add(extension); } } this.HighPriExtensions = (SoapReflectedExtension[])list3.ToArray(typeof(SoapReflectedExtension)); this.LowPriExtensions = (SoapReflectedExtension[])list4.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); int num2 = 0; for (int j = 0; j < soapMethodList.Count; j++) { SoapReflectedMethod method2 = (SoapReflectedMethod)soapMethodList[j]; SoapClientMethod method3 = new SoapClientMethod { parameterSerializer = serializerArray[num2++] }; if (method2.responseMappings != null) { method3.returnSerializer = serializerArray[num2++]; } method3.inHeaderSerializer = serializerArray[num2++]; if (method2.outHeaderMappings != null) { method3.outHeaderSerializer = serializerArray[num2++]; } method3.action = method2.action; method3.oneWay = method2.oneWay; method3.rpc = method2.rpc; method3.use = method2.use; method3.paramStyle = method2.paramStyle; method3.methodInfo = method2.methodInfo; method3.extensions = method2.extensions; method3.extensionInitializers = SoapReflectedExtension.GetInitializers(method3.methodInfo, method2.extensions); ArrayList list5 = new ArrayList(); ArrayList list6 = new ArrayList(); for (int k = 0; k < method2.headers.Length; k++) { SoapHeaderMapping mapping = new SoapHeaderMapping(); SoapReflectedHeader header = method2.headers[k]; 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) != 0) { list5.Add(mapping); } if ((mapping.direction & (SoapHeaderDirection.Fault | SoapHeaderDirection.Out)) != 0) { list6.Add(mapping); } } method3.inHeaderMappings = (SoapHeaderMapping[])list5.ToArray(typeof(SoapHeaderMapping)); if (method3.outHeaderSerializer != null) { method3.outHeaderMappings = (SoapHeaderMapping[])list6.ToArray(typeof(SoapHeaderMapping)); } this.methods.Add(method2.name, method3); } }
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; } } }
private static Array CombineExtensionsHelper(Array array1, Array array2, Array array3, Type elementType) { int num = (array1.Length + array2.Length) + array3.Length; if (num == 0) { return null; } Array destinationArray = null; if (elementType == typeof(SoapReflectedExtension)) { destinationArray = new SoapReflectedExtension[num]; } else { if (elementType != typeof(object)) { throw new ArgumentException(System.Web.Services.Res.GetString("ElementTypeMustBeObjectOrSoapReflectedException"), "elementType"); } destinationArray = new object[num]; } int destinationIndex = 0; Array.Copy(array1, 0, destinationArray, destinationIndex, array1.Length); destinationIndex += array1.Length; Array.Copy(array2, 0, destinationArray, destinationIndex, array2.Length); destinationIndex += array2.Length; Array.Copy(array3, 0, destinationArray, destinationIndex, array3.Length); return destinationArray; }
internal SoapClientType(Type type) { this.binding = WebServiceBindingReflector.GetAttribute(type); if (this.binding == null) { throw new InvalidOperationException(Res.GetString("WebClientBindingAttributeRequired")); } this.serviceNamespace = this.binding.Namespace; this.serviceDefaultIsEncoded = SoapReflector.ServiceDefaultIsEncoded(type); ArrayList soapMethodList = new ArrayList(); ArrayList mappings = new ArrayList(); GenerateXmlMappings(type, soapMethodList, this.serviceNamespace, this.serviceDefaultIsEncoded, mappings); XmlMapping[] mappingArray = (XmlMapping[]) mappings.ToArray(typeof(XmlMapping)); TraceMethod caller = Tracing.On ? new TraceMethod(this, ".ctor", new object[] { type }) : null; if (Tracing.On) { Tracing.Enter(Tracing.TraceId("TraceCreateSerializer"), caller, new TraceMethod(typeof(XmlSerializer), "FromMappings", new object[] { mappingArray, type })); } XmlSerializer[] serializerArray = XmlSerializer.FromMappings(mappingArray, type); if (Tracing.On) { Tracing.Exit(Tracing.TraceId("TraceCreateSerializer"), caller); } SoapExtensionTypeElementCollection soapExtensionTypes = WebServicesSection.Current.SoapExtensionTypes; ArrayList list3 = new ArrayList(); ArrayList list4 = new ArrayList(); for (int i = 0; i < soapExtensionTypes.Count; i++) { SoapExtensionTypeElement element1 = soapExtensionTypes[i]; SoapReflectedExtension extension = new SoapReflectedExtension(soapExtensionTypes[i].Type, null, soapExtensionTypes[i].Priority); if (soapExtensionTypes[i].Group == PriorityGroup.High) { list3.Add(extension); } else { list4.Add(extension); } } this.HighPriExtensions = (SoapReflectedExtension[]) list3.ToArray(typeof(SoapReflectedExtension)); this.LowPriExtensions = (SoapReflectedExtension[]) list4.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); int num2 = 0; for (int j = 0; j < soapMethodList.Count; j++) { SoapReflectedMethod method2 = (SoapReflectedMethod) soapMethodList[j]; SoapClientMethod method3 = new SoapClientMethod { parameterSerializer = serializerArray[num2++] }; if (method2.responseMappings != null) { method3.returnSerializer = serializerArray[num2++]; } method3.inHeaderSerializer = serializerArray[num2++]; if (method2.outHeaderMappings != null) { method3.outHeaderSerializer = serializerArray[num2++]; } method3.action = method2.action; method3.oneWay = method2.oneWay; method3.rpc = method2.rpc; method3.use = method2.use; method3.paramStyle = method2.paramStyle; method3.methodInfo = method2.methodInfo; method3.extensions = method2.extensions; method3.extensionInitializers = SoapReflectedExtension.GetInitializers(method3.methodInfo, method2.extensions); ArrayList list5 = new ArrayList(); ArrayList list6 = new ArrayList(); for (int k = 0; k < method2.headers.Length; k++) { SoapHeaderMapping mapping = new SoapHeaderMapping(); SoapReflectedHeader header = method2.headers[k]; 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) != 0) { list5.Add(mapping); } if ((mapping.direction & (SoapHeaderDirection.Fault | SoapHeaderDirection.Out)) != 0) { list6.Add(mapping); } } method3.inHeaderMappings = (SoapHeaderMapping[]) list5.ToArray(typeof(SoapHeaderMapping)); if (method3.outHeaderSerializer != null) { method3.outHeaderMappings = (SoapHeaderMapping[]) list6.ToArray(typeof(SoapHeaderMapping)); } this.methods.Add(method2.name, method3); } }
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; } } }
private static Array CombineExtensionsHelper(Array array1, Array array2, Array array3, Type elementType) { int length = array1.Length + array2.Length + array3.Length; if (length == 0) return null; Array result = null; if (elementType == typeof(SoapReflectedExtension)) result = new SoapReflectedExtension[length]; else if (elementType == typeof(object)) result = new object[length]; else throw new ArgumentException(Res.GetString(Res.ElementTypeMustBeObjectOrSoapReflectedException), "elementType"); int pos = 0; Array.Copy(array1, 0, result, pos, array1.Length); pos += array1.Length; Array.Copy(array2, 0, result, pos, array2.Length); pos += array2.Length; Array.Copy(array3, 0, result, pos, array3.Length); return result; }
internal static SoapExtension[] InitializeExtensions(SoapReflectedExtension[] reflectedExtensions, object[] extensionInitializers) { if (reflectedExtensions == null) return null; SoapExtension[] extensions = new SoapExtension[reflectedExtensions.Length]; for (int i = 0; i < extensions.Length; i++) { extensions[i] = reflectedExtensions[i].CreateInstance(extensionInitializers[i]); } return extensions; }