Inheritance: StringType
Example #1
0
        public static void ConvertTypesToSchemaToFile(Type [] types, SdlType sdlType, string path)
        {
            FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write);

            ConvertTypesToSchemaToStream(types, sdlType, fs);
            fs.Close();
        }
 internal WsdlGenerator(ServiceType[] serviceTypes, SdlType sdlType, TextWriter output)
 {
     this._typeToInteropNS = new Hashtable();
     this._textWriter = output;
     this._queue = new Queue();
     this._name = null;
     this._namespaces = new ArrayList();
     this._dynamicAssembly = null;
     this._serviceEndpoint = null;
     for (int i = 0; i < serviceTypes.Length; i++)
     {
         if ((serviceTypes[i] != null) && (serviceTypes[i].ObjectType.BaseType != null))
         {
             this.ProcessTypeAttributes(serviceTypes[i].ObjectType);
             this._queue.Enqueue(serviceTypes[i].ObjectType);
         }
         if (serviceTypes[i].Url != null)
         {
             if (this._typeToServiceEndpoint == null)
             {
                 this._typeToServiceEndpoint = new Hashtable(10);
             }
             if (this._typeToServiceEndpoint.ContainsKey(serviceTypes[i].ObjectType.Name))
             {
                 ((ArrayList) this._typeToServiceEndpoint[serviceTypes[i].ObjectType.Name]).Add(serviceTypes[i].Url);
             }
             else
             {
                 ArrayList list2 = new ArrayList(10);
                 list2.Add(serviceTypes[i].Url);
                 this._typeToServiceEndpoint[serviceTypes[i].ObjectType.Name] = list2;
             }
         }
     }
 }
 private bool ShouldIntercept(ITransportHeaders requestHeaders, out SdlType sdlType)
 {
     sdlType = SdlType.Sdl;
     string str = requestHeaders["__RequestVerb"] as string;
     string str2 = requestHeaders["__RequestUri"] as string;
     if (((str2 != null) && (str != null)) && str.Equals("GET"))
     {
         int startIndex = str2.LastIndexOf('?');
         if (startIndex == -1)
         {
             return false;
         }
         string strA = str2.Substring(startIndex).ToLower(CultureInfo.InvariantCulture);
         if ((string.CompareOrdinal(strA, "?sdl") == 0) || (string.CompareOrdinal(strA, "?sdlx") == 0))
         {
             sdlType = SdlType.Sdl;
             return true;
         }
         if (string.CompareOrdinal(strA, "?wsdl") == 0)
         {
             sdlType = SdlType.Wsdl;
             return true;
         }
     }
     return false;
 }
Example #4
0
        } // ConvertTypesToSchemaToFile


        /// <include file='doc\MetaData.uex' path='docs/doc[@for="MetaData.ConvertTypesToSchemaToFile2"]/*' />
        public static void ConvertTypesToSchemaToStream(ServiceType[] serviceTypes, SdlType sdlType, Stream outputStream)
        {
			Util.Log("MetaData.ConvertTypesToSchemaToStream 4");			
			TextWriter tw = new StreamWriter(outputStream, new UTF8Encoding(false, true));
            SUDSGenerator sgen = new SUDSGenerator(serviceTypes, sdlType, tw);
            sgen.Generate();
            tw.Flush();

        } // ConvertTypesToSchemaToStream
Example #5
0
 public static void ConvertTypesToSchemaToStream(Type[] types, SdlType sdlType, Stream outputStream)
 {
     ServiceType[] serviceTypes = new ServiceType[types.Length];
     for (int i = 0; i < types.Length; i++)
     {
         serviceTypes[i] = new ServiceType(types[i]);
     }
     ConvertTypesToSchemaToStream(serviceTypes, sdlType, outputStream);
 }
Example #6
0
		// Constructor
		internal SUDSGenerator(Type[] types, SdlType sdlType, TextWriter output, Assembly assembly, String url)
		{
			Util.Log("SUDSGenerator.SUDSGenerator 4 "+url);			
            if (sdlType == SdlType.Sdl)
                sdlGenerator = new SdlGenerator(types, sdlType, output, assembly, url);
            else
                wsdlGenerator = new WsdlGenerator(types, sdlType, output, assembly, url);
            this.sdlType =sdlType;
		}
Example #7
0
		internal SUDSGenerator(ServiceType[] serviceTypes, SdlType sdlType, TextWriter output)
		{
			Util.Log("SUDSGenerator.SUDSGenerator 5 ");
            if (sdlType == SdlType.Sdl)
                sdlGenerator = new SdlGenerator(serviceTypes, sdlType, output);
            else
                wsdlGenerator = new WsdlGenerator(serviceTypes, sdlType, output);
            this.sdlType = sdlType;
		}
Example #8
0
        } // ConvertTypesToSchemaToFile

        /// <include file='doc\MetaData.uex' path='docs/doc[@for="MetaData.ConvertTypesToSchemaToFile2"]/*' />
        public static void ConvertTypesToSchemaToStream(ServiceType[] serviceTypes, SdlType sdlType, Stream outputStream)
        {
            Util.Log("MetaData.ConvertTypesToSchemaToStream 4");
            TextWriter    tw   = new StreamWriter(outputStream, new UTF8Encoding(false, true));
            SUDSGenerator sgen = new SUDSGenerator(serviceTypes, sdlType, tw);

            sgen.Generate();
            tw.Flush();
        } // ConvertTypesToSchemaToStream
Example #9
0
        public static void ConvertTypesToSchemaToStream(Type [] types, SdlType sdlType, Stream outputStream)
        {
            ServiceType[] st = new ServiceType [types.Length];
            for (int n = 0; n < types.Length; n++)
            {
                st [n] = new ServiceType(types[n]);
            }

            ConvertTypesToSchemaToStream(st, sdlType, outputStream);
        }
