Ejemplo n.º 1
0
 void FillItems(ServiceDescriptionCollection descriptions)
 {
     foreach (ServiceDescription element in descriptions)
     {
         Add(element);
     }
 }
Ejemplo n.º 2
0
/*
 *          protected override IList GetMethodParameterAttributes(MethodInfo method, ParameterInfo paramInfo)
 *          {
 *              IList attrs = base.GetMethodParameterAttributes(method, paramInfo);
 *
 *              // Add the XmlElementAttribute if needed
 *              XmlMemberMapping inMemberMapping = inputMembersMapping[paramInfo.Position];
 *              if (inMemberMapping.Namespace != inputMembersMapping.Namespace)
 *              {
 *                  CustomAttributeBuilderBuilder cabb =
 *                              new CustomAttributeBuilderBuilder(typeof(XmlElementAttribute));
 *                  cabb.AddPropertyValue("Namespace", inMemberMapping.Namespace);
 *
 *                  attrs.Add(cabb.Build());
 *              }
 *
 *              return attrs;
 *          }
 */

            #endregion

            #region Private Methods

            private void Initialize(DiscoveryClientDocumentCollection wsDocuments, string bindingName)
            {
                // Service descriptions
                this.wsDescriptions = new ServiceDescriptionCollection();
                XmlSchemas schemas = new XmlSchemas();

                foreach (DictionaryEntry entry in wsDocuments)
                {
                    if (entry.Value is ServiceDescription)
                    {
                        this.wsDescriptions.Add((ServiceDescription)entry.Value);
                    }
                    if (entry.Value is XmlSchema)
                    {
                        schemas.Add((XmlSchema)entry.Value);
                    }
                }

                // XmlSchemaImporter
                foreach (ServiceDescription serviceDescription in this.wsDescriptions)
                {
                    foreach (XmlSchema schema in serviceDescription.Types.Schemas)
                    {
                        if (schemas[schema.TargetNamespace] == null)
                        {
                            schemas.Add(schema);
                        }
                    }
                }
                this.schemaImporter = new XmlSchemaImporter(schemas);

                this.wsBinding = GetWsBinding(this.wsDescriptions, bindingName);
                this.wsUrl     = GetWsUrl(this.wsDescriptions, this.wsBinding);
            }
