internal static WebServiceBindingAttribute GetAttribute(LogicalMethodInfo methodInfo, string binding) { if (methodInfo.Binding != null) { if (binding.Length > 0 && methodInfo.Binding.Name != binding) { throw new InvalidOperationException(Res.GetString(Res.WebInvalidBindingName, binding, methodInfo.Binding.Name)); } return(methodInfo.Binding); } Type type = methodInfo.DeclaringType; object[] attrs = type.GetCustomAttributes(typeof(WebServiceBindingAttribute), false); WebServiceBindingAttribute webAttr = null; foreach (WebServiceBindingAttribute attr in attrs) { if (attr.Name == binding) { if (webAttr != null) { throw new ArgumentException(Res.GetString(Res.MultipleBindingsWithSameName2, type.FullName, binding, "methodInfo")); } webAttr = attr; } } if (webAttr == null && binding != null && binding.Length > 0) { throw new ArgumentException(Res.GetString(Res.TypeIsMissingWebServiceBindingAttributeThat2, type.FullName, binding), "methodInfo"); } return(webAttr); }
private LogicalMethodInfo(System.Reflection.MethodInfo beginMethodInfo, System.Reflection.MethodInfo endMethodInfo, WebMethod webMethod) { this.methodInfo = beginMethodInfo; this.endMethodInfo = endMethodInfo; this.methodName = beginMethodInfo.Name.Substring(5); if (webMethod != null) { this.binding = webMethod.binding; this.attribute = webMethod.attribute; this.declaration = webMethod.declaration; } ParameterInfo[] parameters = beginMethodInfo.GetParameters(); if (((parameters.Length < 2) || (parameters[parameters.Length - 1].ParameterType != typeof(object))) || (parameters[parameters.Length - 2].ParameterType != typeof(AsyncCallback))) { throw new InvalidOperationException(Res.GetString("WebMethodMissingParams", new object[] { beginMethodInfo.DeclaringType.FullName, beginMethodInfo.Name, typeof(AsyncCallback).FullName, typeof(object).FullName })); } this.stateParam = parameters[parameters.Length - 1]; this.callbackParam = parameters[parameters.Length - 2]; this.inParams = GetInParameters(beginMethodInfo, parameters, 0, parameters.Length - 2, true); ParameterInfo[] paramInfos = endMethodInfo.GetParameters(); this.resultParam = paramInfos[0]; this.outParams = GetOutParameters(endMethodInfo, paramInfos, 1, paramInfos.Length - 1, true); this.parameters = new ParameterInfo[this.inParams.Length + this.outParams.Length]; this.inParams.CopyTo(this.parameters, 0); this.outParams.CopyTo(this.parameters, this.inParams.Length); this.retType = endMethodInfo.ReturnType; this.isVoid = this.retType == typeof(void); this.attributes = new Hashtable(); }
internal static WebServiceBindingAttribute GetAttribute(LogicalMethodInfo methodInfo, string binding) { if (methodInfo.Binding != null) { if ((binding.Length > 0) && (methodInfo.Binding.Name != binding)) { throw new InvalidOperationException(Res.GetString("WebInvalidBindingName", new object[] { binding, methodInfo.Binding.Name })); } return(methodInfo.Binding); } Type declaringType = methodInfo.DeclaringType; object[] customAttributes = declaringType.GetCustomAttributes(typeof(WebServiceBindingAttribute), false); WebServiceBindingAttribute attribute = null; foreach (WebServiceBindingAttribute attribute2 in customAttributes) { if (attribute2.Name == binding) { if (attribute != null) { throw new ArgumentException(Res.GetString("MultipleBindingsWithSameName2", new object[] { declaringType.FullName, binding, "methodInfo" })); } attribute = attribute2; } } if (((attribute == null) && (binding != null)) && (binding.Length > 0)) { throw new ArgumentException(Res.GetString("TypeIsMissingWebServiceBindingAttributeThat2", new object[] { declaringType.FullName, binding }), "methodInfo"); } return(attribute); }
internal LogicalMethodInfo(MethodInfo methodInfo, WebMethod webMethod) { if (methodInfo.IsStatic) throw new InvalidOperationException(Res.GetString(Res.WebMethodStatic, methodInfo.Name)); this.methodInfo = methodInfo; if (webMethod != null) { this.binding = webMethod.binding; this.attribute = webMethod.attribute; this.declaration = webMethod.declaration; } MethodInfo methodDefinition = declaration != null ? declaration : methodInfo; parameters = methodDefinition.GetParameters(); inParams = GetInParameters(methodDefinition, parameters, 0, parameters.Length, false); outParams = GetOutParameters(methodDefinition, parameters, 0, parameters.Length, false); retType = methodDefinition.ReturnType; isVoid = retType == typeof(void); methodName = methodDefinition.Name; attributes = new Hashtable(); }
internal LogicalMethodInfo(System.Reflection.MethodInfo methodInfo, WebMethod webMethod) { if (methodInfo.IsStatic) { throw new InvalidOperationException(Res.GetString("WebMethodStatic", new object[] { methodInfo.Name })); } this.methodInfo = methodInfo; if (webMethod != null) { this.binding = webMethod.binding; this.attribute = webMethod.attribute; this.declaration = webMethod.declaration; } System.Reflection.MethodInfo info = (this.declaration != null) ? this.declaration : methodInfo; this.parameters = info.GetParameters(); this.inParams = GetInParameters(info, this.parameters, 0, this.parameters.Length, false); this.outParams = GetOutParameters(info, this.parameters, 0, this.parameters.Length, false); this.retType = info.ReturnType; this.isVoid = this.retType == typeof(void); this.methodName = info.Name; this.attributes = new Hashtable(); }
internal WebMethod(MethodInfo declaration, WebServiceBindingAttribute binding, WebMethodAttribute attribute) { this.declaration = declaration; this.binding = binding; this.attribute = attribute; }
public BindingInfo (WebServiceBindingAttribute at, string name, string ns) { if (at != null) { #if NET_1_1 Name = at.Name; #endif Namespace = at.Namespace; Location = at.Location; WebServiceBindingAttribute = at; } if (Name == null || Name.Length == 0) Name = name; if (Namespace == null || Namespace.Length == 0) Namespace = ns; }
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); } }
private bindingTemplate parseServiceBinding(string classWithAnnotations, string lang, WebServiceBindingAttribute webServiceAnnotation, Properties properties) { bindingTemplate bindingTemplate = null; Type t = Type.GetType(classWithAnnotations, false, false); UDDIServiceBinding uddiServiceBinding = null; object[] attrib = t.GetCustomAttributes(typeof(UDDIServiceBinding), true); if (attrib != null && attrib.Length > 0) uddiServiceBinding = attrib[0] as UDDIServiceBinding; //= (UDDIServiceBinding) classWithAnnotations.getAnnotation(UDDIServiceBinding.class); //binding if (uddiServiceBinding != null) { bindingTemplate = new bindingTemplate(); bindingTemplate.bindingKey = (TokenResolver.replaceTokens(uddiServiceBinding.bindingKey, properties)); String bindingLang = (lang); if (uddiServiceBinding.lang != null) { bindingLang = TokenResolver.replaceTokens(uddiServiceBinding.lang, properties); } description bindingDescription = new description(); bindingDescription.lang = (bindingLang); bindingDescription.Value = (TokenResolver.replaceTokens(uddiServiceBinding.description, properties)); bindingTemplate.description = new description[] { (bindingDescription) }; accessPoint accessPoint = new accessPoint(); accessPoint.useType = (AccessPointType.wsdlDeployment.ToString()); if (!"".Equals(uddiServiceBinding.accessPointType)) { accessPoint.useType = (uddiServiceBinding.accessPointType); } if (!"".Equals(uddiServiceBinding.accessPoint)) { String endPoint = uddiServiceBinding.accessPoint; endPoint = TokenResolver.replaceTokens(endPoint, properties); log.debug("AccessPoint EndPoint=" + endPoint); accessPoint.Value = (endPoint); } else if (webServiceAnnotation != null && webServiceAnnotation.Location != null) { accessPoint.Value = (webServiceAnnotation.Location); } bindingTemplate.Item = (accessPoint); //tModelKeys on the binding if (!"".Equals(uddiServiceBinding.tModelKeys)) { String[] tModelKeys = uddiServiceBinding.tModelKeys.Split(','); foreach (String tModelKey in tModelKeys) { tModelInstanceInfo instanceInfo = new tModelInstanceInfo(); instanceInfo.tModelKey = (tModelKey); if (bindingTemplate.tModelInstanceDetails == null) { bindingTemplate.tModelInstanceDetails = (new tModelInstanceInfo[] { instanceInfo }); } List<tModelInstanceInfo> l = new List<tModelInstanceInfo>(); l.AddRange(bindingTemplate.tModelInstanceDetails); l.Add(instanceInfo); bindingTemplate.tModelInstanceDetails = l.ToArray(); } } //categoryBag on the binding if (!"".Equals(uddiServiceBinding.categoryBag)) { categoryBag categoryBag = parseCategoryBag(uddiServiceBinding.categoryBag); bindingTemplate.categoryBag = (categoryBag); } } else { log.error("Missing UDDIServiceBinding annotation in class " + classWithAnnotations); } return bindingTemplate; }
internal static LogicalMethodInfo[] GetMethods(Type type) { if (type.IsInterface) { throw new InvalidOperationException(Res.GetString(Res.NeedConcreteType, type.FullName)); } ArrayList list = new ArrayList(); MethodInfo[] methods = type.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic); Hashtable unique = new Hashtable(); Hashtable methodInfos = new Hashtable(); for (int i = 0; i < methods.Length; i++) { Type declaringType = methods[i].DeclaringType; if (declaringType == typeof(object)) { continue; } if (declaringType == typeof(WebService)) { continue; } string signature = methods[i].ToString(); MethodInfo declaration = FindInterfaceMethodInfo(declaringType, signature); WebServiceBindingAttribute binding = null; if (declaration != null) { object[] attrs = declaration.DeclaringType.GetCustomAttributes(typeof(WebServiceBindingAttribute), false); if (attrs.Length > 0) { if (attrs.Length > 1) { throw new ArgumentException(Res.GetString(Res.OnlyOneWebServiceBindingAttributeMayBeSpecified1, declaration.DeclaringType.FullName), "type"); } binding = (WebServiceBindingAttribute)attrs[0]; if (binding.Name == null || binding.Name.Length == 0) { binding.Name = declaration.DeclaringType.Name; } } else { declaration = null; } } else if (!methods[i].IsPublic) { continue; } WebMethodAttribute attribute = WebMethodReflector.GetAttribute(methods[i], declaration); if (attribute == null) { continue; } WebMethod webMethod = new WebMethod(declaration, binding, attribute); methodInfos.Add(methods[i], webMethod); MethodInfo method = (MethodInfo)unique[signature]; if (method == null) { unique.Add(signature, methods[i]); list.Add(methods[i]); } else { if (method.DeclaringType.IsAssignableFrom(methods[i].DeclaringType)) { unique[signature] = methods[i]; list[list.IndexOf(method)] = methods[i]; } } } return(LogicalMethodInfo.Create((MethodInfo[])list.ToArray(typeof(MethodInfo)), LogicalMethodTypes.Async | LogicalMethodTypes.Sync, methodInfos)); }
LogicalMethodInfo(MethodInfo beginMethodInfo, MethodInfo endMethodInfo, WebMethod webMethod) { this.methodInfo = beginMethodInfo; this.endMethodInfo = endMethodInfo; methodName = beginMethodInfo.Name.Substring(5); if (webMethod != null) { this.binding = webMethod.binding; this.attribute = webMethod.attribute; this.declaration = webMethod.declaration; } ParameterInfo[] beginParamInfos = beginMethodInfo.GetParameters(); if (beginParamInfos.Length < 2 || beginParamInfos[beginParamInfos.Length - 1].ParameterType != typeof(object) || beginParamInfos[beginParamInfos.Length - 2].ParameterType != typeof(AsyncCallback)) { throw new InvalidOperationException(Res.GetString(Res.WebMethodMissingParams, beginMethodInfo.DeclaringType.FullName, beginMethodInfo.Name, typeof(AsyncCallback).FullName, typeof(object).FullName)); } stateParam = beginParamInfos[beginParamInfos.Length - 1]; callbackParam = beginParamInfos[beginParamInfos.Length - 2]; inParams = GetInParameters(beginMethodInfo, beginParamInfos, 0, beginParamInfos.Length - 2, true); ParameterInfo[] endParamInfos = endMethodInfo.GetParameters(); resultParam = endParamInfos[0]; outParams = GetOutParameters(endMethodInfo, endParamInfos, 1, endParamInfos.Length - 1, true); parameters = new ParameterInfo[inParams.Length + outParams.Length]; inParams.CopyTo(parameters, 0); outParams.CopyTo(parameters, inParams.Length); retType = endMethodInfo.ReturnType; isVoid = retType == typeof(void); attributes = new Hashtable(); }
internal ReflectedBinding(WebServiceBindingAttribute bindingAttr) { this.bindingAttr = bindingAttr; }
internal WebMethod(MethodInfo declaration, WebServiceBindingAttribute binding, WebMethodAttribute attribute) { this.declaration = declaration; this.binding = binding; this.attribute = attribute; }
public BindingInfo (WebServiceBindingAttribute at, string ns) { Name = at.Name; Namespace = at.Namespace; if (Namespace == "") Namespace = ns; Location = at.Location; }
internal static LogicalMethodInfo[] GetMethods(Type type) { if (type.IsInterface) { throw new InvalidOperationException(Res.GetString("NeedConcreteType", new object[] { type.FullName })); } ArrayList list = new ArrayList(); MethodInfo[] methods = type.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); Hashtable hashtable = new Hashtable(); Hashtable declarations = new Hashtable(); for (int i = 0; i < methods.Length; i++) { Type declaringType = methods[i].DeclaringType; if ((declaringType != typeof(object)) && (declaringType != typeof(WebService))) { string signature = methods[i].ToString(); MethodInfo declaration = FindInterfaceMethodInfo(declaringType, signature); WebServiceBindingAttribute binding = null; if (declaration != null) { object[] customAttributes = declaration.DeclaringType.GetCustomAttributes(typeof(WebServiceBindingAttribute), false); if (customAttributes.Length > 0) { if (customAttributes.Length > 1) { throw new ArgumentException(Res.GetString("OnlyOneWebServiceBindingAttributeMayBeSpecified1", new object[] { declaration.DeclaringType.FullName }), "type"); } binding = (WebServiceBindingAttribute)customAttributes[0]; if ((binding.Name == null) || (binding.Name.Length == 0)) { binding.Name = declaration.DeclaringType.Name; } } else { declaration = null; } } else if (!methods[i].IsPublic) { continue; } WebMethodAttribute attribute = GetAttribute(methods[i], declaration); if (attribute != null) { WebMethod method = new WebMethod(declaration, binding, attribute); declarations.Add(methods[i], method); MethodInfo info2 = (MethodInfo)hashtable[signature]; if (info2 == null) { hashtable.Add(signature, methods[i]); list.Add(methods[i]); } else if (info2.DeclaringType.IsAssignableFrom(methods[i].DeclaringType)) { hashtable[signature] = methods[i]; list[list.IndexOf(info2)] = methods[i]; } } } } return(LogicalMethodInfo.Create((MethodInfo[])list.ToArray(typeof(MethodInfo)), LogicalMethodTypes.Async | LogicalMethodTypes.Sync, declarations)); }