protected override async Task <string> GenerateDescriptionFiles(DotNetProject dotNetProject, FilePath basePath)
        {
            if (!dotNetProject.Items.GetAll <WebReferencesDir> ().Any())
            {
                var met = new WebReferencesDir(basePath.ParentDirectory);
                dotNetProject.Items.Add(met);
            }

            WebReferenceUrl wru = dotNetProject.Items.GetAll <WebReferenceUrl> ().FirstOrDefault(m => m.RelPath.CanonicalPath == basePath);

            if (wru == null)
            {
                wru         = new WebReferenceUrl(protocol.Url);
                wru.RelPath = basePath;
                dotNetProject.Items.Add(wru);
            }

            DiscoveryClientResultCollection files = await Task.Run(() => {
                protocol.ResolveAll();
                return(protocol.WriteAll(basePath, "Reference.map"));
            });

            foreach (DiscoveryClientResult dr in files)
            {
                dotNetProject.AddFile(new FilePath(Path.GetFileName(dr.Filename)).ToAbsolute(basePath), BuildAction.None);
            }

            return(Path.Combine(basePath, "Reference.map"));
        }
Exemple #2
0
    static void Main()
    {
        try
        {
            DiscoveryClientProtocol myDiscoveryClientProtocol =
                new DiscoveryClientProtocol();

            // Get the collection holding DiscoveryClientResult objects.
            DiscoveryClientResultCollection myDiscoveryClientResultCollection =
                myDiscoveryClientProtocol.ReadAll("results.discomap");
            Console.WriteLine("The number of DiscoveryClientResult objects: "
                              + myDiscoveryClientResultCollection.Count);
            Console.WriteLine("Displaying the items in the collection:");

            // Iterate through the collection and display the properties
            // of each DiscoveryClientResult in it.
            foreach (DiscoveryClientResult myDiscoveryClientResult in
                     myDiscoveryClientResultCollection)
            {
                Console.WriteLine(
                    "Type of reference in the discovery document: "
                    + myDiscoveryClientResult.ReferenceTypeName);
                Console.WriteLine("Url for the reference: "
                                  + myDiscoveryClientResult.Url);
                Console.WriteLine("File for saving the reference: "
                                  + myDiscoveryClientResult.Filename);
            }
        }
        catch (Exception e)
        {
            Console.WriteLine("Error is " + e.Message);
        }
    }
Exemple #3
0
        protected override string GenerateDescriptionFiles(DotNetProject project, FilePath basePath)
        {
            if (!project.Items.GetAll <WebReferencesDir> ().Any())
            {
                WebReferencesDir met = new WebReferencesDir();
                met.Path = basePath.ParentDirectory;
                project.Items.Add(met);
            }

            WebReferenceUrl wru = project.Items.GetAll <WebReferenceUrl> ().FirstOrDefault(m => m.RelPath.CanonicalPath == basePath);

            if (wru == null)
            {
                wru         = new WebReferenceUrl(protocol.Url);
                wru.RelPath = basePath;
                project.Items.Add(wru);
            }

            protocol.ResolveAll();
            DiscoveryClientResultCollection files = protocol.WriteAll(basePath, "Reference.map");

            foreach (DiscoveryClientResult dr in files)
            {
                project.AddFile(new FilePath(dr.Filename).ToAbsolute(basePath), BuildAction.None);
            }

            return(Path.Combine(basePath, "Reference.map"));
        }
Exemple #4
0
        public void ShouldGetWritenMetadataDocumentsToFiles()
        {
            string            wsdlLocation          = ConfigurationLoader.GetConfigurationFilePath(@"SampleData\DescriptionModel\MockService.wsdl");
            MetadataDiscovery instance              = new MetadataDiscovery(wsdlLocation);
            string            mapFile               = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + @"\Test\", "MockService.map");
            DiscoveryClientResultCollection results = instance.WriteMetadata(mapFile);

            Assert.AreEqual <int>(4, results.Count);
        }