Example #10
0
        public static void ConvertTypesToSchemaToStream(ServiceType[] serviceTypes, SdlType sdlType, Stream outputStream)
        {
            if (sdlType == SdlType.Sdl)
            {
                throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, CoreChannel.GetResourceString("Sdl generation is not supported"), new object[0]));
            }
            TextWriter output = new StreamWriter(outputStream, new UTF8Encoding(false, true));

            new SUDSGenerator(serviceTypes, sdlType, output).Generate();
            output.Flush();
        }
        } // ConvertTypesToSchemaToFile

        public static void ConvertTypesToSchemaToStream(Type[] types, SdlType sdlType, Stream outputStream)
        {
			Util.Log("MetaData.ConvertTypesToSchemaToFile 2 ");						

            ServiceType[] serviceTypes = new ServiceType[types.Length];
            for (int i=0; i<types.Length; i++)
                serviceTypes[i] = new ServiceType(types[i]);

            ConvertTypesToSchemaToStream(serviceTypes, sdlType, outputStream);

        } // ConvertTypesToSchemaToStream
Example #12
0
        } // ConvertTypesToSchemaToFile

        /// <include file='doc\MetaData.uex' path='docs/doc[@for="MetaData.ConvertTypesToSchemaToStream"]/*' />
        public static void ConvertTypesToSchemaToStream(Type[] types, SdlType sdlType, Stream outputStream)
        {
            Util.Log("MetaData.ConvertTypesToSchemaToFile 2 ");

            ServiceType[] serviceTypes = new ServiceType[types.Length];
            for (int i = 0; i < types.Length; i++)
            {
                serviceTypes[i] = new ServiceType(types[i]);
            }

            ConvertTypesToSchemaToStream(serviceTypes, sdlType, outputStream);
        } // ConvertTypesToSchemaToStream
Example #13
0
 internal SUDSGenerator(ServiceType[] serviceTypes, SdlType sdlType, TextWriter output)
 {
     Util.Log("SUDSGenerator.SUDSGenerator 5 ");
     if (sdlType == SdlType.Sdl)
     {
         sdlGenerator = new SdlGenerator(serviceTypes, sdlType, output);
     }
     else
     {
         wsdlGenerator = new WsdlGenerator(serviceTypes, sdlType, output);
     }
     this.sdlType = sdlType;
 }
        } // ConvertTypesToSchemaToFile


        public static void ConvertTypesToSchemaToStream(ServiceType[] serviceTypes, SdlType sdlType, Stream outputStream)
        {
            Util.Log("MetaData.ConvertTypesToSchemaToStream 4");			
            if (sdlType == SdlType.Sdl)
                throw new NotSupportedException(
                            String.Format(
                                CultureInfo.CurrentCulture, CoreChannel.GetResourceString("Sdl generation is not supported")));
		  TextWriter tw = new StreamWriter(outputStream, new UTF8Encoding(false, true));
            SUDSGenerator sgen = new SUDSGenerator(serviceTypes, sdlType, tw);
            sgen.Generate();
            tw.Flush();

        } // ConvertTypesToSchemaToStream
Example #15
0
        } // ConvertTypesToSchemaToFile


        public static void ConvertTypesToSchemaToStream(ServiceType[] serviceTypes, SdlType sdlType, Stream outputStream)
        {
            Util.Log("MetaData.ConvertTypesToSchemaToStream 4");			
            if (sdlType == SdlType.Sdl)
                throw new NotSupportedException(
                            String.Format(
                                CultureInfo.CurrentCulture, CoreChannel.GetResourceString("Sdl generation is not supported")));
		  TextWriter tw = new StreamWriter(outputStream, new UTF8Encoding(false, true));
            SUDSGenerator sgen = new SUDSGenerator(serviceTypes, sdlType, tw);
            sgen.Generate();
            tw.Flush();

        } // ConvertTypesToSchemaToStream
Example #16
0
 // Constructor
 internal SUDSGenerator(Type[] types, SdlType sdlType, TextWriter output, Assembly assembly, String url)
 {
     Util.Log("SUDSGenerator.SUDSGenerator 4 " + url);
     if (sdlType == SdlType.Sdl)
     {
         sdlGenerator = new SdlGenerator(types, sdlType, output, assembly, url);
     }
     else
     {
         wsdlGenerator = new WsdlGenerator(types, sdlType, output, assembly, url);
     }
     this.sdlType = sdlType;
 }
Example #17
0
        public static void ConvertTypesToSchemaToStream(ServiceType [] serviceTypes, SdlType sdlType, Stream outputStream)
        {
            MetaDataExporter exporter  = new MetaDataExporter();
            MemoryStream     memStream = new MemoryStream();

            StreamWriter  sw = new StreamWriter(memStream);
            XmlTextWriter tw = new XmlTextWriter(sw);

            exporter.ExportTypes(serviceTypes, sdlType, tw);
            tw.Flush();

            memStream.Position = 0;
            CopyStream(memStream, outputStream);
        }
Example #18
0
        } // ConvertTypesToSchemaToFile

        /// <include file='doc\MetaData.uex' path='docs/doc[@for="MetaData.ConvertTypesToSchemaToStream"]/*' />
        public static void ConvertTypesToSchemaToStream(Type[] types, SdlType sdlType, Stream outputStream)
        {
            Util.Log("MetaData.ConvertTypesToSchemaToFile 2 ");
            //    This should actually delegate to the version that accepts ServiceType once
            //   support for that is added in sudsgen.

            ServiceType[] serviceTypes = new ServiceType[types.Length];
            for (int i = 0; i < types.Length; i++)
            {
                serviceTypes[i] = new ServiceType(types[i]);
            }

            ConvertTypesToSchemaToStream(serviceTypes, sdlType, outputStream);
        } // ConvertTypesToSchemaToStream
