Exemplo n.º 1
0
            internal void Resolve(StringBuilder sb){
                Util.Log("RealSchemaType.Resolve "+_type);             
                sb.Length = 0;

                // Check if this is a suds type
                bool bSUDSType = IsSUDSType;


                // Resolve base type eliminating system defined roots of the class heirarchy

                Type baseType = _type.BaseType;
                if (IsNotSystemDefinedRoot(_type, baseType))
                {                    
                    Util.Log("RealSchemaType.Resolve Not System Defined root "+baseType);                                                     
                    XMLNamespace xns = _WsdlGenerator.GetNamespace(baseType);
                    Debug.Assert(xns != null, "Namespace should have been found");
                    sb.Append(xns.Prefix);
                    sb.Append(':');
                    sb.Append(baseType.Name);
                    BaseName = sb.ToString();
                    if (bSUDSType)
                        _xns.DependsOnSUDSNS(xns);
                    Type ltype= _type; 
                    Type lbaseType = ltype.BaseType;
                    while(lbaseType != null && IsNotSystemDefinedRoot(ltype, lbaseType))
                    {
                        if (_typeToServiceEndpoint != null && !_typeToServiceEndpoint.ContainsKey(lbaseType.Name) && _typeToServiceEndpoint.ContainsKey(ltype.Name))
                        {
                            // type contains endpoints, but baseType doesn't, so assign the type's endpoints to the baseType.
                            // This is needed when a child has endpoints but the parent doesn't. A cast to the parent won't 
                            // find the object's endpoint
                            _typeToServiceEndpoint[lbaseType.Name] = _typeToServiceEndpoint[ltype.Name];
                        }
                        ltype = lbaseType;
                        lbaseType = ltype.BaseType;
                    }

                    Util.Log("RealSchemaType.Resolve Not System Defined root BaseName "+BaseName);                                 
                }

                // The element definition of this type depends on itself
                _xns.DependsOnSchemaNS(_xns, false);

                if (bSUDSType)
                {
                    Util.Log("RealSchemaType.Resolve AddRealSUDSType  "+_type);                                                     
                    _xns.AddRealSUDSType(this);

                    // Resolve interfaces introduced by this type
                    if (_iFaces.Length > 0)
                    {
                        _implIFaces = new String[_iFaces.Length];
                        for (int i=0;i<_iFaces.Length;i++)
                        {
                            String ns;
                            Assembly assem;
                            Util.Log("RealSchemaType.Resolve iFace  "+_iFaces[i].Name);                                                                                     
                            bool bInteropType = WsdlGenerator.GetNSAndAssembly(_iFaces[i], out ns, out assem);
                            XMLNamespace xns = _xns.LookupSchemaNamespace(ns, assem);
                            Debug.Assert(xns != null, "SchemaType should have been found");
                            sb.Length = 0;
                            sb.Append(xns.Prefix);
                            sb.Append(':');
                            sb.Append(_iFaces[i].Name);
                            _implIFaces[i] = sb.ToString();
                            _xns.DependsOnSUDSNS(xns);
                        }
                    }

                    // Resolve methods introduced by this type
                    if (_methods.Length > 0)
                    {
                        String useNS = null;
                        if (_xns.IsInteropType)
                            useNS = _xns.Name;
                        else
                        {
                            sb.Length = 0;
                            WsdlGenerator.QualifyName(sb, _xns.Name, Name);
                            useNS = sb.ToString();
                        }
                        XMLNamespace methodXNS = _xns.LookupSchemaNamespace(useNS, _xns.Assem);
                        Debug.Assert(methodXNS != null, "Namespace is null");
                        _xns.DependsOnSUDSNS(methodXNS);
                        _phony = new PhonySchemaType[_methods.Length];
                        for (int i=0;i<_methods.Length;i++)
                        {
                            // Process the request
                            MethodInfo method = _methods[i];
                            String methodRequestName = method.Name;

                            ParameterInfo[] parameters = method.GetParameters();
                            PhonySchemaType methodRequest = new PhonySchemaType(methodRequestName);

                            // Wsdl 
                            Util.Log("RealSchemaType.Resolve Wsdl  "+methodRequestName);
                            methodRequest._inParamTypes = new ArrayList(10); 
                            methodRequest._inParamNames = new ArrayList(10); 
                            methodRequest._outParamTypes = new ArrayList(10);
                            methodRequest._outParamNames = new ArrayList(10);
                            methodRequest._paramNamesOrder = new ArrayList(10);

                            int paramNameCnt = 0;
                            foreach (ParameterInfo param in parameters){
                                bool bmarshalIn = false;
                                bool bmarshalOut = false;
                                methodRequest._paramNamesOrder.Add(param.Name);
                                ParamInOut(param, out bmarshalIn, out bmarshalOut);

                                Type type = param.ParameterType;
                                String paramName = param.Name;
                                if (paramName == null || paramName.Length == 0)
                                    paramName = "param"+paramNameCnt++;

                                // Find the Wsdl type name

                                String stringType = TypeName(type, true, methodXNS);
                                // add to the method parameters
                                if (bmarshalIn)
                                {
                                    methodRequest._inParamNames.Add(paramName);
                                    methodRequest._inParamTypes.Add(stringType);
                                }

                                if (bmarshalOut)
                                {
                                    methodRequest._outParamNames.Add(paramName);
                                    methodRequest._outParamTypes.Add(stringType);
                                }
                            }


                            methodXNS.AddPhonySchemaType(methodRequest);
                            _phony[i] = methodRequest;
                            _methodTypes[2*i] = methodRequest.ElementName;

                            if (!RemotingServices.IsOneWay(method))
                            {
                                // Process response (look at custom attributes to get values

                                String returnName = null;
                                SoapMethodAttribute soapAttribute = (SoapMethodAttribute)InternalRemotingServices.GetCachedSoapAttribute(method);
                                if (soapAttribute.ReturnXmlElementName != null)
                                    returnName = soapAttribute.ReturnXmlElementName;
                                else
                                    returnName = "return";

                                String responseName = null;
                                if (soapAttribute.ResponseXmlElementName != null)
                                    responseName = soapAttribute.ResponseXmlElementName;
                                else
                                    responseName = methodRequestName + "Response";

                                PhonySchemaType methodResponse = new PhonySchemaType(responseName);

                                //Wsdl type
                                // out paramters alread processed above.
                                // return name stored in methodRequest PhonySchemaType
                                methodRequest._returnName = returnName;
                                Type returnType = method.ReturnType;

                                if (!((returnType == null) || (returnType == typeof(void))))
                                {
                                    methodRequest._returnType = TypeName(returnType, true, methodXNS);
                                }
                                methodXNS.AddPhonySchemaType(methodResponse);
                                _methodTypes[2*i+1] = methodResponse.ElementName;
                            }
                        }
                    }
                }

                // Resolve fields
                if (_fields != null)
                {
                    for (int i=0;i<_fields.Length;i++)
                    {
                        FieldInfo field = _fields[i];
                        Debug.Assert(!field.IsStatic, "Static field");
                        Type fieldType = field.FieldType;
                        if (fieldType == null)
                            fieldType = typeof(Object);
                        Util.Log("RealSchemaType.Resolve fields  "+field.Name+" type "+fieldType);                                                                                                              
                        AddParticle(new SchemaElement(field.Name, fieldType, false, _xns));
                    }
                }

                // Resolve attribute elements                
                return;
            }
