private void Write8_SoapBinding(string n, string ns, SoapBinding o, bool isNullable, bool needType)
 {
     if (o == null)
     {
         if (isNullable)
         {
             base.WriteNullTagLiteral(n, ns);
         }
     }
     else
     {
         if (!needType && !(o.GetType() == typeof(SoapBinding)))
         {
             throw base.CreateUnknownTypeException(o);
         }
         base.WriteStartElement(n, ns, o, false, null);
         if (needType)
         {
             base.WriteXsiType("SoapBinding", "http://schemas.xmlsoap.org/disco/soap/");
         }
         base.WriteAttribute("address", "", o.Address);
         base.WriteAttribute("binding", "", base.FromXmlQualifiedName(o.Binding));
         base.WriteEndElement(o);
     }
 }
        void GenerateDiscoDocument(HttpContext context)
        {
            ServiceDescriptionCollection descs = GetDescriptions();

            DiscoveryDocument doc  = new DiscoveryDocument();
            ContractReference cref = new ContractReference();

            cref.Ref    = _url + "?wsdl";
            cref.DocRef = _url;
            doc.References.Add(cref);

            foreach (ServiceDescription desc in descs)
            {
                foreach (Service ser in desc.Services)
                {
                    foreach (Port port in ser.Ports)
                    {
                        SoapAddressBinding sab = port.Extensions.Find(typeof(SoapAddressBinding)) as SoapAddressBinding;
                        if (sab != null)
                        {
                            System.Web.Services.Discovery.SoapBinding dsb = new System.Web.Services.Discovery.SoapBinding();
                            dsb.Address = sab.Location;
                            dsb.Binding = port.Binding;
                            doc.AdditionalInfo.Add(dsb);
                        }
                    }
                }
            }

            context.Response.ContentType = "text/xml; charset=utf-8";
            XmlTextWriter xtw = new XmlTextWriter(context.Response.OutputStream, new UTF8Encoding(false));

            xtw.Formatting = Formatting.Indented;
            doc.Write(xtw);
        }
        internal DiscoveryServerType(Type type, string uri) : base(typeof(DiscoveryServerProtocol))
        {
            this.schemaTable = new Hashtable();
            this.wsdlTable   = new Hashtable();
            uri             = new Uri(uri, true).GetLeftPart(UriPartial.Path);
            this.methodInfo = new LogicalMethodInfo(typeof(DiscoveryServerProtocol).GetMethod("Discover", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance));
            ServiceDescriptionReflector reflector = new ServiceDescriptionReflector();

            reflector.Reflect(type, uri);
            XmlSchemas schemas = reflector.Schemas;

            this.description = reflector.ServiceDescription;
            XmlSerializer serializer = ServiceDescription.Serializer;

            this.AddSchemaImports(schemas, uri, reflector.ServiceDescriptions);
            for (int i = 1; i < reflector.ServiceDescriptions.Count; i++)
            {
                ServiceDescription description = reflector.ServiceDescriptions[i];
                Import             import      = new Import {
                    Namespace = description.TargetNamespace
                };
                string key = "wsdl" + i.ToString(CultureInfo.InvariantCulture);
                import.Location = uri + "?wsdl=" + key;
                reflector.ServiceDescription.Imports.Add(import);
                this.wsdlTable.Add(key, description);
            }
            this.discoDoc = new DiscoveryDocument();
            this.discoDoc.References.Add(new ContractReference(uri + "?wsdl", uri));
            foreach (Service service in reflector.ServiceDescription.Services)
            {
                foreach (Port port in service.Ports)
                {
                    SoapAddressBinding binding = (SoapAddressBinding)port.Extensions.Find(typeof(SoapAddressBinding));
                    if (binding != null)
                    {
                        System.Web.Services.Discovery.SoapBinding binding2 = new System.Web.Services.Discovery.SoapBinding {
                            Binding = port.Binding,
                            Address = binding.Location
                        };
                        this.discoDoc.References.Add(binding2);
                    }
                }
            }
        }
