public void WriteRoot_DiscoveryDocument(object o)
 {
     WriteStartDocument();
     System.Web.Services.Discovery.DiscoveryDocument ob = (System.Web.Services.Discovery.DiscoveryDocument)o;
     TopLevelElement();
     WriteObject_DiscoveryDocument(ob, "discovery", "http://schemas.xmlsoap.org/disco/", true, false, true);
 }
        void WriteObject_DiscoveryDocument(System.Web.Services.Discovery.DiscoveryDocument ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
        {
            if (ob == null)
            {
                if (isNullable)
                {
                    WriteNullTagLiteral(element, namesp);
                }
                return;
            }

            if (writeWrappingElem)
            {
                WriteStartElement(element, namesp, ob);
            }

            if (needType)
            {
                WriteXsiType("DiscoveryDocument", "http://schemas.xmlsoap.org/disco/");
            }

            if (ob.@references != null)
            {
                for (int n6 = 0; n6 < [email protected]; n6++)
                {
                    if (ob.@references[n6] == null)
                    {
                    }
                    else if (ob.@references[n6].GetType() == typeof(System.Web.Services.Discovery.SchemaReference))
                    {
                        WriteObject_SchemaReference(((System.Web.Services.Discovery.SchemaReference)ob.@references[n6]), "schemaRef", "http://schemas.xmlsoap.org/disco/", false, false, true);
                    }
                    else if (ob.@references[n6].GetType() == typeof(System.Web.Services.Discovery.DiscoveryDocumentReference))
                    {
                        WriteObject_DiscoveryDocumentReference(((System.Web.Services.Discovery.DiscoveryDocumentReference)ob.@references[n6]), "discoveryRef", "http://schemas.xmlsoap.org/disco/", false, false, true);
                    }
                    else if (ob.@references[n6].GetType() == typeof(System.Web.Services.Discovery.ContractReference))
                    {
                        WriteObject_ContractReference(((System.Web.Services.Discovery.ContractReference)ob.@references[n6]), "contractRef", "http://schemas.xmlsoap.org/disco/scl/", false, false, true);
                    }
                    else
                    {
                        throw CreateUnknownTypeException(ob.@references[n6]);
                    }
                }
            }
            if (ob.@additionalInfo != null)
            {
                for (int n7 = 0; n7 < [email protected]; n7++)
                {
                    WriteObject_SoapBinding(((System.Web.Services.Discovery.SoapBinding)ob.@additionalInfo[n7]), "soap", "http://schemas/xmlsoap.org/disco/schema/soap/", false, false, true);
                }
            }
            if (writeWrappingElem)
            {
                WriteEndElement(ob);
            }
        }
		public System.Web.Services.Discovery.DiscoveryDocument ReadObject_DiscoveryDocument (bool isNullable, bool checkType)
		{
			System.Web.Services.Discovery.DiscoveryDocument ob = null;
			if (isNullable && ReadNull()) return null;

			if (checkType) 
			{
				System.Xml.XmlQualifiedName t = GetXsiType();
				if (t != null) 
				{
					if (t.Name != "DiscoveryDocument" || t.Namespace != "http://schemas.xmlsoap.org/disco/")
						throw CreateUnknownTypeException(t);
				}
			}

			ob = new System.Web.Services.Discovery.DiscoveryDocument ();

			Reader.MoveToElement();

			while (Reader.MoveToNextAttribute())
			{
				if (IsXmlnsAttribute (Reader.Name)) {
				}
				else {
					UnknownNode (ob);
				}
			}

			Reader.MoveToElement();
			if (Reader.IsEmptyElement) {
				Reader.Skip ();
				return ob;
			}

			Reader.ReadStartElement();
			Reader.MoveToContent();

			bool b0=false, b1=false;

			System.Collections.ArrayList o3 = null;
			System.Collections.ArrayList o5 = null;
			int n2=0, n4=0;

			while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
			{
				if (Reader.NodeType == System.Xml.XmlNodeType.Element) 
				{
					if (Reader.LocalName == "discoveryRef" && Reader.NamespaceURI == "http://schemas.xmlsoap.org/disco/" && !b0) {
						if (o3 == null)
							o3 = new System.Collections.ArrayList();
						o3.Add (ReadObject_DiscoveryDocumentReference (false, true));
						n2++;
					}
					else if (Reader.LocalName == "soap" && Reader.NamespaceURI == "http://schemas/xmlsoap.org/disco/schema/soap/" && !b1) {
						if (o5 == null)
							o5 = new System.Collections.ArrayList();
						o5.Add (ReadObject_SoapBinding (false, true));
						n4++;
					}
					else if (Reader.LocalName == "contractRef" && Reader.NamespaceURI == "http://schemas.xmlsoap.org/disco/scl/" && !b0) {
						if (o3 == null)
							o3 = new System.Collections.ArrayList();
						o3.Add (ReadObject_ContractReference (false, true));
						n2++;
					}
					else if (Reader.LocalName == "schemaRef" && Reader.NamespaceURI == "http://schemas.xmlsoap.org/disco/" && !b0) {
						if (o3 == null)
							o3 = new System.Collections.ArrayList();
						o3.Add (ReadObject_SchemaReference (false, true));
						n2++;
					}
					else {
						UnknownNode (ob);
					}
				}
				else
					UnknownNode(ob);

				Reader.MoveToContent();
			}

			ob.@references = o3;
			ob.@additionalInfo = o5;

			ReadEndElement();

			return ob;
		}
Beispiel #4
0
        private void SearchNetworkForWebServers(Dictionary <string, string> WebServiceURLs)
        {
            Cursor.Current = Cursors.WaitCursor;
            string origMessage = ux_textboxLoginMessage.Text;

            ux_textboxLoginMessage.Text    = "Scanning...";
            ux_progressbarScanning.Step    = 1;
            ux_progressbarScanning.Minimum = 0;
            ux_progressbarScanning.Maximum = 255;
            ux_progressbarScanning.Value   = 1;
            ux_progressbarScanning.Show();

            System.Web.Services.Discovery.DiscoveryClientProtocol dcp = new System.Web.Services.Discovery.DiscoveryClientProtocol();
            dcp.Timeout = 1000;

            // Search for active servers hosting the GRIN-Global web services...
            // Try the localhost first...
            try
            {
                ux_textboxLoginMessage.Text = "Scanning localhost...";
                ux_textboxLoginMessage.Update();
                dcp.Discover("http://localhost/GRINGlobal/GUI.asmx");
                WebServiceURLs.Add("localhost", "http://localhost/GRINGlobal/GUI.asmx");
            }
            catch
            {
                // Silently fail...
            }


            // Now scan the class D subnet for all available ethernet adapters...
            System.Net.NetworkInformation.NetworkInterface[] adapters = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();

            foreach (System.Net.NetworkInformation.NetworkInterface adapter in adapters)
            {
                if (adapter.NetworkInterfaceType == System.Net.NetworkInformation.NetworkInterfaceType.Ethernet &&
                    adapter.OperationalStatus == System.Net.NetworkInformation.OperationalStatus.Up)
                {
                    System.Net.NetworkInformation.IPInterfaceProperties adapterProperties = adapter.GetIPProperties();
                    System.Net.NetworkInformation.UnicastIPAddressInformationCollection adapterAddresses = adapterProperties.UnicastAddresses;
                    foreach (System.Net.NetworkInformation.IPAddressInformation addressInfo in adapterAddresses)
                    {
                        DateTime dtStart       = DateTime.Now;
                        string   addrPrefix    = addressInfo.Address.ToString().Substring(0, addressInfo.Address.ToString().LastIndexOf('.'));
                        string   ipAddress     = addrPrefix + ".1";
                        string   webServiceURL = "http://" + ipAddress + "/GRINGlobal/GUI.asmx";
                        string   serverName    = System.Net.Dns.GetHostEntry(ipAddress).HostName;
                        System.Web.Services.Discovery.DiscoveryDocument dd = new System.Web.Services.Discovery.DiscoveryDocument();

                        for (int addrSuffix = 1; addrSuffix < 254; addrSuffix++)
                        {
                            try
                            {
                                // Now see if we can find a GG server...
                                ipAddress = addrPrefix + "." + addrSuffix;
                                // Display what IP address is being scanned...
                                ux_textboxLoginMessage.Text = "Scanning " + ipAddress + "...";
                                ux_textboxLoginMessage.Update();
                                // Attempt to discover the GG specific web services using the IP address...
                                dd = dcp.Discover("http://" + ipAddress + "/GRINGlobal/GUI.asmx");
                                // If we made it here, we found a webservice so now attempt to resolve the ipAddress to a friendlier host name
                                // Why do this now?  Because DNS lookup can be expensive so only do it when really neccessary
                                // (BTW... unresolved DNS lookups will return the ipAddress)...
                                serverName    = System.Net.Dns.GetHostEntry(ipAddress).HostName;
                                webServiceURL = "http://" + serverName + "/GRINGlobal/GUI.asmx";
                                // Attempt to discover the GG specific web services (again - this time with a DNS resolved computer name)
                                // Why do this?  Because there is a slight possiblity the DNS lookup returned bogus data...
                                dd = dcp.Discover(webServiceURL);
                                for (int i = 0; i < dd.References.Count; i++)
                                {
                                    // There are many different references in a discovery document - we only want the SOAP Bindings...
                                    if (dd.References[i].GetType() == typeof(System.Web.Services.Discovery.SoapBinding))
                                    {
                                        System.Web.Services.Discovery.SoapBinding wsb = (System.Web.Services.Discovery.SoapBinding)dd.References[i];
                                        // The bad news is that the references have duplicates bindings (one for each protocol), but the good
                                        // news is that since the WebServiceURLs object is a dictionary... it will create and execption if the same Key entry is
                                        // attempted to be added twice (net result is that it will silently fail in the catch block)...
                                        WebServiceURLs.Add(serverName, wsb.Address);
                                    }
                                }
                            }
                            catch
                            {
                                // Silently fail...
                            }
                            ux_progressbarScanning.PerformStep();
                            ux_progressbarScanning.Update();
                            // Check to see if we should bail out (at user request)...
                            Application.DoEvents();
                        }
                    }
                }
            }
            ux_progressbarScanning.Hide();
            ux_textboxLoginMessage.Text = origMessage;
        }
 System.Web.Services.Discovery.DiscoveryDocument Read1_DiscoveryDocument(bool isNullable, bool checkType)
 {
     if (isNullable && ReadNull())
     {
         return(null);
     }
     if (checkType)
     {
         System.Xml.XmlQualifiedName t = GetXsiType();
         if (t == null || ((object)((System.Xml.XmlQualifiedName)t).Name == (object)id1_DiscoveryDocument && (object)((System.Xml.XmlQualifiedName)t).Namespace == (object)id2_httpschemasxmlsoaporgdisco))
         {
             ;
         }
         else
         {
             throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)t);
         }
     }
     System.Web.Services.Discovery.DiscoveryDocument o = new System.Web.Services.Discovery.DiscoveryDocument();
     System.Collections.IList a_0 = (System.Collections.IList)o.@References;
     bool[] paramsRead            = new bool[1];
     while (Reader.MoveToNextAttribute())
     {
         if (!IsXmlnsAttribute(Reader.Name))
         {
             UnknownNode((object)o);
         }
     }
     Reader.MoveToElement();
     if (Reader.IsEmptyElement)
     {
         Reader.Skip();
         return(o);
     }
     Reader.ReadStartElement();
     Reader.MoveToContent();
     while (Reader.NodeType != System.Xml.XmlNodeType.EndElement)
     {
         if (Reader.NodeType == System.Xml.XmlNodeType.Element)
         {
             if (((object)Reader.LocalName == (object)id3_schemaRef && (object)Reader.NamespaceURI == (object)id4_httpschemasxmlsoaporgdiscoschema))
             {
                 if ((object)(a_0) == null)
                 {
                     Reader.Skip();
                 }
                 else
                 {
                     a_0.Add(Read7_SchemaReference(false, true));
                 }
             }
             else if (((object)Reader.LocalName == (object)id5_soap && (object)Reader.NamespaceURI == (object)id6_httpschemasxmlsoaporgdiscosoap))
             {
                 if ((object)(a_0) == null)
                 {
                     Reader.Skip();
                 }
                 else
                 {
                     a_0.Add(Read9_SoapBinding(false, true));
                 }
             }
             else if (((object)Reader.LocalName == (object)id7_discoveryRef && (object)Reader.NamespaceURI == (object)id2_httpschemasxmlsoaporgdisco))
             {
                 if ((object)(a_0) == null)
                 {
                     Reader.Skip();
                 }
                 else
                 {
                     a_0.Add(Read2_DiscoveryDocumentReference(false, true));
                 }
             }
             else if (((object)Reader.LocalName == (object)id8_contractRef && (object)Reader.NamespaceURI == (object)id9_httpschemasxmlsoaporgdiscoscl))
             {
                 if ((object)(a_0) == null)
                 {
                     Reader.Skip();
                 }
                 else
                 {
                     a_0.Add(Read5_ContractReference(false, true));
                 }
             }
             else
             {
                 UnknownNode((object)o);
             }
         }
         else
         {
             UnknownNode((object)o);
         }
         Reader.MoveToContent();
     }
     ReadEndElement();
     return(o);
 }
 void Write1_DiscoveryDocument(string n, string ns, System.Web.Services.Discovery.DiscoveryDocument o, bool isNullable, bool needType)
 {
     if ((object)o == null)
     {
         if (isNullable)
         {
             WriteNullTagLiteral(n, ns);
         }
         return;
     }
     if (!needType)
     {
         System.Type t = o.GetType();
         if (t == typeof(System.Web.Services.Discovery.DiscoveryDocument))
         {
             ;
         }
         else
         {
             throw CreateUnknownTypeException(o);
         }
     }
     WriteStartElement(n, ns, o);
     if (needType)
     {
         WriteXsiType(@"DiscoveryDocument", @"http://schemas.xmlsoap.org/disco/");
     }
     {
         System.Collections.IList a = (System.Collections.IList)o.@References;
         if (a != null)
         {
             for (int ia = 0; ia < a.Count; ia++)
             {
                 System.Object ai = a[ia];
                 {
                     if (ai is System.Web.Services.Discovery.SchemaReference)
                     {
                         Write7_SchemaReference(@"schemaRef", @"http://schemas.xmlsoap.org/disco/schema/", ((System.Web.Services.Discovery.SchemaReference)ai), false, false);
                     }
                     else if (ai is System.Web.Services.Discovery.SoapBinding)
                     {
                         Write9_SoapBinding(@"soap", @"http://schemas.xmlsoap.org/disco/soap/", ((System.Web.Services.Discovery.SoapBinding)ai), false, false);
                     }
                     else if (ai is System.Web.Services.Discovery.DiscoveryDocumentReference)
                     {
                         Write2_DiscoveryDocumentReference(@"discoveryRef", @"http://schemas.xmlsoap.org/disco/", ((System.Web.Services.Discovery.DiscoveryDocumentReference)ai), false, false);
                     }
                     else if (ai is System.Web.Services.Discovery.ContractReference)
                     {
                         Write5_ContractReference(@"contractRef", @"http://schemas.xmlsoap.org/disco/scl/", ((System.Web.Services.Discovery.ContractReference)ai), false, false);
                     }
                     else
                     {
                         if (ai != null)
                         {
                             throw CreateUnknownTypeException(ai);
                         }
                     }
                 }
             }
         }
     }
     WriteEndElement(o);
 }
        public System.Web.Services.Discovery.DiscoveryDocument ReadObject_DiscoveryDocument(bool isNullable, bool checkType)
        {
            System.Web.Services.Discovery.DiscoveryDocument ob = null;
            if (isNullable && ReadNull())
            {
                return(null);
            }

            if (checkType)
            {
                System.Xml.XmlQualifiedName t = GetXsiType();
                if (t != null)
                {
                    if (t.Name != "DiscoveryDocument" || t.Namespace != "http://schemas.xmlsoap.org/disco/")
                    {
                        throw CreateUnknownTypeException(t);
                    }
                }
            }

            ob = new System.Web.Services.Discovery.DiscoveryDocument();

            Reader.MoveToElement();

            while (Reader.MoveToNextAttribute())
            {
                if (IsXmlnsAttribute(Reader.Name))
                {
                }
                else
                {
                    UnknownNode(ob);
                }
            }

            Reader.MoveToElement();
            if (Reader.IsEmptyElement)
            {
                Reader.Skip();
                return(ob);
            }

            Reader.ReadStartElement();
            Reader.MoveToContent();

            bool b0 = false, b1 = false;

            System.Collections.ArrayList o3 = null;
            System.Collections.ArrayList o5 = null;
            int n2 = 0, n4 = 0;

            while (Reader.NodeType != System.Xml.XmlNodeType.EndElement)
            {
                if (Reader.NodeType == System.Xml.XmlNodeType.Element)
                {
                    if (Reader.LocalName == "discoveryRef" && Reader.NamespaceURI == "http://schemas.xmlsoap.org/disco/" && !b0)
                    {
                        if (o3 == null)
                        {
                            o3 = new System.Collections.ArrayList();
                        }
                        o3.Add(ReadObject_DiscoveryDocumentReference(false, true));
                        n2++;
                    }
                    else if (Reader.LocalName == "soap" && Reader.NamespaceURI == "http://schemas/xmlsoap.org/disco/schema/soap/" && !b1)
                    {
                        if (o5 == null)
                        {
                            o5 = new System.Collections.ArrayList();
                        }
                        o5.Add(ReadObject_SoapBinding(false, true));
                        n4++;
                    }
                    else if (Reader.LocalName == "contractRef" && Reader.NamespaceURI == "http://schemas.xmlsoap.org/disco/scl/" && !b0)
                    {
                        if (o3 == null)
                        {
                            o3 = new System.Collections.ArrayList();
                        }
                        o3.Add(ReadObject_ContractReference(false, true));
                        n2++;
                    }
                    else if (Reader.LocalName == "schemaRef" && Reader.NamespaceURI == "http://schemas.xmlsoap.org/disco/" && !b0)
                    {
                        if (o3 == null)
                        {
                            o3 = new System.Collections.ArrayList();
                        }
                        o3.Add(ReadObject_SchemaReference(false, true));
                        n2++;
                    }
                    else
                    {
                        UnknownNode(ob);
                    }
                }
                else
                {
                    UnknownNode(ob);
                }

                Reader.MoveToContent();
            }

            ob.@references     = o3;
            ob.@additionalInfo = o5;

            ReadEndElement();

            return(ob);
        }
