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);
		}
Example #2
0
		public SoapTypeStubInfo (LogicalTypeInfo logicalTypeInfo)
		: base (logicalTypeInfo)
		{
			xmlImporter = new XmlReflectionImporter ();
			soapImporter = new SoapReflectionImporter ();
			
			object [] o;

			o = Type.GetCustomAttributes (typeof (WebServiceBindingAttribute), false);
			
			if (typeof (SoapHttpClientProtocol).IsAssignableFrom (Type))
			{
				if (o.Length == 0)
					throw new InvalidOperationException ("WebServiceBindingAttribute is required on proxy class '" + Type + "'.");
				if (o.Length > 1)
					throw new InvalidOperationException ("Only one WebServiceBinding attribute may be specified on type '" + Type + "'.");
					
				// Remove the default binding, it is not needed since there is always
				// a binding attribute.
				Bindings.Clear ();
			}
				
			foreach (WebServiceBindingAttribute at in o)
				AddBinding (new BindingInfo (at, LogicalType.WebServiceNamespace));

			o = Type.GetCustomAttributes (typeof (SoapDocumentServiceAttribute), false);
			if (o.Length == 1){
				SoapDocumentServiceAttribute a = (SoapDocumentServiceAttribute) o [0];

				ParameterStyle = a.ParameterStyle;
				RoutingStyle = a.RoutingStyle;
				Use = a.Use;
				SoapBindingStyle = SoapBindingStyle.Document;
			} else {
				o = Type.GetCustomAttributes (typeof (SoapRpcServiceAttribute), false);
				if (o.Length == 1){
					SoapRpcServiceAttribute srs = (SoapRpcServiceAttribute) o [0];
					
					ParameterStyle = SoapParameterStyle.Wrapped;
					RoutingStyle = srs.RoutingStyle;
					Use = SoapBindingUse.Encoded;
					SoapBindingStyle = SoapBindingStyle.Rpc;
				} else {
					ParameterStyle = SoapParameterStyle.Wrapped;
					RoutingStyle = SoapServiceRoutingStyle.SoapAction;
					Use = SoapBindingUse.Literal;
					SoapBindingStyle = SoapBindingStyle.Document;
				}
			}
			
			if (ParameterStyle == SoapParameterStyle.Default) ParameterStyle = SoapParameterStyle.Wrapped;
			if (Use == SoapBindingUse.Default) Use = SoapBindingUse.Literal;
			
			xmlImporter.IncludeTypes (Type);
			soapImporter.IncludeTypes (Type);

			SoapExtensions = SoapExtension.GetTypeExtensions (Type);
		}
		public SoapRpcServiceAttribute ()
		{
			routingStyle = SoapServiceRoutingStyle.SoapAction;
		}
		public SoapDocumentServiceAttribute () 
		{
			paramStyle = SoapParameterStyle.Wrapped;
			routingStyle = SoapServiceRoutingStyle.SoapAction;
			use = SoapBindingUse.Literal;
		}