Beispiel #4
0
        public void Discover()
        {
            if (this.clientType.Binding == null)
            {
                throw new InvalidOperationException(System.Web.Services.Res.GetString("DiscoveryIsNotPossibleBecauseTypeIsMissing1", new object[] { base.GetType().FullName }));
            }
            DiscoveryClientProtocol protocol = new DiscoveryClientProtocol(this);

            foreach (object obj2 in protocol.Discover(base.Url).References)
            {
                System.Web.Services.Discovery.SoapBinding binding = obj2 as System.Web.Services.Discovery.SoapBinding;
                if (((binding != null) && (this.clientType.Binding.Name == binding.Binding.Name)) && (this.clientType.Binding.Namespace == binding.Binding.Namespace))
                {
                    base.Url = binding.Address;
                    return;
                }
            }
            throw new InvalidOperationException(System.Web.Services.Res.GetString("TheBindingNamedFromNamespaceWasNotFoundIn3", new object[] { this.clientType.Binding.Name, this.clientType.Binding.Namespace, base.Url }));
        }
 internal DiscoveryServerType(Type type, string uri) : base(typeof(DiscoveryServerProtocol))
 {
     this.schemaTable = new Hashtable();
     this.wsdlTable = new Hashtable();
     uri = new Uri(uri, true).GetLeftPart(UriPartial.Path);
     this.methodInfo = new LogicalMethodInfo(typeof(DiscoveryServerProtocol).GetMethod("Discover", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance));
     ServiceDescriptionReflector reflector = new ServiceDescriptionReflector();
     reflector.Reflect(type, uri);
     XmlSchemas schemas = reflector.Schemas;
     this.description = reflector.ServiceDescription;
     XmlSerializer serializer = ServiceDescription.Serializer;
     this.AddSchemaImports(schemas, uri, reflector.ServiceDescriptions);
     for (int i = 1; i < reflector.ServiceDescriptions.Count; i++)
     {
         ServiceDescription description = reflector.ServiceDescriptions[i];
         Import import = new Import {
             Namespace = description.TargetNamespace
         };
         string key = "wsdl" + i.ToString(CultureInfo.InvariantCulture);
         import.Location = uri + "?wsdl=" + key;
         reflector.ServiceDescription.Imports.Add(import);
         this.wsdlTable.Add(key, description);
     }
     this.discoDoc = new DiscoveryDocument();
     this.discoDoc.References.Add(new ContractReference(uri + "?wsdl", uri));
     foreach (Service service in reflector.ServiceDescription.Services)
     {
         foreach (Port port in service.Ports)
         {
             SoapAddressBinding binding = (SoapAddressBinding) port.Extensions.Find(typeof(SoapAddressBinding));
             if (binding != null)
             {
                 System.Web.Services.Discovery.SoapBinding binding2 = new System.Web.Services.Discovery.SoapBinding {
                     Binding = port.Binding,
                     Address = binding.Location
                 };
                 this.discoDoc.References.Add(binding2);
             }
         }
     }
 }
Beispiel #6
0
 public void Discover()
 {
     if (this.clientType.Binding == null)
     {
         throw new InvalidOperationException(System.Web.Services.Res.GetString("DiscoveryIsNotPossibleBecauseTypeIsMissing1", new object[1]
         {
             (object)this.GetType().FullName
         }));
     }
     else
     {
         foreach (object obj in (IEnumerable) new DiscoveryClientProtocol((HttpWebClientProtocol)this).Discover(this.Url).References)
         {
             System.Web.Services.Discovery.SoapBinding soapBinding = obj as System.Web.Services.Discovery.SoapBinding;
             if (soapBinding != null && this.clientType.Binding.Name == soapBinding.Binding.Name && this.clientType.Binding.Namespace == soapBinding.Binding.Namespace)
             {
                 this.Url = soapBinding.Address;
                 return;
             }
         }
         throw new InvalidOperationException(System.Web.Services.Res.GetString("TheBindingNamedFromNamespaceWasNotFoundIn3", (object)this.clientType.Binding.Name, (object)this.clientType.Binding.Namespace, (object)this.Url));
     }
 }
Beispiel #7
0
        public void Discover()
        {
            BindingInfo bnd = (BindingInfo)type_info.Bindings [0];

            DiscoveryClientProtocol discoverer = new DiscoveryClientProtocol();

            discoverer.Discover(Url);

            foreach (object info in discoverer.AdditionalInformation)
            {
                System.Web.Services.Discovery.SoapBinding sb = info as System.Web.Services.Discovery.SoapBinding;
                if (sb != null && sb.Binding.Name == bnd.Name && sb.Binding.Namespace == bnd.Namespace)
                {
                    Url = sb.Address;
                    return;
                }
            }

            string msg = string.Format(
                "The binding named '{0}' from namespace '{1}' was not found in the discovery document at '{2}'",
                bnd.Name, bnd.Namespace, Url);

            throw new Exception(msg);
        }