Example #19
0
		// Constructor
		internal SdlGenerator(Type[] types, SdlType sdlType, TextWriter output)
		{
			Util.Log("SdlGenerator.SdlGenerator 2");
			_textWriter = output;
			_queue = new Queue();
			_name = null;
			_namespaces = new ArrayList();
			_dynamicAssembly = null;
			_serviceEndpoint = null;
			_sdlType = sdlType;
			for (int i=0;i<types.Length;i++)
			{
				if (types[i] != null)
				{
					if (types[i].BaseType != null)
						_queue.Enqueue(types[i]);
				}
			}
		}
        } // Properties


        // Should we intercept the call and return some SDL
        private bool ShouldIntercept(ITransportHeaders requestHeaders, out SdlType sdlType)
        {
            sdlType = SdlType.Sdl;

            String requestVerb = requestHeaders["__RequestVerb"] as String;
            String requestURI  = requestHeaders["__RequestUri"] as String;

            // http verb must be "GET" to return sdl (and request uri must be set)
            if ((requestURI == null) ||
                (requestVerb == null) || !requestVerb.Equals("GET"))
            {
                return(false);
            }

            // find last index of ? and look for "sdl" or "sdlx"
            int index = requestURI.LastIndexOf('?');

            if (index == -1)
            {
                return(false); // no query string
            }
            String queryString = requestURI.Substring(index).ToLower(CultureInfo.InvariantCulture);

            // sdl?
            if ((String.CompareOrdinal(queryString, "?sdl") == 0) ||
                (String.CompareOrdinal(queryString, "?sdlx") == 0))
            {
                sdlType = SdlType.Sdl;
                return(true);
            }

            // wsdl?
            if (String.CompareOrdinal(queryString, "?wsdl") == 0)
            {
                sdlType = SdlType.Wsdl;
                return(true);
            }

            return(false);
        } // ShouldIntercept
		public static void ConvertTypesToSchemaToStream (ServiceType [] serviceTypes, SdlType sdlType, Stream outputStream)
		{
			MetaDataExporter exporter = new MetaDataExporter ();
			MemoryStream memStream = new MemoryStream ();
			
			StreamWriter sw = new StreamWriter (memStream);
			XmlTextWriter tw = new XmlTextWriter (sw);

			exporter.ExportTypes (serviceTypes, sdlType, tw);
			tw.Flush ();
			
			memStream.Position = 0;
			CopyStream (memStream, outputStream);
		}
 internal SUDSGenerator(ServiceType[] serviceTypes, SdlType sdlType, TextWriter output)
 {
     Util.Log("SUDSGenerator.SUDSGenerator 5 ");
     wsdlGenerator = new WsdlGenerator(serviceTypes, sdlType, output);
     this.sdlType  = sdlType;
 }
        } // ShouldIntercept

        private void GenerateSdl(SdlType sdlType,
                                 IServerResponseChannelSinkStack sinkStack,
                                 ITransportHeaders requestHeaders,
                                 ITransportHeaders responseHeaders,
                                 out Stream outputStream)
        {
            if (!MetadataEnabled)
            {
                throw new RemotingException(CoreChannel.GetResourceString("Remoting_MetadataNotEnabled"));
            }

            String requestUri = requestHeaders[CommonTransportKeys.RequestUri] as String;
            String objectUri  = HttpChannelHelper.GetObjectUriFromRequestUri(requestUri);

            if (!RemoteApplicationMetadataEnabled &&
                (String.Compare(objectUri, "RemoteApplicationMetadata.rem", StringComparison.OrdinalIgnoreCase) == 0))
            {
                throw new RemotingException(CoreChannel.GetResourceString("Remoting_RemoteApplicationMetadataNotEnabled"));
            }

            // If the host header is present, we will use this in the generated uri's
            String hostName = (String)requestHeaders["Host"];

            if (hostName != null)
            {
                // filter out port number if present
                int index = hostName.IndexOf(':');
                if (index != -1)
                {
                    hostName = hostName.Substring(0, index);
                }
            }



            ServiceType[] types = null;

            if (String.Compare(objectUri, "RemoteApplicationMetadata.rem", StringComparison.OrdinalIgnoreCase) == 0)
            {
                // get the service description for all registered service types

                ActivatedServiceTypeEntry[] activatedTypes =
                    RemotingConfiguration.GetRegisteredActivatedServiceTypes();

                WellKnownServiceTypeEntry[] wellKnownTypes =
                    RemotingConfiguration.GetRegisteredWellKnownServiceTypes();

                // determine total number of types
                int typeCount = 0;

                if (activatedTypes != null)
                {
                    typeCount += activatedTypes.Length;
                }

                if (wellKnownTypes != null)
                {
                    typeCount += wellKnownTypes.Length;
                }

                types = new ServiceType[typeCount];

                // collect data
                int co = 0;
                if (activatedTypes != null)
                {
                    foreach (ActivatedServiceTypeEntry entry in activatedTypes)
                    {
                        types[co++] = new ServiceType(entry.ObjectType, null);
                    }
                }

                if (wellKnownTypes != null)
                {
                    foreach (WellKnownServiceTypeEntry entry in wellKnownTypes)
                    {
                        String[] urls = _receiver.GetUrlsForUri(entry.ObjectUri);
                        String   url  = urls[0];
                        if (hostName != null)
                        {
                            url = HttpChannelHelper.ReplaceMachineNameWithThisString(url, hostName);
                        }

                        types[co++] = new ServiceType(entry.ObjectType, url);
                    }
                }

                InternalRemotingServices.RemotingAssert(co == typeCount, "Not all types were processed.");
            }
            else
            {
                // get the service description for a particular object
                Type objectType = RemotingServices.GetServerTypeForUri(objectUri);
                if (objectType == null)
                {
                    throw new RemotingException(
                              String.Format(
                                  CultureInfo.CurrentCulture, "Object with uri '{0}' does not exist at server.",
                                  objectUri));
                }

                String[] urls = _receiver.GetUrlsForUri(objectUri);
                String   url  = urls[0];
                if (hostName != null)
                {
                    url = HttpChannelHelper.ReplaceMachineNameWithThisString(url, hostName);
                }

                types    = new ServiceType[1];
                types[0] = new ServiceType(objectType, url);
            }

            responseHeaders["Content-Type"] = "text/xml";

            bool bMemStream = false;

            outputStream = sinkStack.GetResponseStream(null, responseHeaders);
            if (outputStream == null)
            {
                outputStream = new MemoryStream(1024);
                bMemStream   = true;
            }

            MetaData.ConvertTypesToSchemaToStream(types, sdlType, outputStream);

            if (bMemStream)
            {
                outputStream.Position = 0;
            }
        } // GenerateXmlForUri
 // Methods
 public static void ConvertTypesToSchemaToFile(Type[] types, SdlType sdlType, string path)
 {
 }
 public static void ConvertTypesToSchemaToStream(ServiceType[] serviceTypes, SdlType sdlType, Stream outputStream)
 {
     if (sdlType == SdlType.Sdl)
     {
         throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, CoreChannel.GetResourceString("Sdl generation is not supported"), new object[0]));
     }
     TextWriter output = new StreamWriter(outputStream, new UTF8Encoding(false, true));
     new SUDSGenerator(serviceTypes, sdlType, output).Generate();
     output.Flush();
 }