Ejemplo n.º 3
0
        private void ProcessLocalPaths(DiscoveryClientProtocol client, StringCollection localPaths, XmlSchemas schemas,
                                       ServiceDescriptionCollection descriptions)
        {
            StringEnumerator enumerator = localPaths.GetEnumerator();

            while (enumerator.MoveNext())
            {
                string current   = enumerator.Current;
                string extension = Path.GetExtension(current);
                if (string.Compare(extension, ".discomap", true) == 0)
                {
                    client.ReadAll(current);
                }
                else
                {
                    object document = null;
                    if (string.Compare(extension, ".wsdl", true) == 0)
                    {
                        document = ReadLocalDocument(false, current);
                    }
                    else
                    {
                        if (string.Compare(extension, ".xsd", true) != 0)
                        {
                            throw new InvalidOperationException("Unknown file type " + current);
                        }
                        document = ReadLocalDocument(true, current);
                    }
                    if (document != null)
                    {
                        AddDocument(current, document, schemas, descriptions);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void ProcessRemoteUrls(DiscoveryClientProtocol client, StringCollection urls, XmlSchemas schemas,
                                       ServiceDescriptionCollection descriptions)
        {
            StringEnumerator enumerator = urls.GetEnumerator();

            while (enumerator.MoveNext())
            {
                string current = enumerator.Current;
                try
                {
                    DiscoveryDocument document = client.DiscoverAny(current);
                    client.ResolveAll();
                }
                catch (Exception exception)
                {
                    throw new InvalidOperationException("General Error " + current, exception);
                }
            }
            IDictionaryEnumerator enumerator2 = client.Documents.GetEnumerator();

            while (enumerator2.MoveNext())
            {
                var entry = (DictionaryEntry)enumerator2.Current;
                AddDocument((string)entry.Key, entry.Value, schemas, descriptions);
            }
        }
Ejemplo n.º 5
0
 void IWsdlImportExtension.BeforeImport(ServiceDescriptionCollection wsdlDocuments,
                                        XmlSchemaSet xmlSchemas,
                                        ICollection <System.Xml.XmlElement> policy)
 {
     this.WsdlDocuments = wsdlDocuments;
     this.XmlSchemas    = xmlSchemas;
 }
Ejemplo n.º 6
0
    public static void Main()
    {
        try
        {
            ServiceDescription myServiceDescription1 =
                ServiceDescription.Read("DataTypes_CS.wsdl");
            ServiceDescription myServiceDescription2 =
                ServiceDescription.Read("MathService_CS.wsdl");
// <Snippet1>
// <Snippet2>
            // Create the object of 'ServiceDescriptionCollection' class.
            ServiceDescriptionCollection myCollection =
                new ServiceDescriptionCollection();
            // Add 'ServiceDescription' objects.
            myCollection.Add(myServiceDescription1);
            myCollection.Add(myServiceDescription2);
// </Snippet2>
// </Snippet1>
// <Snippet3>
            // Display element properties in collection using 'Item' property.
            for (int i = 0; i < myCollection.Count; i++)
            {
                Console.WriteLine(myCollection[i].TargetNamespace);
            }
// </Snippet3>
        }
        catch (Exception e)
        {
            Console.WriteLine("The following exception was raised: {0}", e.Message);
        }
    }
Ejemplo n.º 7
0
    static ArrayList GetBindingTypes(ServiceDescriptionCollection col)
    {
        ServiceDescription doc  = col [0];
        ArrayList          list = new ArrayList();

        foreach (Service s in doc.Services)
        {
            foreach (Port p in s.Ports)
            {
                Binding bin = col.GetBinding(p.Binding);
                if (bin.Extensions.Find(typeof(System.Web.Services.Description.SoapBinding)) != null)
                {
                    if (!list.Contains("Soap"))
                    {
                        list.Add("Soap");
                    }
                }

                HttpBinding ext = (HttpBinding)bin.Extensions.Find(typeof(HttpBinding));
                if (ext != null)
                {
                    if (ext.Verb == "POST")
                    {
                        list.Add("HttpPost");
                    }
                    else
                    {
                        list.Add("HttpGet");
                    }
                }
            }
        }
        return(list);
    }
        private void AddSchemaImports(XmlSchemas schemas, string uri, ServiceDescriptionCollection descriptions)
        {
            int num = 0;

            foreach (XmlSchema schema in schemas)
            {
                if (schema != null)
                {
                    if ((schema.Id == null) || (schema.Id.Length == 0))
                    {
                        schema.Id = "schema" + ++num.ToString(CultureInfo.InvariantCulture);
                    }
                    string location = uri + "?schema=" + schema.Id;
                    foreach (ServiceDescription description in descriptions)
                    {
                        if (description.Types.Schemas.Count == 0)
                        {
                            XmlSchema schema2 = new XmlSchema {
                                TargetNamespace = description.TargetNamespace
                            };
                            schema.ElementFormDefault = XmlSchemaForm.Qualified;
                            this.AddExternal(schema2, schema.TargetNamespace, location);
                            description.Types.Schemas.Add(schema2);
                        }
                        else
                        {
                            this.AddExternal(description.Types.Schemas[0], schema.TargetNamespace, location);
                        }
                    }
                    this.schemaTable.Add(schema.Id, schema);
                }
            }
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
 void IWsdlImportExtension.BeforeImport(
     ServiceDescriptionCollection wsdlDocuments,
     XmlSchemaSet xmlSchemas,
     ICollection <XmlElement> policy)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 11
0
    public static void Main()
    {
        try
        {
            ServiceDescription myServiceDescription1 =
                ServiceDescription.Read("DataTypes_CS.wsdl");
            ServiceDescription myServiceDescription2 =
                ServiceDescription.Read("MathService_CS.wsdl");

            // Create the object of 'ServiceDescriptionCollection' class.
            ServiceDescriptionCollection myCollection =
                new ServiceDescriptionCollection();
            // Add 'ServiceDescription' objects.
            myCollection.Add(myServiceDescription1);
            myCollection.Add(myServiceDescription2);
// <Snippet1>
            // Construct an XML qualified name.
            XmlQualifiedName myXmlQualifiedName =
                new XmlQualifiedName("MathServiceSoap", "http://tempuri2.org/");
            // Get the PortType from the collection.
            PortType myPort = myCollection.GetPortType(myXmlQualifiedName);
// </Snippet1>
            Console.WriteLine("Specified PortType is a member of ServiceDescription "
                              + "instances within the collection.");
        }
        catch (Exception e)
        {
            Console.WriteLine("The following exception was raised: {0}", e.Message);
        }
    }
Ejemplo n.º 12
0
 private void ProcessLocalPaths(DiscoveryClientProtocol client, StringCollection localPaths, XmlSchemas schemas,
                                ServiceDescriptionCollection descriptions)
 {
     foreach (string text1 in localPaths)
     {
         string text2 = Path.GetExtension(text1);
         if (string.Compare(text2, ".discomap", true) == 0)
         {
             client.ReadAll(text1);
         }
         else
         {
             object obj1 = null;
             if (string.Compare(text2, ".wsdl", true) == 0)
             {
                 obj1 = ReadLocalDocument(false, text1);
             }
             else
             {
                 if (string.Compare(text2, ".xsd", true) != 0)
                 {
                     throw new InvalidOperationException("Unknown file type " + text1);
                 }
                 obj1 = ReadLocalDocument(true, text1);
             }
             if (obj1 != null)
             {
                 AddDocument(text1, obj1, schemas, descriptions);
             }
         }
     }
 }
        // See comment on the ServerProtocol.IsCacheUnderPressure method for explanation of the excludeSchemeHostPortFromCachingKey logic.
        internal DocumentationServerType(Type type, string uri, bool excludeSchemeHostPortFromCachingKey)
            : base(typeof(DocumentationServerProtocol))
        {
            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(DocumentationServerProtocol).GetMethod("Documentation", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic));
            ServiceDescriptionReflector reflector = new ServiceDescriptionReflector(this.UriFixups);

            reflector.Reflect(type, uri);
            schemas                     = reflector.Schemas;
            serviceDescriptions         = reflector.ServiceDescriptions;
            schemasWithPost             = reflector.SchemasWithPost;
            serviceDescriptionsWithPost = reflector.ServiceDescriptionsWithPost;
        }
Ejemplo n.º 14
0
    public static void Main()
    {
        ServiceDescription myServiceDescription =
            ServiceDescription.Read("MimePartCollection_1_Input_cs.wsdl");
        ServiceDescriptionCollection myServiceDescriptionCol =
            new ServiceDescriptionCollection();

        myServiceDescriptionCol.Add(myServiceDescription);
        XmlQualifiedName myXmlQualifiedName =
            new  XmlQualifiedName("MimeServiceHttpPost", "http://tempuri.org/");
        // Create a 'Binding' object.
        Binding          myBinding          = myServiceDescriptionCol.GetBinding(myXmlQualifiedName);
        OperationBinding myOperationBinding = null;

        for (int i = 0; i < myBinding.Operations.Count; i++)
        {
            if (myBinding.Operations[i].Name.Equals("AddNumbers"))
            {
                myOperationBinding = myBinding.Operations[i];
            }
        }
        OutputBinding myOutputBinding = myOperationBinding.Output;
        MimeMultipartRelatedBinding myMimeMultipartRelatedBinding = null;
        IEnumerator myIEnumerator = myOutputBinding.Extensions.GetEnumerator();

        while (myIEnumerator.MoveNext())
        {
            myMimeMultipartRelatedBinding = (MimeMultipartRelatedBinding)myIEnumerator.Current;
        }
        // Create an instances of 'MimePartCollection'.
        MimePartCollection myMimePartCollection = new MimePartCollection();

        myMimePartCollection = myMimeMultipartRelatedBinding.Parts;

        Console.WriteLine("Total number of mimepart elements initially is: "
                          + myMimePartCollection.Count);
        // Create an instance of 'MimePart'.
        MimePart myMimePart = new MimePart();
        // Create an instance of 'MimeXmlBinding'.
        MimeXmlBinding myMimeXmlBinding = new MimeXmlBinding();

        myMimeXmlBinding.Part = "body";
        myMimePart.Extensions.Add(myMimeXmlBinding);
        // Insert a mimepart at first position.
        myMimePartCollection.Insert(0, myMimePart);
        Console.WriteLine("Inserting a mimepart object...");
        if (myMimePartCollection.Contains(myMimePart))
        {
            Console.WriteLine("'MimePart' is succesffully added at position: "
                              + myMimePartCollection.IndexOf(myMimePart));
            Console.WriteLine("Total number of mimepart elements after inserting is: "
                              + myMimePartCollection.Count);
        }
        myServiceDescription.Write("MimePartCollection_1_Output_CS.wsdl");
        Console.WriteLine("MimePartCollection_1_Output_CS.wsdl has been generated successfully.");
    }
Ejemplo n.º 15
0
 internal static void EnumerateDocumentedItems(ServiceDescriptionCollection wsdls, Dictionary <string, string> documentedItems)
 {
     foreach (ServiceDescription wsdl in wsdls)
     {
         foreach (XmlSchema schema in wsdl.Types.Schemas)
         {
             EnumerateDocumentedItems(schema.Items, documentedItems);
         }
     }
 }
Ejemplo n.º 16
0
 void DiscoveredWebServices(ServiceDescriptionCollection services)
 {
     ServiceDescriptionMessage = String.Format("{0} service(s) found at address {1}", services.Count, discoveryUri);
     if (services.Count > 0)
     {
         AddUrlToHistory(discoveryUri);
     }
     DefaultNameSpace = GetDefaultNamespace();
     FillItems(services);
     string referenceName = ServiceReferenceHelper.GetReferenceName(discoveryUri);
 }
Ejemplo n.º 17
0
 internal ServiceDescriptionCollection GetDescriptions()
 {
     if (_descriptions == null)
     {
         ServiceDescriptionReflector reflector = new ServiceDescriptionReflector();
         reflector.Reflect(ServiceType, _url);
         _schemas      = reflector.Schemas;
         _descriptions = reflector.ServiceDescriptions;
     }
     return(_descriptions);
 }
Ejemplo n.º 18
0
        public static void Generate(ArrayList services, ArrayList schemas, string binOper, string protocol)
        {
            ServiceDescriptionCollection descCol = new ServiceDescriptionCollection();

            foreach (ServiceDescription sd in services)
            {
                descCol.Add(sd);
            }

            XmlSchemas schemaCol;

            if (schemas.Count > 0)
            {
                schemaCol = new XmlSchemas();
                foreach (XmlSchema sc in schemas)
                {
                    schemaCol.Add(sc);
                }
            }
            else
            {
                schemaCol = descCol[0].Types.Schemas;
            }

            string oper, bin = null;

            int i = binOper.IndexOf('/');

            if (i != -1)
            {
                oper = binOper.Substring(i + 1);
                bin  = binOper.Substring(0, i);
            }
            else
            {
                oper = binOper;
            }

            ConsoleSampleGenerator sg = new ConsoleSampleGenerator(descCol, schemaCol);

            string req, resp;

            sg.GenerateMessages(oper, bin, protocol, out req, out resp);

            Console.WriteLine();
            Console.WriteLine("Sample request message:");
            Console.WriteLine();
            Console.WriteLine(req);
            Console.WriteLine();
            Console.WriteLine("Sample response message:");
            Console.WriteLine();
            Console.WriteLine(resp);
        }
        internal DocumentationServerType(Type type, string uri) : base(typeof(DocumentationServerProtocol))
        {
            uri             = new Uri(uri, true).GetLeftPart(UriPartial.Path);
            this.methodInfo = new LogicalMethodInfo(typeof(DocumentationServerProtocol).GetMethod("Documentation", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance));
            ServiceDescriptionReflector reflector = new ServiceDescriptionReflector();

            reflector.Reflect(type, uri);
            this.schemas                     = reflector.Schemas;
            this.serviceDescriptions         = reflector.ServiceDescriptions;
            this.schemasWithPost             = reflector.SchemasWithPost;
            this.serviceDescriptionsWithPost = reflector.ServiceDescriptionsWithPost;
        }
Ejemplo n.º 20
0
        void IWsdlImportExtension.BeforeImport(
            ServiceDescriptionCollection wsdlDocuments,
            XmlSchemaSet xmlSchemas,
            ICollection <XmlElement> policy)
        {
            if (!Enabled)
            {
                return;
            }

            impl.BeforeImport(wsdlDocuments, xmlSchemas, policy);
        }
Ejemplo n.º 21
0
            /// <summary>
            /// Search and returns the operation that matches the specified method.
            /// </summary>
            private Operation GetOperation(ServiceDescriptionCollection descriptions, Binding binding, MethodInfo method)
            {
                PortType portType = descriptions.GetPortType(binding.Type);

                foreach (Operation operation in portType.Operations)
                {
                    if (operation.Name == method.Name)
                    {
                        return(operation);
                    }
                }
                throw new ApplicationException(String.Format("No Operation has been found for the method '{0}' in the WSDL document located at '{1}'.", method.Name, serviceUri.Description));
            }
Ejemplo n.º 22
0
        void IWsdlImportExtension.BeforeImport(ServiceDescriptionCollection wsdlDocuments, XmlSchemaSet xmlSchemas, ICollection <XmlElement> policy)
        {
            // unite both inline (in WSDLs) and standalone schemas
            _serviceModel.XmlSchemas = wsdlDocuments.MergeSchemas(xmlSchemas);

            var operationMessages = GetOperationMessages(wsdlDocuments);

            operationMessages.ForEach(o => _serviceModel.OperationMessages.Add(o.QualifiedName, o));

            var complexTypes = GetComplexTypes(_serviceModel.XmlSchemas);

            complexTypes.ForEach(c => _serviceModel.ComplexTypes.Add(c));
        }
Ejemplo n.º 23
0
        public WsdlImporter(
            MetadataSet metadata,
            IEnumerable <IPolicyImportExtension> policyImportExtensions,
            IEnumerable <IWsdlImportExtension> wsdlImportExtensions)
            : base(policyImportExtensions)
        {
            if (metadata == null)
            {
                throw new ArgumentNullException("metadata");
            }

            if (wsdlImportExtensions == null)
            {
                wsdl_extensions = new KeyedByTypeCollection <IWsdlImportExtension> ();

                wsdl_extensions.Add(new DataContractSerializerMessageContractImporter());
                wsdl_extensions.Add(new XmlSerializerMessageContractImporter());
                wsdl_extensions.Add(new MessageEncodingBindingElementImporter());
                wsdl_extensions.Add(new TransportBindingElementImporter());
                wsdl_extensions.Add(new StandardBindingImporter());
            }
            else
            {
                wsdl_extensions = new KeyedByTypeCollection <IWsdlImportExtension> (wsdlImportExtensions);
            }

            // It is okay to fill these members immediately when WsdlImporter.ctor() is invoked
            // i.e. after this .ctor(), those metadata docs are not considered anymore.
            this.metadata       = metadata;
            this.wsdl_documents = new ServiceDescriptionCollection();
            this.xmlschemas     = new XmlSchemaSet();
            this.policies       = new List <XmlElement> ();
            this.contractHash   = new Dictionary <PortType, ContractDescription> ();
            this.bindingHash    = new Dictionary <WSBinding, ServiceEndpoint> ();
            this.endpointHash   = new Dictionary <Port, ServiceEndpoint> ();

            foreach (MetadataSection ms in metadata.MetadataSections)
            {
                if (ms.Dialect == MetadataSection.ServiceDescriptionDialect &&
                    ms.Metadata.GetType() == typeof(WSServiceDescription))
                {
                    wsdl_documents.Add((WSServiceDescription)ms.Metadata);
                }
                else
                if (ms.Dialect == MetadataSection.XmlSchemaDialect &&
                    ms.Metadata.GetType() == typeof(XmlSchema))
                {
                    xmlschemas.Add((XmlSchema)ms.Metadata);
                }
            }
        }
Ejemplo n.º 24
0
        ServiceDescriptionCollection GetServiceDescriptionCollection(DiscoveryClientProtocol protocol)
        {
            ServiceDescriptionCollection services = new ServiceDescriptionCollection();

            foreach (DictionaryEntry entry in protocol.References)
            {
                ContractReference          contractRef  = entry.Value as ContractReference;
                DiscoveryDocumentReference discoveryRef = entry.Value as DiscoveryDocumentReference;
                if (contractRef != null)
                {
                    services.Add(contractRef.Contract);
                }
            }
            return(services);
        }
Ejemplo n.º 25
0
        public static ServiceDescription FindRootDescription(ServiceDescriptionCollection wsdls)
        {
            ServiceDescription rootDescription = null;

            //Find the "root" service description
            foreach (ServiceDescription description in wsdls)
            {
                if (description.Services.Count > 0)
                {
                    rootDescription = description.Services[0].ServiceDescription;
                    break;
                }
            }
            return(rootDescription);
        }
Ejemplo n.º 26
0
        private ServiceDescriptionCollection GetServiceDescriptions(DiscoveryClientProtocol protocol)
        {
            ServiceDescriptionCollection services = new ServiceDescriptionCollection();

            protocol.ResolveOneLevel();

            foreach (DictionaryEntry entry in protocol.References)
            {
                ContractReference contractRef = entry.Value as ContractReference;
                if (contractRef != null)
                {
                    services.Add(contractRef.Contract);
                }
            }
            return(services);
        }
Ejemplo n.º 27
0
    public static void Main()
    {
        ServiceDescription myServiceDescription =
            ServiceDescription.Read("MimePart_3_Input_cs.wsdl");
        ServiceDescriptionCollection myServiceDescriptionCol =
            new ServiceDescriptionCollection();

        myServiceDescriptionCol.Add(myServiceDescription);
        XmlQualifiedName myXmlQualifiedName =
            new XmlQualifiedName("MimeServiceHttpPost", "http://tempuri.org/");

        // Create the Binding.
        Binding myBinding =
            myServiceDescriptionCol.GetBinding(myXmlQualifiedName);
        OperationBinding myOperationBinding = null;

        for (int i = 0; i < myBinding.Operations.Count; i++)
        {
            if (myBinding.Operations[i].Name.Equals("AddNumbers"))
            {
                myOperationBinding = myBinding.Operations[i];
            }
        }
// <Snippet2>
// <Snippet3>
        // Create the OutputBinding.
        OutputBinding  myOutputBinding  = myOperationBinding.Output;
        MimeXmlBinding myMimeXmlBinding = new MimeXmlBinding();

        myMimeXmlBinding.Part = "body";

        // Create the MimePart.
        MimePart myMimePart = new MimePart();

        myMimePart.Extensions.Add(myMimeXmlBinding);
        MimeMultipartRelatedBinding myMimePartRelatedBinding =
            new MimeMultipartRelatedBinding();

        // Add the MimePart to the MimePartRelatedBinding.
        myMimePartRelatedBinding.Parts.Add(myMimePart);
        myOutputBinding.Extensions.Add(myMimePartRelatedBinding);
// </Snippet3>
// </Snippet2>
        myServiceDescription.Write("MimePart_3_Output_CS.wsdl");
        Console.WriteLine(
            "MimePart_3_Output_CS.wsdl has been generated successfully.");
    }
Ejemplo n.º 28
0
        public WsdlImporter(
            MetadataSet metadata,
            IEnumerable <IPolicyImportExtension> policyImportExtensions,
            IEnumerable <IWsdlImportExtension> wsdlImportExtensions)
            : base(policyImportExtensions)
        {
            if (metadata == null)
            {
                throw new ArgumentNullException("metadata");
            }

            if (wsdlImportExtensions == null)
            {
                wsdl_extensions = new KeyedByTypeCollection <IWsdlImportExtension> ();

                wsdl_extensions.Add(new StandardBindingImporter());
                wsdl_extensions.Add(new TransportBindingElementImporter());
                //wsdl_extensions.Add (new MessageEncodingBindingElementImporter ());
                wsdl_extensions.Add(new XmlSerializerMessageContractImporter());
                wsdl_extensions.Add(new DataContractSerializerMessageContractImporter());
            }
            else
            {
                wsdl_extensions = new KeyedByTypeCollection <IWsdlImportExtension> (wsdlImportExtensions);
            }

            this.metadata       = metadata;
            this.wsdl_documents = new ServiceDescriptionCollection();
            this.xmlschemas     = new XmlSchemaSet();
            this.policies       = new List <XmlElement> ();

            foreach (MetadataSection ms in metadata.MetadataSections)
            {
                if (ms.Dialect == MetadataSection.ServiceDescriptionDialect &&
                    ms.Metadata.GetType() == typeof(WSServiceDescription))
                {
                    wsdl_documents.Add((WSServiceDescription)ms.Metadata);
                }
                else
                if (ms.Dialect == MetadataSection.XmlSchemaDialect &&
                    ms.Metadata.GetType() == typeof(XmlSchema))
                {
                    xmlschemas.Add((XmlSchema)ms.Metadata);
                }
            }
        }
Ejemplo n.º 29
0
        public void Add(ServiceDescriptionCollection serviceDescriptions)
        {
            if (serviceDescriptions.Count == 0)
            {
                return;
            }

            webServicesListView.BeginUpdate();
            try {
                foreach (ServiceDescription description in serviceDescriptions)
                {
                    Add(description);
                }
            } finally {
                webServicesListView.EndUpdate();
            }
        }
    public static void Main()
    {
        try
        {
            // Get ServiceDescription objects.
            ServiceDescription myServiceDescription1 =
                ServiceDescription.Read("DataTypes_CS.wsdl");
            ServiceDescription myServiceDescription2 =
                ServiceDescription.Read("MathService_CS.wsdl");

            // Set the names of the ServiceDescriptions.
            myServiceDescription1.Name = "DataTypes";
            myServiceDescription2.Name = "MathService";

            // Create a ServiceDescriptionCollection.
            ServiceDescriptionCollection myServiceDescriptionCollection =
                new ServiceDescriptionCollection();

            // Add the ServiceDescriptions to the collection.
            myServiceDescriptionCollection.Add(myServiceDescription1);
            myServiceDescriptionCollection.Add(myServiceDescription2);

            // Display the elements of the collection using the indexer.
            Console.WriteLine("Elements in the collection: ");
            for (int i = 0; i < myServiceDescriptionCollection.Count; i++)
            {
                Console.WriteLine(myServiceDescriptionCollection[i].Name);
            }

            // Construct an XML qualified name.
            XmlQualifiedName myXmlQualifiedName =
                new XmlQualifiedName("MathServiceSoap", "http://tempuri2.org/");

            // Get the Binding from the collection.
            Binding myBinding =
                myServiceDescriptionCollection.GetBinding(myXmlQualifiedName);

            Console.WriteLine("Binding found in collection with name: " +
                              myBinding.ServiceDescription.Name);
        }
        catch (Exception e)
        {
            Console.WriteLine("The following exception was raised: {0}", e.Message);
        }
    }
 public static bool CheckConformance(System.Web.Services.WsiProfiles claims, ServiceDescriptionCollection descriptions, BasicProfileViolationCollection violations)
 {
 }
Ejemplo n.º 32
0
	public static void RetrieveServiceData (ServiceData sd, DiscoveryClientProtocol contract)
	{
		ServiceDescriptionCollection col = new ServiceDescriptionCollection ();
		foreach (object doc in contract.Documents.Values)
			if (doc is ServiceDescription) col.Add ((ServiceDescription)doc);
		
		string loc = GetLocation (col[0]);
		if (loc != null)
		{
			WebResponse res = null;
			try
			{
				WebRequest req = (WebRequest)WebRequest.Create (loc);
				req.Timeout = 15000;
				res = req.GetResponse ();
			}
			catch (Exception ex)
			{
				WebException wex = ex as WebException;
				if (wex != null) res = wex.Response;
			}
			if (res != null)
			{
				sd.ServerType = res.Headers ["Server"] + " # " + res.Headers ["X-Powered-By"];
			}
		}
		
		ArrayList bins = GetBindingTypes (col);
		sd.Protocols = (string[]) bins.ToArray(typeof(string));
	}
Ejemplo n.º 33
0
	static ArrayList GetBindingTypes (ServiceDescriptionCollection col)
	{
		ServiceDescription doc = col [0];
		ArrayList list = new ArrayList ();
		foreach (Service s in doc.Services)
		{
			foreach (Port p in s.Ports)
			{
				Binding bin = col.GetBinding (p.Binding);
				if (bin.Extensions.Find (typeof (System.Web.Services.Description.SoapBinding)) != null)
					if (!list.Contains ("Soap")) list.Add ("Soap");
					
				HttpBinding ext = (HttpBinding) bin.Extensions.Find (typeof (HttpBinding));
				if (ext != null)
				{
					if (ext.Verb == "POST") list.Add ("HttpPost");
					else list.Add ("HttpGet");
				}
			}
		}
		return list;
	}