Beispiel #8
0
        /// <include file='doc\SoapClientProtocol.uex' path='docs/doc[@for="SoapHttpClientProtocol.Discover"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public void Discover()
        {
            if (clientType.Binding == null)
            {
                throw new InvalidOperationException(Res.GetString(Res.DiscoveryIsNotPossibleBecauseTypeIsMissing1, this.GetType().FullName));
            }
            DiscoveryClientProtocol disco = new DiscoveryClientProtocol(this);
            DiscoveryDocument       doc   = disco.Discover(Url);

            foreach (object item in doc.References)
            {
                System.Web.Services.Discovery.SoapBinding soapBinding = item as System.Web.Services.Discovery.SoapBinding;
                if (soapBinding != null)
                {
                    if (clientType.Binding.Name == soapBinding.Binding.Name &&
                        clientType.Binding.Namespace == soapBinding.Binding.Namespace)
                    {
                        Url = soapBinding.Address;
                        return;
                    }
                }
            }
            throw new InvalidOperationException(Res.GetString(Res.TheBindingNamedFromNamespaceWasNotFoundIn3, clientType.Binding.Name, clientType.Binding.Namespace, Url));
        }
        // See comment on the ServerProtocol.IsCacheUnderPressure method for explanation of the excludeSchemeHostPortFromCachingKey logic.
        internal DiscoveryServerType(Type type, string uri, bool excludeSchemeHostPortFromCachingKey)
            : base(typeof(DiscoveryServerProtocol))
        {
            if (excludeSchemeHostPortFromCachingKey)
            {
                this.UriFixups = new List <Action <Uri> >();
            }
            //
            // parse the uri from a string into a Uri object
            //
            Uri uriObject = new Uri(uri, true);

            //
            // and get rid of the query string if there's one
            //
            uri        = uriObject.GetLeftPart(UriPartial.Path);
            methodInfo = new LogicalMethodInfo(typeof(DiscoveryServerProtocol).GetMethod("Discover", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic));
            ServiceDescriptionReflector reflector = new ServiceDescriptionReflector(this.UriFixups);

            reflector.Reflect(type, uri);

            XmlSchemas schemas = reflector.Schemas;

            this.description = reflector.ServiceDescription;

            // We need to force initialization of ServiceDescription's XmlSerializer since we
            // won't necessarily have the permissions to do it when we actually need it
            XmlSerializer serializer = ServiceDescription.Serializer;

            // add imports to the external schemas
            AddSchemaImports(schemas, uri, reflector.ServiceDescriptions);

            // add imports to the other service descriptions
            for (int i = 1; i < reflector.ServiceDescriptions.Count; i++)
            {
                ServiceDescription description = reflector.ServiceDescriptions[i];
                Import             import      = new Import();
                import.Namespace = description.TargetNamespace;

                //


                string id = "wsdl" + i.ToString(CultureInfo.InvariantCulture);

                import.Location = uri + "?wsdl=" + id;
                this.AddUriFixup(delegate(Uri current)
                {
                    import.Location = CombineUris(current, import.Location);
                });
                reflector.ServiceDescription.Imports.Add(import);
                wsdlTable.Add(id, description);
            }

            discoDoc = new DiscoveryDocument();
            ContractReference contractReference = new ContractReference(uri + "?wsdl", uri);

            this.AddUriFixup(delegate(Uri current)
            {
                contractReference.Ref    = CombineUris(current, contractReference.Ref);
                contractReference.DocRef = CombineUris(current, contractReference.DocRef);
            });
            discoDoc.References.Add(contractReference);

            foreach (Service service in reflector.ServiceDescription.Services)
            {
                foreach (Port port in service.Ports)
                {
                    SoapAddressBinding soapAddress = (SoapAddressBinding)port.Extensions.Find(typeof(SoapAddressBinding));
                    if (soapAddress != null)
                    {
                        System.Web.Services.Discovery.SoapBinding binding = new System.Web.Services.Discovery.SoapBinding();
                        binding.Binding = port.Binding;
                        binding.Address = soapAddress.Location;
                        this.AddUriFixup(delegate(Uri current)
                        {
                            binding.Address = CombineUris(current, binding.Address);
                        });
                        discoDoc.References.Add(binding);
                    }
                }
            }
        }