Example #26
0
        public void ExportTypes(ServiceType[] servicetypes, SdlType sdltype, XmlTextWriter tw)
        {
            if (sdltype == SdlType.Sdl)                 // Obsolete, we don't support this
            {
                throw new NotSupportedException();
            }

            if (servicetypes.Length == 0)
            {
                return;
            }
            Type maint = servicetypes [0].ObjectType;

            Hashtable dataTypes = new Hashtable();
            ArrayList services  = new ArrayList();

            FindTypes(servicetypes, dataTypes, services);

            if (services.Count > 0)
            {
                maint = ((ServiceType)services[0]).ObjectType;
            }

            string serviceNs = GetXmlNamespace(maint, null);

            tw.Formatting = Formatting.Indented;
            tw.WriteStartElement("definitions", MetaData.WsdlNamespace);
            tw.WriteAttributeString("name", maint.Name);
            tw.WriteAttributeString("targetNamespace", serviceNs);
            tw.WriteAttributeString("xmlns", MetaData.XmlnsNamespace, MetaData.WsdlNamespace);
            tw.WriteAttributeString("xmlns", "tns", MetaData.XmlnsNamespace, serviceNs);
            tw.WriteAttributeString("xmlns", "xsd", MetaData.XmlnsNamespace, MetaData.SchemaNamespace);
            tw.WriteAttributeString("xmlns", "xsi", MetaData.XmlnsNamespace, MetaData.SchemaInstanceNamespace);
            tw.WriteAttributeString("xmlns", "suds", MetaData.XmlnsNamespace, MetaData.SudsNamespace);
            tw.WriteAttributeString("xmlns", "wsdl", MetaData.XmlnsNamespace, MetaData.WsdlNamespace);
            tw.WriteAttributeString("xmlns", "soapenc", MetaData.XmlnsNamespace, MetaData.SoapEncodingNamespace);
            tw.WriteAttributeString("xmlns", "soap", MetaData.XmlnsNamespace, MetaData.SoapNamespace);

            int nums = 0;

            foreach (DictionaryEntry entry in dataTypes)
            {
                string ns = (string)entry.Key;
                if (tw.LookupPrefix(ns) != null)
                {
                    continue;
                }
                tw.WriteAttributeString("xmlns", "ns" + nums, MetaData.XmlnsNamespace, ns);
                nums++;
            }

            // Schema

            if (dataTypes.Count > 0)
            {
                tw.WriteStartElement("types", MetaData.WsdlNamespace);
                foreach (DictionaryEntry entry in dataTypes)
                {
                    SchemaInfo sinfo = (SchemaInfo)entry.Value;
                    if (sinfo == null || sinfo.Types.Count == 0)
                    {
                        continue;
                    }

                    tw.WriteStartElement("s", "schema", MetaData.SchemaNamespace);
                    tw.WriteAttributeString("targetNamespace", (string)entry.Key);
                    tw.WriteAttributeString("elementFormDefault", "unqualified");
                    tw.WriteAttributeString("attributeFormDefault", "unqualified");

                    foreach (string ns in sinfo.Imports)
                    {
                        if (ns == (string)entry.Key)
                        {
                            continue;
                        }
                        tw.WriteStartElement("import", MetaData.SchemaNamespace);
                        tw.WriteAttributeString("namespace", ns);
                        tw.WriteEndElement();
                    }

                    foreach (Type type in sinfo.Types)
                    {
                        WriteDataTypeSchema(tw, type);
                    }

                    tw.WriteEndElement();
                }
                tw.WriteEndElement();
            }

            // Bindings

/*			foreach (ServiceType st in servicetypes)
 *                              WriteServiceBinding (tw, st);
 */
            foreach (ServiceType st in services)
            {
                WriteServiceBinding(tw, st, dataTypes);
            }

            // Service element

            tw.WriteStartElement("service", MetaData.WsdlNamespace);
            if (services.Count > 0)
            {
                tw.WriteAttributeString("name", GetServiceName(maint));
            }
            else
            {
                tw.WriteAttributeString("name", "Service");
            }

            foreach (ServiceType st in services)
            {
                WriteServiceType(tw, st);
            }
            tw.WriteEndElement();

            // Closing

            tw.WriteEndElement();
            tw.Flush();
        }
 internal WsdlGenerator(Type[] types, SdlType sdlType, TextWriter output)
 {
     this._typeToInteropNS = new Hashtable();
     this._textWriter = output;
     this._queue = new Queue();
     this._name = null;
     this._namespaces = new ArrayList();
     this._dynamicAssembly = null;
     this._serviceEndpoint = null;
     for (int i = 0; i < types.Length; i++)
     {
         if ((types[i] != null) && (types[i].BaseType != null))
         {
             this.ProcessTypeAttributes(types[i]);
             this._queue.Enqueue(types[i]);
         }
     }
 }
