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(); }
/// <summary> /// Sets the request header namespace in outgoing Soap Requests. /// </summary> /// <param name="signature">The service creation parameters.</param> /// <param name="service">The service object for which RequestHeader /// needs to be patched.</param> private static void SetRequestHeaderNameSpace(DfaServiceSignature signature, AdsClient service) { // Set the header namespace prefix. For all /cm services, the members // shouldn't have xmlns. For all other services, the members should have // /cm as xmlns. object[] attributes = service.GetType().GetCustomAttributes(false); foreach (object attribute in attributes) { if (attribute is WebServiceBindingAttribute) { WebServiceBindingAttribute binding = (WebServiceBindingAttribute)attribute; string xmlns = binding.Namespace; RequestHeader svcRequestHeader = null; PropertyInfo propInfo = service.GetType().GetProperty("RequestHeader"); if (propInfo != null) { svcRequestHeader = (RequestHeader)propInfo.GetValue(service, null); if (svcRequestHeader != null) { PropertyInfo wsPropInfo = svcRequestHeader.GetType().GetProperty("TargetNamespace"); if (wsPropInfo != null) { wsPropInfo.SetValue(svcRequestHeader, xmlns, null); } } } } } }
public void UsesExistingWebServiceBindingAttributeWithDecoratedClass() { wse.ObjectName = "UsesExistingWebServiceBindingAttributeWithDecoratedClass"; wse.TargetName = "decoratedService"; wse.AfterPropertiesSet(); Type proxyType = wse.GetExportedType(); object[] attrs = proxyType.GetCustomAttributes(typeof(WebServiceBindingAttribute), true); Assert.IsNotEmpty(attrs); Assert.AreEqual(1, attrs.Length); WebServiceBindingAttribute wsba = attrs[0] as WebServiceBindingAttribute; Assert.AreEqual(WsiProfiles.None, wsba.ConformsTo); }
public void CreatesDefaultWebServiceBindingAttribute() { wse.ObjectName = "CreatesDefaultWebServiceBindingAttribute"; wse.TargetName = "noDecoratedService"; wse.AfterPropertiesSet(); Type proxyType = wse.GetExportedType(); object[] attrs = proxyType.GetCustomAttributes(typeof(WebServiceBindingAttribute), true); Assert.IsNotEmpty(attrs); Assert.AreEqual(1, attrs.Length); WebServiceBindingAttribute wsba = attrs[0] as WebServiceBindingAttribute; Assert.AreEqual(WsiProfiles.BasicProfile1_1, wsba.ConformsTo); }
public void DocumentLiteralWithDefaultConfig() { WebServiceProxyFactory wspf = new WebServiceProxyFactory(); wspf.ServiceUri = new AssemblyResource("assembly://Spring.Services.Tests/Spring.Data.Spring.Web.Services/document-literal.wsdl"); wspf.ServiceInterface = typeof(IHelloWorld); wspf.AfterPropertiesSet(); object proxy = wspf.GetObject(); Assert.IsNotNull(proxy); Type proxyType = proxy.GetType(); Assert.IsTrue(proxy is IHelloWorld); Assert.IsTrue(proxy is SoapHttpClientProtocol); object[] typeAttrs = proxyType.GetCustomAttributes(typeof(WebServiceBindingAttribute), false); Assert.IsTrue(typeAttrs.Length > 0); WebServiceBindingAttribute wsba = (WebServiceBindingAttribute)typeAttrs[0]; Assert.AreEqual("HelloWorldServiceSoap", wsba.Name); Assert.AreEqual("http://www.springframwework.net", wsba.Namespace); MethodInfo sayHelloWorldMethod = proxyType.GetMethod("SayHelloWorld"); Assert.IsNotNull(sayHelloWorldMethod); object[] sdmaAttrs = sayHelloWorldMethod.GetCustomAttributes(typeof(SoapDocumentMethodAttribute), false); Assert.IsTrue(sdmaAttrs.Length > 0); SoapDocumentMethodAttribute sdma = (SoapDocumentMethodAttribute)sdmaAttrs[0]; Assert.AreEqual("http://www.springframwework.net/SayHelloWorld", sdma.Action); Assert.AreEqual(SoapParameterStyle.Wrapped, sdma.ParameterStyle); Assert.AreEqual(string.Empty, sdma.Binding); Assert.AreEqual(false, sdma.OneWay); Assert.AreEqual(string.Empty, sdma.RequestElementName); Assert.AreEqual("http://www.springframwework.net", sdma.RequestNamespace); Assert.AreEqual(string.Empty, sdma.ResponseElementName); Assert.AreEqual("http://www.springframwework.net", sdma.ResponseNamespace); Assert.AreEqual(SoapBindingUse.Literal, sdma.Use); // Try to instantiate the proxy type ObjectUtils.InstantiateType(proxyType); }
/// <include file='doc\ClientProtocol.uex' path='docs/doc[@for="HttpWebClientProtocol.GenerateXmlMappings"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public static bool GenerateXmlMappings(Type type, ArrayList mappings) { if (typeof(SoapHttpClientProtocol).IsAssignableFrom(type)) { WebServiceBindingAttribute binding = WebServiceBindingReflector.GetAttribute(type); if (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. string serviceNamespace = binding.Namespace; bool serviceDefaultIsEncoded = SoapReflector.ServiceDefaultIsEncoded(type); ArrayList soapMethodList = new ArrayList(); SoapClientType.GenerateXmlMappings(type, soapMethodList, serviceNamespace, serviceDefaultIsEncoded, mappings); return(true); } return(false); }
public static bool GenerateXmlMappings(Type type, ArrayList mappings) { if (!typeof(SoapHttpClientProtocol).IsAssignableFrom(type)) { return(false); } WebServiceBindingAttribute attribute = WebServiceBindingReflector.GetAttribute(type); if (attribute == null) { throw new InvalidOperationException(Res.GetString("WebClientBindingAttributeRequired")); } string serviceNamespace = attribute.Namespace; bool serviceDefaultIsEncoded = SoapReflector.ServiceDefaultIsEncoded(type); ArrayList soapMethodList = new ArrayList(); SoapClientType.GenerateXmlMappings(type, soapMethodList, serviceNamespace, serviceDefaultIsEncoded, mappings); return(true); }
public BindingInfo(WebServiceBindingAttribute at, string name, string ns) { if (at != null) { Name = at.Name; Namespace = at.Namespace; Location = at.Location; WebServiceBindingAttribute = at; } if (Name == null || Name.Length == 0) { Name = name; } if (Namespace == null || Namespace.Length == 0) { Namespace = ns; } }
/// <summary> /// Fix the request header namespace in outgoing Soap Requests, so that /// cross namespace requests can work properly. /// </summary> /// <param name="signature">The service creation parameters.</param> /// <param name="service">The service object for which RequestHeader /// needs to be patched.</param> private static void FixRequestHeaderNameSpace(AdWordsServiceSignature signature, AdsClient service) { // Set the header namespace prefix. For all /cm services, the members // shouldn't have xmlns. For all other services, the members should have // /cm as xmlns. object[] attributes = service.GetType().GetCustomAttributes(false); foreach (object attribute in attributes) { if (attribute is WebServiceBindingAttribute) { WebServiceBindingAttribute binding = (WebServiceBindingAttribute)attribute; string delimiter = "/api/adwords/"; string xmlns = String.Join("", new String[] { binding.Namespace.Substring(0, binding.Namespace.IndexOf(delimiter) + delimiter.Length), "cm/", signature.Version }); if (xmlns == binding.Namespace) { xmlns = ""; } RequestHeader svcRequestHeader = null; PropertyInfo propInfo = service.GetType().GetProperty("RequestHeader"); if (propInfo != null) { svcRequestHeader = (RequestHeader)propInfo.GetValue(service, null); if (svcRequestHeader != null) { PropertyInfo wsPropInfo = svcRequestHeader.GetType().GetProperty("TargetNamespace"); if (wsPropInfo != null) { wsPropInfo.SetValue(svcRequestHeader, xmlns, null); } } } } } }
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(); }
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 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 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 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); } }
internal ReflectedBinding(WebServiceBindingAttribute bindingAttr) { this.bindingAttr = bindingAttr; }
public businessService readServiceAnnotations(String classWithAnnotations, Properties properties) { Type t = Type.GetType(classWithAnnotations, false, true); if (t != null) { businessService service = new businessService(); object[] attrib = t.GetCustomAttributes(typeof(UDDIService), true); object[] ws = t.GetCustomAttributes(typeof(System.Web.Services.WebServiceBindingAttribute), true); WebServiceBindingAttribute webServiceAnnotation = null; if (ws != null && ws.Length > 0) { webServiceAnnotation = ((WebServiceBindingAttribute[])ws)[0]; } if (attrib != null && attrib.Length > 0) { UDDIService[] bits = attrib as UDDIService[]; UDDIService uddiService = bits[0]; name n = new name(); n.lang = uddiService.lang; service.businessKey = (TokenResolver.replaceTokens(uddiService.businessKey, properties)); service.serviceKey = (TokenResolver.replaceTokens(uddiService.serviceKey, properties)); if (!"".Equals(uddiService.serviceName, StringComparison.CurrentCultureIgnoreCase)) { n.Value = (TokenResolver.replaceTokens(uddiService.serviceName, properties)); } else if (webServiceAnnotation != null && !"".Equals(webServiceAnnotation.Name)) { n.Value = (webServiceAnnotation.Name); } else { n.Value = (classWithAnnotations); } service.name = new name[] { n }; description d = new description(); d.lang = (uddiService.lang); d.Value = (TokenResolver.replaceTokens(uddiService.description, properties)); service.description = new description[] { d }; //categoryBag on the service if (!"".Equals(uddiService.categoryBag)) { categoryBag categoryBag = parseCategoryBag(uddiService.categoryBag); service.categoryBag = (categoryBag); } //bindingTemplate on service bindingTemplate bindingTemplate = parseServiceBinding(classWithAnnotations, uddiService.lang, webServiceAnnotation, properties); if (bindingTemplate != null) { bindingTemplate.serviceKey = (service.serviceKey); if (service.bindingTemplates == null) { service.bindingTemplates = new bindingTemplate[] { bindingTemplate }; } else { List <bindingTemplate> l = new List <bindingTemplate>(); l.AddRange(service.bindingTemplates); l.Add(bindingTemplate); service.bindingTemplates = l.ToArray(); } } return(service); } else { log.error("Missing UDDIService annotation in class " + classWithAnnotations); } } log.error("Unable to load type " + classWithAnnotations); return(null); }
internal void Reflect() { emptyBinding = false; Hashtable bindings = new Hashtable(); Hashtable reflectedBindings = new Hashtable(); for (int i = 0; i < reflector.Methods.Length; i++) { MoveToMethod(reflector.Methods[i]); string bindingName = ReflectMethodBinding(); if (bindingName == null) { bindingName = string.Empty; } ReflectedBinding reflectedBinding = (ReflectedBinding)reflectedBindings[bindingName]; if (reflectedBinding == null) { reflectedBinding = new ReflectedBinding(); reflectedBinding.bindingAttr = WebServiceBindingReflector.GetAttribute(method, bindingName); if (reflectedBinding.bindingAttr == null || (bindingName.Length == 0 && reflectedBinding.bindingAttr.Location.Length > 0)) { reflectedBinding.bindingAttr = new WebServiceBindingAttribute(); } reflectedBindings.Add(bindingName, reflectedBinding); } if (reflectedBinding.bindingAttr.Location.Length == 0) { if (reflectedBinding.methodList == null) { reflectedBinding.methodList = new ArrayList(); } reflectedBinding.methodList.Add(method); bindings[reflectedBinding.bindingAttr.Name] = method; } else { AddImport(reflectedBinding.bindingAttr.Namespace, reflectedBinding.bindingAttr.Location); } } foreach (ReflectedBinding reflectedBinding in reflectedBindings.Values) { ReflectBinding(reflectedBinding); } // Only check for empty binding if we do not have real bindings if (reflectedBindings.Count == 0) { // It should be possible to get the value for WebReference.ServiceLocationUrl even if the web service has no web methods. // This is a common scenario for Whitehorse during the early stages of development when a user is defining the web // components and their inter-connections, but not the details of whatmethods will be present on each web service. // get all WebServiceBindings emptyBinding = true; ReflectedBinding binding = null; object[] attrs = ServiceType.GetCustomAttributes(typeof(WebServiceBindingAttribute), false); for (int i = 0; i < attrs.Length; i++) { WebServiceBindingAttribute bindingAttribute = (WebServiceBindingAttribute)attrs[i]; if (bindings[bindingAttribute.Name] != null) { continue; } if (binding != null) { binding = null; break; } binding = new ReflectedBinding(bindingAttribute); } if (binding != null) { ReflectBinding(binding); } } Type[] interfaces = ServiceType.GetInterfaces(); // iterate through all the interfaces for this type foreach (Type bindingInterface in interfaces) { object[] attrs = bindingInterface.GetCustomAttributes(typeof(WebServiceBindingAttribute), false); for (int i = 0; i < attrs.Length; i++) { WebServiceBindingAttribute bindingAttribute = (WebServiceBindingAttribute)attrs[i]; if (bindings[bindingAttribute.Name] != null) { continue; } ReflectBinding(new ReflectedBinding(bindingAttribute)); } } ReflectDescription(); }
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 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 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); } }