Exemple #5
0
        ReferenceGroup ConvertMapFile(string mapFile)
        {
            var prot = new DiscoveryClientProtocol();
            DiscoveryClientResultCollection files = prot.ReadAll(mapFile);

            var map = new ReferenceGroup();

            if (refGroup != null)
            {
                map.ClientOptions = refGroup.ClientOptions;
                map.ID            = refGroup.ID;
            }
            else
            {
                map.ClientOptions = defaultOptions;
                map.ID            = Guid.NewGuid().ToString();
            }

            var sources = new Dictionary <string, int> ();

            foreach (DiscoveryClientResult res in files)
            {
                string url = res.Url;
                var    uri = new Uri(url);
                if (!string.IsNullOrEmpty(uri.Query))
                {
                    url = url.Substring(0, url.Length - uri.Query.Length);
                }
                int nSource;
                if (!sources.TryGetValue(url, out nSource))
                {
                    nSource       = sources.Count + 1;
                    sources [url] = nSource;
                    var ms = new MetadataSource();
                    ms.Address  = url;
                    ms.Protocol = uri.Scheme;
                    ms.SourceId = nSource.ToString();
                    map.MetadataSources.Add(ms);
                }
                var file = new MetadataFile();
                file.FileName  = res.Filename;
                file.ID        = Guid.NewGuid().ToString();
                file.SourceId  = nSource.ToString();
                file.SourceUrl = res.Url;
                switch (Path.GetExtension(file.FileName).ToLower())
                {
                case ".disco": file.MetadataType = "Disco"; break;

                case ".wsdl": file.MetadataType = "Wsdl"; break;

                case ".xsd": file.MetadataType = "Schema"; break;
                }
                map.Metadata.Add(file);
            }
            map.Save(mapFile);
            return(map);
        }
Exemple #6
0
    static void Main()
    {
        try
        {
            DiscoveryClientProtocol myDiscoveryClientProtocol =
                new DiscoveryClientProtocol();

            // Get the collection of DiscoveryClientResult objects.
            DiscoveryClientResultCollection myDiscoveryClientResultCollection =
                myDiscoveryClientProtocol.ReadAll("results.discomap");
            Console.WriteLine("The number of DiscoveryClientResult objects: "
                              + myDiscoveryClientResultCollection.Count);
            Console.WriteLine("Removing a DiscoveryClientResult "
                              + "from the collection...");

            // Remove first DiscoveryClientResult from the collection.
            myDiscoveryClientResultCollection.Remove
                (myDiscoveryClientResultCollection[0]);
            Console.WriteLine("Adding a DiscoveryClientResult "
                              + "to the collection...");
// <Snippet1>
            // Initialize a new instance of the DiscoveryClientResult class.
            DiscoveryClientResult myDiscoveryClientResult =
                new DiscoveryClientResult(
                    typeof(System.Web.Services.Discovery.DiscoveryDocumentReference),
                    "http://localhost/Discovery/Service1_cs.asmx?disco",
                    "Service1_cs.disco");

            // Add the DiscoveryClientResult to the collection.
            myDiscoveryClientResultCollection.Add(myDiscoveryClientResult);
// </Snippet1>
            Console.WriteLine("Displaying the items in the collection");
            for (int i = 0; i < myDiscoveryClientResultCollection.Count; i++)
            {
                DiscoveryClientResult myClientResult =
                    myDiscoveryClientResultCollection[i];
                Console.WriteLine("DiscoveryClientResult Object " + (i + 1));
                Console.WriteLine("Type of reference in the discovery document: "
                                  + myClientResult.ReferenceTypeName);
                Console.WriteLine("URL for reference: " + myClientResult.Url);
                Console.WriteLine("File for saving the reference: "
                                  + myClientResult.Filename);
            }
        }
        catch (Exception e)
        {
            Console.WriteLine("Error is " + e.Message);
        }
    }