Beispiel #10
0
		void GenerateDiscoDocument (HttpContext context)
		{
			ServiceDescriptionCollection descs = GetDescriptions ();
			
			DiscoveryDocument doc = new DiscoveryDocument ();
			ContractReference cref = new ContractReference ();
			cref.Ref = _url + "?wsdl";
			cref.DocRef = _url;
			doc.References.Add (cref);
			
			foreach (ServiceDescription desc in descs)
				foreach (Service ser in desc.Services)
					foreach (Port port in ser.Ports)
					{
						SoapAddressBinding sab = port.Extensions.Find (typeof(SoapAddressBinding)) as SoapAddressBinding;
						if (sab != null)
						{
							System.Web.Services.Discovery.SoapBinding dsb = new System.Web.Services.Discovery.SoapBinding ();
							dsb.Address = sab.Location;
							dsb.Binding = port.Binding;
							doc.AdditionalInfo.Add (dsb);
						}
					}

			context.Response.ContentType = "text/xml; charset=utf-8";
			XmlTextWriter xtw = new XmlTextWriter (context.Response.OutputStream, new UTF8Encoding (false));
			xtw.Formatting = Formatting.Indented;
			doc.Write (xtw);
		}
        // See comment on the ServerProtocol.IsCacheUnderPressure method for explanation of the excludeSchemeHostPortFromCachingKey logic.
        internal DiscoveryServerType(Type type, string uri, bool excludeSchemeHostPortFromCachingKey)
            : base(typeof(DiscoveryServerProtocol))
        {
            if (excludeSchemeHostPortFromCachingKey)
            {
                this.UriFixups = new List<Action<Uri>>();
            }            
            //
            // parse the uri from a string into a Uri object
            //
            Uri uriObject = new Uri(uri, true);
            //
            // and get rid of the query string if there's one
            //
            uri = uriObject.GetLeftPart(UriPartial.Path);
            methodInfo = new LogicalMethodInfo(typeof(DiscoveryServerProtocol).GetMethod("Discover", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic));
            ServiceDescriptionReflector reflector = new ServiceDescriptionReflector(this.UriFixups);
            reflector.Reflect(type, uri);

            XmlSchemas schemas = reflector.Schemas;
            this.description = reflector.ServiceDescription;
            
            // We need to force initialization of ServiceDescription's XmlSerializer since we
            // won't necessarily have the permissions to do it when we actually need it
            XmlSerializer serializer = ServiceDescription.Serializer;

            // add imports to the external schemas
            AddSchemaImports(schemas, uri, reflector.ServiceDescriptions);

            // add imports to the other service descriptions
            for (int i = 1; i < reflector.ServiceDescriptions.Count; i++) {
                ServiceDescription description = reflector.ServiceDescriptions[i];
                Import import = new Import();
                import.Namespace = description.TargetNamespace;

                // 


                string id = "wsdl" + i.ToString(CultureInfo.InvariantCulture);

                import.Location = uri + "?wsdl=" + id;
                this.AddUriFixup(delegate(Uri current)
                {
                    import.Location = CombineUris(current, import.Location);
                });
                reflector.ServiceDescription.Imports.Add(import);
                wsdlTable.Add(id, description);
            }

            discoDoc = new DiscoveryDocument();
            ContractReference contractReference = new ContractReference(uri + "?wsdl", uri);
            this.AddUriFixup(delegate(Uri current)
            {
                contractReference.Ref = CombineUris(current, contractReference.Ref);
                contractReference.DocRef = CombineUris(current, contractReference.DocRef);
            });
            discoDoc.References.Add(contractReference);

            foreach (Service service in reflector.ServiceDescription.Services) {
                foreach (Port port in service.Ports) {
                    SoapAddressBinding soapAddress = (SoapAddressBinding)port.Extensions.Find(typeof(SoapAddressBinding));
                    if (soapAddress != null) {
                        System.Web.Services.Discovery.SoapBinding binding = new System.Web.Services.Discovery.SoapBinding();
                        binding.Binding = port.Binding;
                        binding.Address = soapAddress.Location;
                        this.AddUriFixup(delegate(Uri current)
                        {
                            binding.Address = CombineUris(current, binding.Address);
                        });
                        discoDoc.References.Add(binding);
                    }
                }
            }
        }