Beispiel #8
0
        private void SearchNetworkForWebServers(Dictionary<string, string> WebServiceURLs)
        {
            Cursor.Current = Cursors.WaitCursor;
            string origMessage = ux_textboxLoginMessage.Text;
            ux_textboxLoginMessage.Text = "Scanning...";
            ux_progressbarScanning.Step = 1;
            ux_progressbarScanning.Minimum = 0;
            ux_progressbarScanning.Maximum = 255;
            ux_progressbarScanning.Value = 1;
            ux_progressbarScanning.Show();

            System.Web.Services.Discovery.DiscoveryClientProtocol dcp = new System.Web.Services.Discovery.DiscoveryClientProtocol();
            dcp.Timeout = 1000;

            // Search for active servers hosting the GRIN-Global web services...
            // Try the localhost first...
            try
            {
                ux_textboxLoginMessage.Text = "Scanning localhost...";
                ux_textboxLoginMessage.Update();
                dcp.Discover("http://localhost/GRINGlobal/GUI.asmx");
                WebServiceURLs.Add("localhost", "http://localhost/GRINGlobal/GUI.asmx");
            }
            catch
            {
                // Silently fail...
            }

            // Now scan the class D subnet for all available ethernet adapters...
            System.Net.NetworkInformation.NetworkInterface[] adapters = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces();

            foreach (System.Net.NetworkInformation.NetworkInterface adapter in adapters)
            {
                if (adapter.NetworkInterfaceType == System.Net.NetworkInformation.NetworkInterfaceType.Ethernet &&
                    adapter.OperationalStatus == System.Net.NetworkInformation.OperationalStatus.Up)
                {
                    System.Net.NetworkInformation.IPInterfaceProperties adapterProperties = adapter.GetIPProperties();
                    System.Net.NetworkInformation.UnicastIPAddressInformationCollection adapterAddresses = adapterProperties.UnicastAddresses;
                    foreach (System.Net.NetworkInformation.IPAddressInformation addressInfo in adapterAddresses)
                    {
                        DateTime dtStart = DateTime.Now;
                        string addrPrefix = addressInfo.Address.ToString().Substring(0, addressInfo.Address.ToString().LastIndexOf('.'));
                        string ipAddress = addrPrefix + ".1";
                        string webServiceURL = "http://" + ipAddress + "/GRINGlobal/GUI.asmx";
                        string serverName = System.Net.Dns.GetHostEntry(ipAddress).HostName;
                        System.Web.Services.Discovery.DiscoveryDocument dd = new System.Web.Services.Discovery.DiscoveryDocument();

                        for (int addrSuffix = 1; addrSuffix < 254; addrSuffix++)
                        {
                            try
                            {
                                // Now see if we can find a GG server...
                                ipAddress = addrPrefix + "." + addrSuffix;
                                // Display what IP address is being scanned...
                                ux_textboxLoginMessage.Text = "Scanning " + ipAddress + "...";
                                ux_textboxLoginMessage.Update();
                                // Attempt to discover the GG specific web services using the IP address...
                                dd = dcp.Discover("http://" + ipAddress + "/GRINGlobal/GUI.asmx");
                                // If we made it here, we found a webservice so now attempt to resolve the ipAddress to a friendlier host name
                                // Why do this now?  Because DNS lookup can be expensive so only do it when really neccessary
                                // (BTW... unresolved DNS lookups will return the ipAddress)...
                                serverName = System.Net.Dns.GetHostEntry(ipAddress).HostName;
                                webServiceURL = "http://" + serverName + "/GRINGlobal/GUI.asmx";
                                // Attempt to discover the GG specific web services (again - this time with a DNS resolved computer name)
                                // Why do this?  Because there is a slight possiblity the DNS lookup returned bogus data...
                                dd = dcp.Discover(webServiceURL);
                                for (int i = 0; i < dd.References.Count; i++)
                                {
                                    // There are many different references in a discovery document - we only want the SOAP Bindings...
                                    if (dd.References[i].GetType() == typeof(System.Web.Services.Discovery.SoapBinding))
                                    {
                                        System.Web.Services.Discovery.SoapBinding wsb = (System.Web.Services.Discovery.SoapBinding)dd.References[i];
                                        // The bad news is that the references have duplicates bindings (one for each protocol), but the good
                                        // news is that since the WebServiceURLs object is a dictionary... it will create and execption if the same Key entry is
                                        // attempted to be added twice (net result is that it will silently fail in the catch block)...
                                        WebServiceURLs.Add(serverName, wsb.Address);
                                    }
                                }
                            }
                            catch
                            {
                                // Silently fail...
                            }
                            ux_progressbarScanning.PerformStep();
                            ux_progressbarScanning.Update();
                            // Check to see if we should bail out (at user request)...
                            Application.DoEvents();
                        }
                    }
                }
            }
            ux_progressbarScanning.Hide();
            ux_textboxLoginMessage.Text = origMessage;
        }