Example #28
0
 // Constructor
 internal SUDSGenerator(Type[] types, TextWriter output)
 {
     Util.Log("SUDSGenerator.SUDSGenerator 1");
     wsdlGenerator = new WsdlGenerator(types, output);
     sdlType       = SdlType.Wsdl;
 }
 internal WsdlGenerator(Type[] types, SdlType sdlType, TextWriter output, Assembly assembly, string url) : this(types, output)
 {
     this._dynamicAssembly = assembly;
     this._serviceEndpoint = url;
 }
Example #30
0
		public void ExportTypes (ServiceType[] servicetypes, SdlType sdltype, XmlTextWriter tw)
		{
			if (sdltype == SdlType.Sdl)	// Obsolete, we don't support this
				throw new NotSupportedException ();

			if (servicetypes.Length == 0) return;
			Type maint = servicetypes [0].ObjectType;
			
			Hashtable dataTypes = new Hashtable (); 
			ArrayList services = new ArrayList ();
			FindTypes (servicetypes, dataTypes, services);
			
			if (services.Count > 0)
				maint = ((ServiceType) services[0]).ObjectType;
			
			string serviceNs = GetXmlNamespace (maint, null);
			
			tw.Formatting = Formatting.Indented;
			tw.WriteStartElement ("definitions", MetaData.WsdlNamespace);
			tw.WriteAttributeString ("name", maint.Name);
			tw.WriteAttributeString ("targetNamespace", serviceNs);
			tw.WriteAttributeString ("xmlns", MetaData.XmlnsNamespace, MetaData.WsdlNamespace);
			tw.WriteAttributeString ("xmlns", "tns", MetaData.XmlnsNamespace, serviceNs);
			tw.WriteAttributeString ("xmlns", "xsd", MetaData.XmlnsNamespace, MetaData.SchemaNamespace);
			tw.WriteAttributeString ("xmlns", "xsi", MetaData.XmlnsNamespace, MetaData.SchemaInstanceNamespace);
			tw.WriteAttributeString ("xmlns", "suds", MetaData.XmlnsNamespace, MetaData.SudsNamespace);
			tw.WriteAttributeString ("xmlns", "wsdl", MetaData.XmlnsNamespace, MetaData.WsdlNamespace);
			tw.WriteAttributeString ("xmlns", "soapenc", MetaData.XmlnsNamespace, MetaData.SoapEncodingNamespace);
			tw.WriteAttributeString ("xmlns", "soap", MetaData.XmlnsNamespace, MetaData.SoapNamespace);
			
			int nums = 0;
			foreach (DictionaryEntry entry in dataTypes)
			{
				string ns = (string) entry.Key;
				if (tw.LookupPrefix (ns) != null) continue;
				tw.WriteAttributeString ("xmlns", "ns"+nums, MetaData.XmlnsNamespace, ns);
				nums++;
			}
			
			// Schema
			
			if (dataTypes.Count > 0)
			{
				tw.WriteStartElement ("types", MetaData.WsdlNamespace);
				foreach (DictionaryEntry entry in dataTypes)
				{
					SchemaInfo sinfo = (SchemaInfo) entry.Value;
					if (sinfo == null || sinfo.Types.Count == 0) continue;
					
					tw.WriteStartElement ("s", "schema", MetaData.SchemaNamespace);
					tw.WriteAttributeString ("targetNamespace", (string) entry.Key);
					tw.WriteAttributeString ("elementFormDefault", "unqualified");
					tw.WriteAttributeString ("attributeFormDefault", "unqualified");
					
					foreach (string ns in sinfo.Imports)
					{
						if (ns == (string) entry.Key) continue;
						tw.WriteStartElement ("import", MetaData.SchemaNamespace);
						tw.WriteAttributeString ("namespace", ns);
						tw.WriteEndElement ();
					}
					
					foreach (Type type in sinfo.Types)
						WriteDataTypeSchema (tw, type);
						
					tw.WriteEndElement ();
				}
				tw.WriteEndElement ();
			}
			
			// Bindings
			
/*			foreach (ServiceType st in servicetypes)
				WriteServiceBinding (tw, st);
*/
			foreach (ServiceType st in services)
				WriteServiceBinding (tw, st, dataTypes);

			// Service element
			
			tw.WriteStartElement ("service", MetaData.WsdlNamespace);
			if (services.Count > 0)
				tw.WriteAttributeString ("name", GetServiceName (maint));
			else
				tw.WriteAttributeString ("name", "Service");

			foreach (ServiceType st in services)
			{
				WriteServiceType (tw, st);
			}
			tw.WriteEndElement ();

			// Closing

			tw.WriteEndElement ();
			tw.Flush ();
		}
		public static void ConvertTypesToSchemaToFile (Type [] types, SdlType sdlType, string path)
		{
			FileStream fs = new FileStream (path, FileMode.Create, FileAccess.Write);
			ConvertTypesToSchemaToStream (types, sdlType, fs);
			fs.Close ();
		}