Beispiel #12
0
        internal DiscoveryServerType(Type type, string uri) : base(typeof(DiscoveryServerProtocol))
        {
            //
            // parse the uri from a string into a Uri object
            //
            Uri uriObject = new Uri(uri, true);

            //
            // and get rid of the query string if there's one
            //
            uri        = uriObject.GetLeftPart(UriPartial.Path);
            methodInfo = new LogicalMethodInfo(typeof(DiscoveryServerProtocol).GetMethod("Discover", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic));
            ServiceDescriptionReflector reflector = new ServiceDescriptionReflector();

            reflector.Reflect(type, uri);

            XmlSchemas schemas = reflector.Schemas;

            this.description = reflector.ServiceDescription;

            // We need to force initialization of ServiceDescription's XmlSerializer since we
            // won't necessarily have the permissions to do it when we actually need it
            XmlSerializer serializer = ServiceDescription.Serializer;

            // add imports to the external schemas
            int count = 0;

            foreach (XmlSchema schema in schemas)
            {
                // CONSIDER, erikc, seems fragile/brittle to use the index here in the URL
                if (schema.Id == null || schema.Id.Length == 0)
                {
                    schema.Id = "schema" + (++count).ToString();
                }
                foreach (ServiceDescription description in reflector.ServiceDescriptions)
                {
                    Import import = new Import();
                    import.Namespace = schema.TargetNamespace;
                    import.Location  = uri + "?schema=" + schema.Id;
                    description.Imports.Add(import);
                }
                schemaTable.Add(schema.Id, schema);
            }

            // add imports to the other service descriptions
            for (int i = 1; i < reflector.ServiceDescriptions.Count; i++)
            {
                ServiceDescription description = reflector.ServiceDescriptions[i];
                Import             import      = new Import();
                import.Namespace = description.TargetNamespace;

                // CONSIDER, erikc, seems kinda brittle to use the index of the description
                // as the URL -- when you add interfaces, reorder methods, etc. this might
                // change which could be irritating.
                string id = "wsdl" + i.ToString();

                import.Location = uri + "?wsdl=" + id;
                reflector.ServiceDescription.Imports.Add(import);
                wsdlTable.Add(id, description);
            }

            discoDoc = new DiscoveryDocument();
            discoDoc.References.Add(new ContractReference(uri + "?wsdl", uri));

            foreach (Service service in reflector.ServiceDescription.Services)
            {
                foreach (Port port in service.Ports)
                {
                    SoapAddressBinding soapAddress = (SoapAddressBinding)port.Extensions.Find(typeof(SoapAddressBinding));
                    if (soapAddress != null)
                    {
                        System.Web.Services.Discovery.SoapBinding binding = new System.Web.Services.Discovery.SoapBinding();
                        binding.Binding = port.Binding;
                        binding.Address = soapAddress.Location;
                        discoDoc.References.Add(binding);
                    }
                }
            }
        }
 private SoapBinding Read8_SoapBinding(bool isNullable, bool checkType)
 {
     XmlQualifiedName type = checkType ? base.GetXsiType() : null;
     bool flag = false;
     if (isNullable)
     {
         flag = base.ReadNull();
     }
     if ((checkType && (type != null)) && ((type.Name != this.id11_SoapBinding) || (type.Namespace != this.id10_Item)))
     {
         throw base.CreateUnknownTypeException(type);
     }
     if (flag)
     {
         return null;
     }
     SoapBinding o = new SoapBinding();
     bool[] flagArray = new bool[2];
     while (base.Reader.MoveToNextAttribute())
     {
         if ((!flagArray[0] && (base.Reader.LocalName == this.id12_address)) && (base.Reader.NamespaceURI == this.id13_Item))
         {
             o.Address = base.Reader.Value;
             flagArray[0] = true;
         }
         else
         {
             if ((!flagArray[1] && (base.Reader.LocalName == this.id14_binding)) && (base.Reader.NamespaceURI == this.id13_Item))
             {
                 o.Binding = base.ToXmlQualifiedName(base.Reader.Value);
                 flagArray[1] = true;
                 continue;
             }
             if (!base.IsXmlnsAttribute(base.Reader.Name))
             {
                 base.UnknownNode(o, ":address, :binding");
             }
         }
     }
     base.Reader.MoveToElement();
     if (base.Reader.IsEmptyElement)
     {
         base.Reader.Skip();
         return o;
     }
     base.Reader.ReadStartElement();
     base.Reader.MoveToContent();
     int whileIterations = 0;
     int readerCount = base.ReaderCount;
     while ((base.Reader.NodeType != XmlNodeType.EndElement) && (base.Reader.NodeType != XmlNodeType.None))
     {
         if (base.Reader.NodeType == XmlNodeType.Element)
         {
             base.UnknownNode(o, "");
         }
         else
         {
             base.UnknownNode(o, "");
         }
         base.Reader.MoveToContent();
         base.CheckReaderCount(ref whileIterations, ref readerCount);
     }
     base.ReadEndElement();
     return o;
 }