Exemple #7
0
    static void Main()
    {
        try
        {
            DiscoveryClientProtocol myDiscoveryClientProtocol =
                new DiscoveryClientProtocol();

            // Get the collection of DiscoveryClientResult objects.
            DiscoveryClientResultCollection myDiscoveryClientResultCollection =
                myDiscoveryClientProtocol.ReadAll("results.discomap");
            Console.WriteLine(
                "Removing a DiscoveryClientResult from the collection...");

            // Remove the first DiscoveryClientResult from the collection.
            myDiscoveryClientResultCollection.Remove(
                myDiscoveryClientResultCollection[0]);
            Console.WriteLine("Adding a DiscoveryClientResult" +
                              " to the collection...");
            DiscoveryClientResult myDiscoveryClientResult =
                new DiscoveryClientResult();

            // Set the DiscoveryDocumentReference class as the type of
            // reference in the discovery document.
            myDiscoveryClientResult.ReferenceTypeName =
                "System.Web.Services.Discovery.DiscoveryDocumentReference";

            // Set the URL for the reference.
            myDiscoveryClientResult.Url =
                "http://localhost/Discovery/Service1_cs.asmx?disco";

            // Set the name of the file in which the reference is saved.
            myDiscoveryClientResult.Filename = "Service1_cs.disco";

            // Add myDiscoveryClientResult to the collection.
            myDiscoveryClientResultCollection.Add(myDiscoveryClientResult);
            if (myDiscoveryClientResultCollection.Contains(myDiscoveryClientResult))
            {
                Console.WriteLine(
                    "Instance of DiscoveryClientResult found in the Collection");
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("Error is " + ex.Message);
        }
    }
Exemple #8
0
    static void Main()
    {
        string outputDirectory           = "c:\\InetPub\\wwwroot";
        DiscoveryClientProtocol myClient = new DiscoveryClientProtocol();

        //  Use default credentials to access the URL being discovered.
        myClient.Credentials = CredentialCache.DefaultCredentials;
        try
        {
            DiscoveryDocument myDocument;

            // Discover the supplied URL to determine if it is a discovery document.
            myDocument = myClient.Discover("http://localhost/MathService_cs.vsdisco");
            myClient.ResolveAll();
            DiscoveryClientResultCollection myCollection =
                myClient.WriteAll(outputDirectory, "MyDiscoMap.discomap");
// <Snippet2>
// <Snippet3>
            // Get the DiscoveryClientProtocol.DiscoveryClientResultsFile.
            DiscoveryClientProtocol.DiscoveryClientResultsFile myResultFile =
                new DiscoveryClientProtocol.DiscoveryClientResultsFile();
            XmlSerializer mySerializer = new XmlSerializer(myResultFile.GetType());
            XmlReader     reader       = new XmlTextReader("http://localhost/MyDiscoMap.discomap");
            myResultFile = (DiscoveryClientProtocol.DiscoveryClientResultsFile)
                           mySerializer.Deserialize(reader);

            // Get a collection of DiscoveryClientResult objects.
            DiscoveryClientResultCollection myResultcollection = myResultFile.Results;

            Console.WriteLine("Referred file(s): ");
            foreach (DiscoveryClientResult myResult in myResultcollection)
            {
                Console.WriteLine(myResult.Filename);
            }
// </Snippet3>
// </Snippet2>
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        }
    }
    static void Main()
    {
        try
        {
            DiscoveryClientProtocol myDiscoveryClientProtocol =
                new DiscoveryClientProtocol();

            // Get the collection of DiscoveryClientResult objects.
            DiscoveryClientResultCollection myDiscoveryClientResultCollection =
                myDiscoveryClientProtocol.ReadAll("results.discomap");

            Console.WriteLine("The number of DiscoveryClientResult objects: "
                              + myDiscoveryClientResultCollection.Count);

            Console.WriteLine(
                "Removing a DiscoveryClientResult from the collection...");
// <Snippet1>
            // Remove the first DiscoveryClientResult from the collection.
            myDiscoveryClientResultCollection.Remove(
                myDiscoveryClientResultCollection[0]);
// </Snippet1>
            Console.WriteLine(
                "Adding a DiscoveryClientResult to the collection...");
// <Snippet2>
// <Snippet3>
// <Snippet4>
// <Snippet5>
// <Snippet6>
            // Initialize new instance of the DiscoveryClientResult class.
            DiscoveryClientResult myDiscoveryClientResult =
                new DiscoveryClientResult();

            // Set the type of reference in the discovery document as
            // DiscoveryDocumentReference.
            myDiscoveryClientResult.ReferenceTypeName =
                "System.Web.Services.Discovery.DiscoveryDocumentReference";

            // Set the URL for the reference.
            myDiscoveryClientResult.Url =
                "http://localhost/Discovery/Service1_cs.asmx?disco";

            // Set the name of the file in which the reference is saved.
            myDiscoveryClientResult.Filename = "Service1_cs.disco";

            // Add the DiscoveryClientResult to the collection.
            myDiscoveryClientResultCollection.Add(myDiscoveryClientResult);
// </Snippet6>
// </Snippet5>
// </Snippet4>
// </Snippet3>
// </Snippet2>

// <Snippet7>
            if (myDiscoveryClientResultCollection.Contains(
                    myDiscoveryClientResult))
            {
                Console.WriteLine(
                    "The collection contains the specified " +
                    "DiscoveryClientResult instance.");
            }
// </Snippet7>
            Console.WriteLine("Displaying the items in collection");

// <Snippet8>
            for (int i = 0; i < myDiscoveryClientResultCollection.Count; i++)
            {
                DiscoveryClientResult myClientResult =
                    myDiscoveryClientResultCollection[i];
                Console.WriteLine("DiscoveryClientResult " + (i + 1));
                Console.WriteLine("Type of reference in the discovery document: "
                                  + myClientResult.ReferenceTypeName);
                Console.WriteLine("Url for reference:" + myClientResult.Url);
                Console.WriteLine("File for saving the reference: "
                                  + myClientResult.Filename);
            }
// </Snippet8>
        }
        catch (Exception e)
        {
            Console.WriteLine("Error is " + e.Message);
        }
    }
    static void Main(string[] args)
    {
        try
        {
            ReadParameters(args);

            if (logo)
            {
                WriteLogo();
            }

            if (args.Length == 0 || args[0] == "--help")
            {
                WriteHelp();
                return;
            }

            if (url == null)
            {
                throw new Exception("URL to discover not provided");
            }

            prot.DiscoverAny(url);
            prot.ResolveAll();

            if (prot.References.Count > 0)
            {
                Console.WriteLine("Disco found documents at the following URLs:");
                foreach (DiscoveryReference refe in prot.References.Values)
                {
                    if (refe is ContractReference)
                    {
                        Console.Write("- WSDL document at  ");
                    }
                    else if (refe is DiscoveryDocumentReference)
                    {
                        Console.Write("- DISCO document at ");
                    }
                    else
                    {
                        Console.Write("- Xml Schema at    ");
                    }
                    Console.WriteLine(refe.Url);
                }
            }
            else
            {
                Console.WriteLine("Disco didn't find any document at the specified URL");
            }

            if (save)
            {
                DiscoveryClientResultCollection col = prot.WriteAll(directory, "results.discomap");
                Console.WriteLine();
                Console.WriteLine("The following files hold the content found at the corresponding URLs:");
                foreach (DiscoveryClientResult res in col)
                {
                    Console.WriteLine("- " + res.Filename + " <- " + res.Url);
                }
                Console.WriteLine();
                Console.WriteLine("The file " + Path.Combine(directory, "results.discomap") + " holds links to each of there files");
                Console.WriteLine();
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("ERROR: " + ex.Message);
            Console.WriteLine(ex);
        }
    }