Exemplo n.º 2
0
            internal void AddPhonySchemaType(PhonySchemaType phType){
                Util.Log("XMLNamespace.AddPhonySchemaType "+phType.Name);                                                               
                PhonySchemaType overloadedType = LookupPhonySchemaType(phType.Name);
                if (overloadedType != null)
                    phType.ElementName = phType.Name + overloadedType.OverloadedType();
                _phonySchemaTypes.Add(phType);

                return;
            }
Exemplo n.º 3
0
			internal void Resolve(StringBuilder sb)
			{
				Util.Log("RealSchemaType.Resolve");             
				sb.Length = 0;

				// Check if this is a suds type
				bool bSUDSType = IsSUDSType;

				// Resolve base type eliminating system defined roots of the class heirarchy
				if (!_type.IsInterface &&
					  !_type.IsValueType &&
					  (_type.BaseType.BaseType != null) &&
					  (_type.BaseType != SdlGenerator.s_marshalByRefType) &&
					  (_type.BaseType != SdlGenerator.s_contextBoundType) &&
					  (_type.BaseType != SdlGenerator.s_remotingClientProxyType) &&
					  ((_type.IsCOMObject == false) ||
					   (_type.BaseType.BaseType.IsCOMObject == true)))
				{
					String ns;
					Assembly assem;
					Util.Log("RealSchemaType.Resolve Not System Defined root "+_type.BaseType);                                 
					bool InteropType = SdlGenerator.GetNSAndAssembly(_type.BaseType, out ns, out assem);
					XMLNamespace xns = _xns.LookupSchemaNamespace(ns, assem);
					Debug.Assert(xns != null, "Namespace should have been found");
					sb.Append(xns.Prefix);
					sb.Append(':');
					sb.Append(_type.BaseType.Name);
					BaseName = sb.ToString();
					if (bSUDSType)
						_xns.DependsOnSUDSNS(xns);
				}

				// The element definition of this type depends on itself
				_xns.DependsOnSchemaNS(_xns);

				if (bSUDSType)
				{
					Util.Log("RealSchemaType.Resolve AddRealSUDSType  "+_type);                                                     
					_xns.AddRealSUDSType(this);

					// Resolve interfaces introduced by this type
					if (_iFaces.Length > 0)
					{
						_implIFaces = new String[_iFaces.Length];
						for (int i=0;i<_iFaces.Length;i++)
						{
							String ns;
							Assembly assem;
							Util.Log("RealSchemaType.Resolve iFace  "+_iFaces[i].Name);                                                                                     
							bool bInteropType = SdlGenerator.GetNSAndAssembly(_iFaces[i], out ns, out assem);
							XMLNamespace xns = _xns.LookupSchemaNamespace(ns, assem);
							Debug.Assert(xns != null, "SchemaType should have been found");
							sb.Length = 0;
							sb.Append(xns.Prefix);
							sb.Append(':');
							sb.Append(_iFaces[i].Name);
							_implIFaces[i] = sb.ToString();
							_xns.DependsOnSUDSNS(xns);
						}
					}

					// Resolve methods introduced by this type
					if (_methods.Length > 0)
					{
						String useNS = null;
						if (_xns.IsInteropType)
							useNS = _xns.Name;
						else
						{
							sb.Length = 0;
							sb.Append(_xns.Name);
							sb.Append('.');
							sb.Append(Name);
							useNS = sb.ToString();
						}
						XMLNamespace methodXNS = _xns.LookupSchemaNamespace(useNS, _xns.Assem);
						Debug.Assert(methodXNS != null, "Namespace is null");
						_xns.DependsOnSUDSNS(methodXNS);
						for (int i=0;i<_methods.Length;i++)
						{
							// Process the request
							MethodInfo method = _methods[i];
							String methodRequestName = method.Name;
							Util.Log("RealSchemaType.Resolve Phony  "+methodRequestName);                                                                                                                   
							PhonySchemaType methodRequest = new PhonySchemaType(methodRequestName);
							ParameterInfo[] parameters = method.GetParameters();
							for (int j=0;j<parameters.Length;j++)
							{
								ParameterInfo parameter = parameters[j];
								if (!parameter.IsOut)
									methodRequest.AddParticle(new SchemaElement(parameter.Name,
										parameter.ParameterType,
										false, methodXNS));
							}
							methodXNS.AddPhonySchemaType(methodRequest);
							_methodTypes[2*i] = methodRequest.ElementName;

							if (!RemotingServices.IsOneWay(method))
							{
								// Process response (look at custom attributes to get values

								String returnName = null;
								SoapMethodAttribute soapAttribute = (SoapMethodAttribute)InternalRemotingServices.GetCachedSoapAttribute(method);
								if (soapAttribute.ReturnXmlElementName != null)
									returnName = soapAttribute.ReturnXmlElementName;
								else
									returnName = "__return";

								String responseName = null;
								if (soapAttribute.ResponseXmlElementName != null)
									responseName = soapAttribute.ResponseXmlElementName;
								else
									responseName = methodRequestName + "Response";

								Util.Log("RealSchemaType.Resolve Phony  "+responseName);                                                                                                                    
								PhonySchemaType methodResponse = new PhonySchemaType(responseName);
								//  Handle a void method that has an out parameter. This can only
								//         be handled through parameterOrder attribute
								if (method.ReturnType.FullName != "System.Void")
									methodResponse.AddParticle(new SchemaElement(returnName,
										method.ReturnType,
										false, methodXNS));

								for (int j=0;j<parameters.Length;j++)
								{
									ParameterInfo parameter = parameters[j];
									/*if(!parameter.IsIn &&
									(parameter.ParameterType.IsByRef ||
									(!parameter.ParameterType.IsPrimitive &&
									parameter.ParameterType.FullName != "System.String")))*/
									if (parameter.IsOut || parameter.ParameterType.IsByRef)
										methodResponse.AddParticle(new SchemaElement(parameter.Name,
											parameter.ParameterType,
											false, methodXNS));
								}
								methodXNS.AddPhonySchemaType(methodResponse);
								_methodTypes[2*i+1] = methodResponse.ElementName;
							}
						}
					}
				}

				// Resolve fields
				if (_fields != null)
				{
					for (int i=0;i<_fields.Length;i++)
					{
						FieldInfo field = _fields[i];
						Debug.Assert(!field.IsStatic, "Static field");
						Type fieldType = field.FieldType;
						if (fieldType == null)
							fieldType = typeof(Object);
						Util.Log("RealSchemaType.Resolve fields  "+field.Name+" type "+fieldType);                                                                                                              
						AddParticle(new SchemaElement(field.Name, fieldType, false, _xns));
					}
				}

				// Resolve attribute elements
				if (_bStruct == false)
					AddAbstractElement(new SchemaAttribute("id", "xsd:ID"));

				return;
			}