Example #32
0
 internal SUDSGenerator(Type[] types, SdlType sdlType, TextWriter output)
 {
     this.wsdlGenerator = new WsdlGenerator(types, sdlType, output);
     this.sdlType       = sdlType;
 }
 public static void ConvertTypesToSchemaToFile(Type[] types, SdlType sdlType, string path)
 {
     ConvertTypesToSchemaToStream(types, sdlType, System.IO.File.Create(path));
 }
		// Constructor 
		internal SUDSGenerator(Type[] types, SdlType sdlType, TextWriter output) 
 		{
			Util.Log("SUDSGenerator.SUDSGenerator 2"); 
                wsdlGenerator = new WsdlGenerator(types, sdlType, output);
                this.sdlType = sdlType;
 		}
 public static void ConvertTypesToSchemaToStream(Type[] types, SdlType sdlType, Stream outputStream)
 {
     ServiceType[] serviceTypes = new ServiceType[types.Length];
     for (int i = 0; i < types.Length; i++)
     {
         serviceTypes[i] = new ServiceType(types[i]);
     }
     ConvertTypesToSchemaToStream(serviceTypes, sdlType, outputStream);
 }
Example #36
0
 internal SUDSGenerator(ServiceType[] serviceTypes, SdlType sdlType, TextWriter output)
 {
     this.wsdlGenerator = new WsdlGenerator(serviceTypes, sdlType, output);
     this.sdlType       = sdlType;
 }
 public static void ConvertTypesToSchemaToStream(ServiceType[] serviceTypes, SdlType sdlType, System.IO.Stream outputStream)
 {
 }
 // Constructor
 internal WsdlGenerator(Type[] types, SdlType sdlType, TextWriter output, Assembly assembly, String url)
 : this(types, output)
 {
     Util.Log("WsdlGenerator.WsdlGenerator 4 "+url);         
     _dynamicAssembly = assembly;
     _serviceEndpoint = url;
 }
        } // ConvertTypesToSchemaToStream


        public static void ConvertTypesToSchemaToFile(ServiceType[] types, SdlType sdlType, String path)
        {
            Util.Log("MetaData.ConvertTypesToSchemaToFile 3 "+path);
            ConvertTypesToSchemaToStream(types, sdlType, File.Create(path));
        } // ConvertTypesToSchemaToFile
        } // Properties


        // Should we intercept the call and return some SDL
        private bool ShouldIntercept(ITransportHeaders requestHeaders, out SdlType sdlType)
        {
            sdlType = SdlType.Sdl;
            
            String requestVerb = requestHeaders["__RequestVerb"] as String;
            String requestURI = requestHeaders["__RequestUri"] as String;
    
            // http verb must be "GET" to return sdl (and request uri must be set)
            if ((requestURI == null) ||
                (requestVerb == null) || !requestVerb.Equals("GET"))              
                return false;

            // find last index of ? and look for "sdl" or "sdlx"
            int index = requestURI.LastIndexOf('?');
            if (index == -1)
                return false; // no query string

            String queryString = requestURI.Substring(index).ToLower(CultureInfo.InvariantCulture);

            // sdl?
            if ((String.CompareOrdinal(queryString, "?sdl") == 0) ||
                (String.CompareOrdinal(queryString, "?sdlx") == 0))
            { 
                sdlType = SdlType.Sdl;
                return true;
            }

            // wsdl?
            if (String.CompareOrdinal(queryString, "?wsdl") == 0)
            { 
                sdlType = SdlType.Wsdl;
                return true;
            }            
            
            return false;            
        } // ShouldIntercept
 // Constructor
 internal SUDSGenerator(Type[] types, SdlType sdlType, TextWriter output)
 {
     Util.Log("SUDSGenerator.SUDSGenerator 2");
     wsdlGenerator = new WsdlGenerator(types, sdlType, output);
     this.sdlType  = sdlType;
 }
