public SoapTypeStubInfo(LogicalTypeInfo logicalTypeInfo) : base(logicalTypeInfo) { xmlImporter = new XmlReflectionImporter(); soapImporter = new SoapReflectionImporter(); if (typeof(SoapHttpClientProtocol).IsAssignableFrom(Type)) { if (Bindings.Count == 0 || ((BindingInfo)Bindings[0]).WebServiceBindingAttribute == null) { throw new InvalidOperationException("WebServiceBindingAttribute is required on proxy class '" + Type + "'."); } if (Bindings.Count > 1) { throw new InvalidOperationException("Only one WebServiceBinding attribute may be specified on type '" + Type + "'."); } } object [] o = Type.GetCustomAttributes(typeof(SoapDocumentServiceAttribute), false); if (o.Length == 1) { SoapDocumentServiceAttribute a = (SoapDocumentServiceAttribute)o [0]; ParameterStyle = a.ParameterStyle; SoapBindingStyle = SoapBindingStyle.Document; } else { o = Type.GetCustomAttributes(typeof(SoapRpcServiceAttribute), false); if (o.Length == 1) { SoapRpcServiceAttribute srs = (SoapRpcServiceAttribute)o [0]; ParameterStyle = SoapParameterStyle.Wrapped; SoapBindingStyle = SoapBindingStyle.Rpc; } else { ParameterStyle = SoapParameterStyle.Wrapped; SoapBindingStyle = SoapBindingStyle.Document; } } if (ParameterStyle == SoapParameterStyle.Default) { ParameterStyle = SoapParameterStyle.Wrapped; } xmlImporter.IncludeTypes(Type); soapImporter.IncludeTypes(Type); #if MONOTOUCH SoapExtensions = new SoapExtensionRuntimeConfig [2][]; #else SoapExtensions = SoapExtension.GetTypeExtensions(Type); #endif }
internal static bool ServiceDefaultIsEncoded(object soapServiceAttribute) { if (soapServiceAttribute == null) { return(false); } SoapDocumentServiceAttribute documentService = soapServiceAttribute as SoapDocumentServiceAttribute; if (documentService == null // soapServiceAttribute is SoapRpcServiceAttribute || documentService.Use == SoapBindingUse.Encoded) { return(true); } return(false); }
public LogicalTypeInfo(Type t) { this.Type = t; object [] o = Type.GetCustomAttributes(typeof(WebServiceAttribute), false); if (o.Length == 1) { WebServiceAttribute a = (WebServiceAttribute)o [0]; WebServiceName = (a.Name != string.Empty) ? a.Name : Type.Name; WebServiceNamespace = (a.Namespace != string.Empty) ? a.Namespace : WebServiceAttribute.DefaultNamespace; Description = a.Description; } else { WebServiceName = Type.Name; WebServiceNamespace = WebServiceAttribute.DefaultNamespace; } // Determine the namespaces for literal and encoded schema types bindingUse = SoapBindingUse.Literal; o = t.GetCustomAttributes(typeof(SoapDocumentServiceAttribute), true); if (o.Length > 0) { SoapDocumentServiceAttribute at = (SoapDocumentServiceAttribute)o[0]; bindingUse = at.Use; if (bindingUse == SoapBindingUse.Default) { bindingUse = SoapBindingUse.Literal; } routingStyle = at.RoutingStyle; } else if (t.GetCustomAttributes(typeof(SoapRpcServiceAttribute), true).Length > 0) { o = t.GetCustomAttributes(typeof(SoapRpcServiceAttribute), true); SoapRpcServiceAttribute at = (SoapRpcServiceAttribute)o[0]; #if NET_2_0 bindingUse = at.Use; #else bindingUse = SoapBindingUse.Encoded; #endif routingStyle = at.RoutingStyle; if (bindingUse == SoapBindingUse.Default) { bindingUse = SoapBindingUse.Encoded; } } else { routingStyle = SoapServiceRoutingStyle.SoapAction; } string sep = WebServiceNamespace.EndsWith("/") ? "" : "/"; WebServiceAbstractNamespace = WebServiceNamespace + sep + "AbstractTypes"; #if NET_2_0 MethodInfo [] type_methods; if (typeof(WebClientProtocol).IsAssignableFrom(Type)) { type_methods = Type.GetMethods(BindingFlags.Instance | BindingFlags.Public); } else { MethodInfo [] all_type_methods = Type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); ArrayList list = new ArrayList(all_type_methods.Length); foreach (MethodInfo mi in all_type_methods) { if (mi.IsPublic && mi.GetCustomAttributes(typeof(WebMethodAttribute), false).Length > 0) { list.Add(mi); } else { foreach (Type ifaceType in Type.GetInterfaces()) { if (ifaceType.GetCustomAttributes(typeof(WebServiceBindingAttribute), false).Length > 0) { MethodInfo found = FindInInterface(ifaceType, mi); if (found != null) { if (found.GetCustomAttributes(typeof(WebMethodAttribute), false).Length > 0) { list.Add(found); } break; } } } } } type_methods = (MethodInfo [])list.ToArray(typeof(MethodInfo)); } #else MethodInfo [] type_methods = Type.GetMethods(BindingFlags.Instance | BindingFlags.Public); #endif logicalMethods = LogicalMethodInfo.Create(type_methods, LogicalMethodTypes.Sync); }