Example #42
0
 public static void ConvertTypesToSchemaToFile(Type[] types, SdlType sdlType, string path)
 {
     ConvertTypesToSchemaToStream(types, sdlType, System.IO.File.Create(path));
 }
 private void GenerateSdl(SdlType sdlType, IServerResponseChannelSinkStack sinkStack, ITransportHeaders requestHeaders, ITransportHeaders responseHeaders, out Stream outputStream)
 {
     if (!this.MetadataEnabled)
     {
         throw new RemotingException(CoreChannel.GetResourceString("Remoting_MetadataNotEnabled"));
     }
     string uri = requestHeaders["__RequestUri"] as string;
     string objectUriFromRequestUri = HttpChannelHelper.GetObjectUriFromRequestUri(uri);
     if (!this.RemoteApplicationMetadataEnabled && (string.Compare(objectUriFromRequestUri, "RemoteApplicationMetadata.rem", StringComparison.OrdinalIgnoreCase) == 0))
     {
         throw new RemotingException(CoreChannel.GetResourceString("Remoting_RemoteApplicationMetadataNotEnabled"));
     }
     string hostName = (string) requestHeaders["Host"];
     if (hostName != null)
     {
         int index = hostName.IndexOf(':');
         if (index != -1)
         {
             hostName = hostName.Substring(0, index);
         }
     }
     string channelUri = SetupUrlBashingForIisIfNecessary(hostName);
     ServiceType[] serviceTypes = null;
     if (string.Compare(objectUriFromRequestUri, "RemoteApplicationMetadata.rem", StringComparison.OrdinalIgnoreCase) == 0)
     {
         ActivatedServiceTypeEntry[] registeredActivatedServiceTypes = RemotingConfiguration.GetRegisteredActivatedServiceTypes();
         WellKnownServiceTypeEntry[] registeredWellKnownServiceTypes = RemotingConfiguration.GetRegisteredWellKnownServiceTypes();
         int num2 = 0;
         if (registeredActivatedServiceTypes != null)
         {
             num2 += registeredActivatedServiceTypes.Length;
         }
         if (registeredWellKnownServiceTypes != null)
         {
             num2 += registeredWellKnownServiceTypes.Length;
         }
         serviceTypes = new ServiceType[num2];
         int num3 = 0;
         if (registeredActivatedServiceTypes != null)
         {
             foreach (ActivatedServiceTypeEntry entry in registeredActivatedServiceTypes)
             {
                 serviceTypes[num3++] = new ServiceType(entry.ObjectType, null);
             }
         }
         if (registeredWellKnownServiceTypes != null)
         {
             foreach (WellKnownServiceTypeEntry entry2 in registeredWellKnownServiceTypes)
             {
                 string url = this._receiver.GetUrlsForUri(entry2.ObjectUri)[0];
                 if (channelUri != null)
                 {
                     url = HttpChannelHelper.ReplaceChannelUriWithThisString(url, channelUri);
                 }
                 else if (hostName != null)
                 {
                     url = HttpChannelHelper.ReplaceMachineNameWithThisString(url, hostName);
                 }
                 serviceTypes[num3++] = new ServiceType(entry2.ObjectType, url);
             }
         }
     }
     else
     {
         Type serverTypeForUri = RemotingServices.GetServerTypeForUri(objectUriFromRequestUri);
         if (serverTypeForUri == null)
         {
             throw new RemotingException(string.Format(CultureInfo.CurrentCulture, "Object with uri '{0}' does not exist at server.", new object[] { objectUriFromRequestUri }));
         }
         string str6 = this._receiver.GetUrlsForUri(objectUriFromRequestUri)[0];
         if (channelUri != null)
         {
             str6 = HttpChannelHelper.ReplaceChannelUriWithThisString(str6, channelUri);
         }
         else if (hostName != null)
         {
             str6 = HttpChannelHelper.ReplaceMachineNameWithThisString(str6, hostName);
         }
         serviceTypes = new ServiceType[] { new ServiceType(serverTypeForUri, str6) };
     }
     responseHeaders["Content-Type"] = "text/xml";
     bool flag = false;
     outputStream = sinkStack.GetResponseStream(null, responseHeaders);
     if (outputStream == null)
     {
         outputStream = new MemoryStream(0x400);
         flag = true;
     }
     MetaData.ConvertTypesToSchemaToStream(serviceTypes, sdlType, outputStream);
     if (flag)
     {
         outputStream.Position = 0L;
     }
 }
		public static void ConvertTypesToSchemaToStream (Type [] types, SdlType sdlType, Stream outputStream)
		{
			ServiceType[] st = new ServiceType [types.Length];
			for (int n=0; n<types.Length; n++)
				st [n] = new ServiceType (types[n]);

			ConvertTypesToSchemaToStream (st, sdlType, outputStream);
		}
Example #45
0
		// Constructor
		internal SUDSGenerator(Type[] types, TextWriter output, Assembly assembly, String url)
		{
			Util.Log("SUDSGenerator.SUDSGenerator 3 "+url);
            wsdlGenerator = new WsdlGenerator(types, output, assembly, url);
            sdlType = SdlType.Wsdl;
		}
	public static void ConvertTypesToSchemaToFile(ServiceType[] types, SdlType sdlType, string path) {}
        } // ShouldIntercept


        private void GenerateSdl(SdlType sdlType,
                                 IServerResponseChannelSinkStack sinkStack,
                                 ITransportHeaders requestHeaders,
                                 ITransportHeaders responseHeaders,
                                 out Stream outputStream)
        {
            if (!MetadataEnabled)
                throw new RemotingException(CoreChannel.GetResourceString("Remoting_MetadataNotEnabled"));
            
            String requestUri = requestHeaders[CommonTransportKeys.RequestUri] as String;           
            String objectUri = HttpChannelHelper.GetObjectUriFromRequestUri(requestUri);            
            
            if (!RemoteApplicationMetadataEnabled && 
                (String.Compare(objectUri, "RemoteApplicationMetadata.rem", StringComparison.OrdinalIgnoreCase) == 0))
                throw new RemotingException(CoreChannel.GetResourceString("Remoting_RemoteApplicationMetadataNotEnabled"));

            // If the host header is present, we will use this in the generated uri's
            String hostName = (String)requestHeaders["Host"];
            if (hostName != null)
            {
                // filter out port number if present
                int index = hostName.IndexOf(':');
                if (index != -1)
                    hostName = hostName.Substring(0, index);
            }

            

            ServiceType[] types = null;

            if (String.Compare(objectUri, "RemoteApplicationMetadata.rem", StringComparison.OrdinalIgnoreCase) == 0)
            {
                // get the service description for all registered service types
                
                ActivatedServiceTypeEntry[] activatedTypes = 
                    RemotingConfiguration.GetRegisteredActivatedServiceTypes();

                WellKnownServiceTypeEntry[] wellKnownTypes = 
                    RemotingConfiguration.GetRegisteredWellKnownServiceTypes();

                // determine total number of types
                int typeCount = 0;
                
                if (activatedTypes != null)
                    typeCount += activatedTypes.Length;
                    
                if (wellKnownTypes != null)
                    typeCount += wellKnownTypes.Length;

                types = new ServiceType[typeCount];

                // collect data
                int co = 0;
                if (activatedTypes != null)
                {
                    foreach (ActivatedServiceTypeEntry entry in activatedTypes)
                    {
                        types[co++] = new ServiceType(entry.ObjectType, null);
                    }                    
                }

                if (wellKnownTypes != null)
                {
                    foreach (WellKnownServiceTypeEntry entry in wellKnownTypes)
                    {   
                        String[] urls = _receiver.GetUrlsForUri(entry.ObjectUri);
                        String url = urls[0];
                        if (hostName != null)
                            url = HttpChannelHelper.ReplaceMachineNameWithThisString(url, hostName);

                        types[co++] = new ServiceType(entry.ObjectType, url);
                    } 
                }

                InternalRemotingServices.RemotingAssert(co == typeCount, "Not all types were processed.");                
            }
            else
            {    
                // get the service description for a particular object
                Type objectType = RemotingServices.GetServerTypeForUri(objectUri);
                if (objectType == null)
                {
                    throw new RemotingException(
                        String.Format(
                            CultureInfo.CurrentCulture, "Object with uri '{0}' does not exist at server.",
                            objectUri));
                }
                
                String[] urls = _receiver.GetUrlsForUri(objectUri);
                String url = urls[0];
                if (hostName != null)
                    url = HttpChannelHelper.ReplaceMachineNameWithThisString(url, hostName);

                types = new ServiceType[1];
                types[0] = new ServiceType(objectType, url);
            }

            responseHeaders["Content-Type"] = "text/xml";

            bool bMemStream = false;

            outputStream = sinkStack.GetResponseStream(null, responseHeaders);
            if (outputStream == null)
            {
                outputStream = new MemoryStream(1024);
                bMemStream = true;
            }        

            MetaData.ConvertTypesToSchemaToStream(types, sdlType, outputStream);

            if (bMemStream)
                outputStream.Position = 0;
        } // GenerateXmlForUri               
	public static void ConvertTypesToSchemaToStream(Type[] types, SdlType sdlType, System.IO.Stream outputStream) {}
 internal SUDSGenerator(ServiceType[] serviceTypes, SdlType sdlType, TextWriter output)
 {
     this.wsdlGenerator = new WsdlGenerator(serviceTypes, sdlType, output);
     this.sdlType = sdlType;
 }
Example #50
0
 // Constructor
 internal SUDSGenerator(Type[] types, TextWriter output, Assembly assembly, String url)
 {
     Util.Log("SUDSGenerator.SUDSGenerator 3 " + url);
     wsdlGenerator = new WsdlGenerator(types, output, assembly, url);
     sdlType       = SdlType.Wsdl;
 }
        internal WsdlGenerator(ServiceType[] serviceTypes, SdlType sdlType, TextWriter output)
        {
            Util.Log("WsdlGenerator.WsdlGenerator 5 ");
            _textWriter = output;
            _queue = new Queue();
            _name = null;
            _namespaces = new ArrayList();
            _dynamicAssembly = null;
            _serviceEndpoint = null;

            for (int i=0; i<serviceTypes.Length; i++)
            {
                if (serviceTypes[i] != null)
                {
                    if (serviceTypes[i].ObjectType.BaseType != null)
                    {
                        Util.Log("WsdlGenerator.WsdlGenerator ProcessTypeAttributes 3 objectType "+serviceTypes[i].ObjectType+" basetype "+serviceTypes[i].ObjectType.BaseType);
                        ProcessTypeAttributes(serviceTypes[i].ObjectType);
                        _queue.Enqueue(serviceTypes[i].ObjectType);
                    }
                }

                // Associate serviceEndpoint with type. A type can have multiple serviceEndpoints
                if (serviceTypes[i].Url != null)
                {
                    if (_typeToServiceEndpoint == null)
                        _typeToServiceEndpoint = new Hashtable(10);
                    if (_typeToServiceEndpoint.ContainsKey(serviceTypes[i].ObjectType.Name))
                    {
                        ArrayList serviceEndpoints = (ArrayList)_typeToServiceEndpoint[serviceTypes[i].ObjectType.Name];
                        serviceEndpoints.Add(serviceTypes[i].Url);
                    }
                    else
                    {
                        ArrayList serviceEndpoints = new ArrayList(10);
                        serviceEndpoints.Add(serviceTypes[i].Url);
                        _typeToServiceEndpoint[serviceTypes[i].ObjectType.Name] = serviceEndpoints;
                    }

                }
            }
        }
 internal SUDSGenerator(Type[] types, SdlType sdlType, TextWriter output)
 {
     this.wsdlGenerator = new WsdlGenerator(types, sdlType, output);
     this.sdlType = sdlType;
 }
Example #53
0
        } // ConvertTypesToSchemaToStream

        public static void ConvertTypesToSchemaToFile(ServiceType[] types, SdlType sdlType, String path)
        {
            Util.Log("MetaData.ConvertTypesToSchemaToFile 3 " + path);
            ConvertTypesToSchemaToStream(types, sdlType, File.Create(path));
        } // ConvertTypesToSchemaToFile
Example #54
0
		// Constructor
		internal SUDSGenerator(Type[] types, TextWriter output)
		{
			Util.Log("SUDSGenerator.SUDSGenerator 1");
            wsdlGenerator = new WsdlGenerator(types, output);
            sdlType = SdlType.Wsdl;
		}