public override DiscoveryReference GetDiscoveryReference (string filename)
		{
			DiscoveryDocumentReference refe = new DiscoveryDocumentReference ();
			refe.Url = filename;
			refe.Ref = filename;
			return refe;
		}
        public void SetUpFixture()
        {
            project          = WebReferenceTestHelper.CreateTestProject("C#");
            project.FileName = "C:\\projects\\test\\foo.csproj";

            protocol = new DiscoveryClientProtocol();
            DiscoveryDocumentReference discoveryRef = new DiscoveryDocumentReference();

            discoveryRef.Url = updateFromUrl;
            protocol.References.Add(discoveryRef);

            ContractReference contractRef = new ContractReference();

            contractRef.Url            = "http://localhost/test.asmx?wsdl";
            contractRef.ClientProtocol = new DiscoveryClientProtocol();
            ServiceDescription desc = new ServiceDescription();

            contractRef.ClientProtocol.Documents.Add(contractRef.Url, desc);
            protocol.References.Add(contractRef);

            WebReferenceTestHelper.InitializeProjectBindings();

            webReference = new SD.WebReference(project, updateFromUrl, name, proxyNamespace, protocol);

            webReferenceUrl                 = webReference.WebReferenceUrl;
            discoFileProjectItem            = WebReferenceTestHelper.GetFileProjectItem(webReference.Items, "Web References\\localhost\\test.disco", ItemType.None);
            referenceMapFileProjectItem     = WebReferenceTestHelper.GetFileProjectItem(webReference.Items, "Web References\\localhost\\Reference.map", ItemType.None);
            wsdlFileProjectItem             = WebReferenceTestHelper.GetFileProjectItem(webReference.Items, "Web References\\localhost\\test.wsdl", ItemType.None);
            proxyFileProjectItem            = WebReferenceTestHelper.GetFileProjectItem(webReference.Items, "Web References\\localhost\\Reference.cs", ItemType.Compile);
            webReferencesProjectItem        = (WebReferencesProjectItem)WebReferenceTestHelper.GetProjectItem(webReference.Items, "Web References\\", ItemType.WebReferences);
            webServicesReferenceProjectItem = (ReferenceProjectItem)WebReferenceTestHelper.GetProjectItem(webReference.Items, ItemType.Reference);
        }
        public void SetUpFixture()
        {
            project          = WebReferenceTestHelper.CreateTestProject("C#");
            project.FileName = "C:\\projects\\test\\foo.csproj";

            protocol = new DiscoveryClientProtocol();
            DiscoveryDocumentReference discoveryRef = new DiscoveryDocumentReference();

            discoveryRef.Url = updateFromUrl;
            protocol.References.Add(discoveryRef);

            ContractReference contractRef = new ContractReference();

            contractRef.Url            = "http://localhost/test.asmx?wsdl";
            contractRef.ClientProtocol = new DiscoveryClientProtocol();
            ServiceDescription desc = new ServiceDescription();

            contractRef.ClientProtocol.Documents.Add(contractRef.Url, desc);
            protocol.References.Add(contractRef);

            WebReferenceTestHelper.InitializeLanguageBindings();

            webReference = new SD.WebReference(project, updateFromUrl, name, proxyNamespace, protocol);

            foreach (ProjectItem item in webReference.Items)
            {
                ProjectService.AddProjectItem(project, item);
            }
            webReferencesProjectItem = webReference.WebReferencesProjectItem;
        }
        public override void FixtureSetUp()
        {
            base.FixtureSetUp();
            project          = WebReferenceTestHelper.CreateTestProject("C#");
            project.FileName = FileName.Create("C:\\projects\\test\\foo.csproj");

            ReferenceProjectItem referenceItem = new ReferenceProjectItem(project, "System.Web.Services");

            ProjectService.AddProjectItem(project, referenceItem);

            protocol = new DiscoveryClientProtocol();
            DiscoveryDocumentReference discoveryRef = new DiscoveryDocumentReference();

            discoveryRef.Url = updateFromUrl;
            protocol.References.Add(discoveryRef);

            ContractReference contractRef = new ContractReference();

            contractRef.Url            = "http://localhost/test.asmx?wsdl";
            contractRef.ClientProtocol = new DiscoveryClientProtocol();
            ServiceDescription desc = new ServiceDescription();

            contractRef.ClientProtocol.Documents.Add(contractRef.Url, desc);
            protocol.References.Add(contractRef);

            WebReferenceTestHelper.InitializeProjectBindings();

            webReference = new Gui.WebReference(project, updateFromUrl, name, proxyNamespace, protocol);
            webServicesReferenceProjectItem = (ReferenceProjectItem)WebReferenceTestHelper.GetProjectItem(webReference.Items, ItemType.Reference);
        }
    static void Run()
    {
        try
        {
// <Snippet1>
            string myUrl = "http://localhost/Sample_cs.vsdisco";
            DiscoveryClientProtocol    myProtocol  = new DiscoveryClientProtocol();
            DiscoveryDocumentReference myReference = new DiscoveryDocumentReference(myUrl);
            Stream            myFileStream         = myProtocol.Download(ref myUrl);
            DiscoveryDocument myDiscoveryDocument  =
                (DiscoveryDocument)myReference.ReadDocument(myFileStream);
// </Snippet1>
            IEnumerator myEnumerator = myDiscoveryDocument.References.GetEnumerator();
            Console.WriteLine("\nThe references to the discovery document are : \n");
            while (myEnumerator.MoveNext())
            {
                DiscoveryDocumentReference myNewReference =
                    (DiscoveryDocumentReference)myEnumerator.Current;
                // Print the discovery document references on the console.
                Console.WriteLine(myNewReference.Url);
            }
        }
        catch (Exception e)
        {
            Console.WriteLine("Exception:{0}", e.Message);
        }
    }
        public void SetUpFixture()
        {
            project = WebReferenceTestHelper.CreateTestProject("C#");
            WebReferencesProjectItem item = new WebReferencesProjectItem(project);

            item.Include = "Web References\\";
            ProjectService.AddProjectItem(project, item);

            protocol = new DiscoveryClientProtocol();
            DiscoveryDocumentReference discoveryRef = new DiscoveryDocumentReference();

            discoveryRef.Url = updateFromUrl;
            protocol.References.Add(discoveryRef);

            ContractReference contractRef = new ContractReference();

            contractRef.Url            = "http://localhost/test.asmx?wsdl";
            contractRef.ClientProtocol = new DiscoveryClientProtocol();
            ServiceDescription desc = new ServiceDescription();

            contractRef.ClientProtocol.Documents.Add(contractRef.Url, desc);
            protocol.References.Add(contractRef);

            WebReferenceTestHelper.InitializeProjectBindings();

            webReference             = new SD.WebReference(project, updateFromUrl, name, proxyNamespace, protocol);
            webReferencesProjectItem = WebReferenceTestHelper.GetProjectItem(webReference.Items, "Web References\\", ItemType.WebReferences);
        }
        public void NotSupportedProjectLanguage()
        {
            project = WebReferenceTestHelper.CreateTestProject("Foo");

            protocol = new DiscoveryClientProtocol();
            DiscoveryDocumentReference discoveryRef = new DiscoveryDocumentReference();

            discoveryRef.Url = updateFromUrl;
            protocol.References.Add(discoveryRef);

            ContractReference contractRef = new ContractReference();

            contractRef.Url            = "http://localhost/test.asmx?wsdl";
            contractRef.ClientProtocol = new DiscoveryClientProtocol();
            ServiceDescription desc = new ServiceDescription();

            contractRef.ClientProtocol.Documents.Add(contractRef.Url, desc);
            protocol.References.Add(contractRef);

            WebReferenceTestHelper.InitializeProjectBindings();

            webReference = new Gui.WebReference(project, updateFromUrl, name, proxyNamespace, protocol);

            proxyFileProjectItem = WebReferenceTestHelper.GetFileProjectItem(webReference.Items, "Web References\\localhost\\Reference.vb", ItemType.Compile);
        }
        public override DiscoveryReference GetDiscoveryReference(string filename)
        {
            DiscoveryDocumentReference refe = new DiscoveryDocumentReference();

            refe.Url = filename;
            refe.Ref = filename;
            return(refe);
        }
Exemple #9
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);
        }
    static void Main()
    {
        DiscoveryDocumentReference myDiscoveryDocReference1 =
            new DiscoveryDocumentReference();
        DiscoveryDocumentReference myDiscoveryDocReference2 =
            new DiscoveryDocumentReference();
        DiscoveryReference myDiscoveryReference;

        Console.WriteLine("Demonstrating DiscoveryReferenceCollection class.");

        // Create new DiscoveryReferenceCollection.
        DiscoveryReferenceCollection myDiscoveryReferenceCollection =
            new DiscoveryReferenceCollection();

        // Access the Count method.
        Console.WriteLine("The number of elements in the collection is: "
                          + myDiscoveryReferenceCollection.Count.ToString());

        // Add elements to the collection.
        myDiscoveryReferenceCollection.Add(myDiscoveryDocReference1);
        myDiscoveryReferenceCollection.Add(myDiscoveryDocReference2);

        Console.WriteLine("The number of elements in the collection "
                          + "after adding two elements to the collection: "
                          + myDiscoveryReferenceCollection.Count.ToString());

        // Call the Contains method.
        if (myDiscoveryReferenceCollection.Contains(myDiscoveryDocReference1)
            != true)
        {
            throw new Exception("Element not found in collection.");
        }

        // Access the indexed member.
        myDiscoveryReference =
            (DiscoveryReference)myDiscoveryReferenceCollection[0];
        if (myDiscoveryReference == null)
        {
            throw new Exception("Element not found in collection.");
        }

        // Remove one element from collection.
        myDiscoveryReferenceCollection.Remove(myDiscoveryDocReference1);
        Console.WriteLine("The number of elements in the collection "
                          + "after removing one element is: "
                          + myDiscoveryReferenceCollection.Count.ToString());
    }
        public override void FixtureSetUp()
        {
            base.FixtureSetUp();
            project          = WebReferenceTestHelper.CreateTestProject("C#");
            project.FileName = FileName.Create("C:\\Projects\\Web.csproj");
            WebReferencesProjectItem item = new WebReferencesProjectItem(project);

            item.Include = "Web References\\";
            ProjectService.AddProjectItem(project, item);

            protocol = new DiscoveryClientProtocol();
            DiscoveryDocumentReference discoveryRef = new DiscoveryDocumentReference();

            discoveryRef.Url = updateFromUrl;
            protocol.References.Add(discoveryRef);

            ContractReference contractRef = new ContractReference();

            contractRef.Url            = "http://localhost/test.asmx?wsdl";
            contractRef.ClientProtocol = new DiscoveryClientProtocol();
            ServiceDescription desc = new ServiceDescription();

            contractRef.ClientProtocol.Documents.Add(contractRef.Url, desc);
            protocol.References.Add(contractRef);

            WebReferenceTestHelper.InitializeProjectBindings();

            webReference = new Gui.WebReference(project, updateFromUrl, oldName, proxyNamespace, protocol);

            // Force generation of items.
            List <ProjectItem> items = webReference.Items;

            // Change the web reference name.
            webReference.Name = name;
            webReferenceUrl   = (WebReferenceUrl)WebReferenceTestHelper.GetProjectItem(webReference.Items, ItemType.WebReferenceUrl);

            discoFileProjectItem        = WebReferenceTestHelper.GetFileProjectItem(webReference.Items, "Web References\\localhost1\\test.disco", ItemType.None);
            referenceMapFileProjectItem = WebReferenceTestHelper.GetFileProjectItem(webReference.Items, "Web References\\localhost1\\Reference.map", ItemType.None);
            wsdlFileProjectItem         = WebReferenceTestHelper.GetFileProjectItem(webReference.Items, "Web References\\localhost1\\test.wsdl", ItemType.None);
            proxyFileProjectItem        = WebReferenceTestHelper.GetFileProjectItem(webReference.Items, "Web References\\localhost1\\Reference.cs", ItemType.Compile);
        }
Exemple #12
0
    public static void Main()
    {
        try
        {
            DiscoveryDocument myDiscoveryDocument;
            XmlTextReader     myXmlTextReader =
                new XmlTextReader("http://localhost/Sample_cs.vsdisco");
            myDiscoveryDocument = DiscoveryDocument.Read(myXmlTextReader);

            // <Snippet2>
            // Create a new instance of DiscoveryDocumentReference.
            DiscoveryDocumentReference myDiscoveryDocumentReference =
                new DiscoveryDocumentReference();
            // </Snippet2>
            // <Snippet3>
            FileStream myFileStream = new FileStream("Temp.vsdisco",
                                                     FileMode.OpenOrCreate, FileAccess.Write);
            myDiscoveryDocumentReference.WriteDocument(
                myDiscoveryDocument, myFileStream);
            myFileStream.Close();
            // </Snippet3>

            FileStream myFileStream1 = new FileStream("Temp.vsdisco",
                                                      FileMode.OpenOrCreate, FileAccess.Read);
            StreamReader myStreamReader = new StreamReader(myFileStream1);

            // Initialize the file pointer.
            myStreamReader.BaseStream.Seek(0, SeekOrigin.Begin);
            Console.WriteLine("The contents of the discovery document are: \n");
            while (myStreamReader.Peek() > -1)
            {
                // Display the contents of the discovery document.
                Console.WriteLine(myStreamReader.ReadLine());
            }
            myStreamReader.Close();
        }
        catch (Exception e)
        {
            Console.WriteLine("Exception: {0}", e.Message);
        }
    }
    static void Run()
    {
        try
        {
// <Snippet1>
            string myUrl = "http://localhost/Sample_cs.vsdisco";
            DiscoveryClientProtocol myProtocol = new DiscoveryClientProtocol();
            // Get the discovery document myDiscoveryDocument.
            DiscoveryDocument myDiscoveryDocument = myProtocol.Discover(myUrl);
            // Get the references of myDiscoveryDocument.
            IEnumerator myEnumerator = myDiscoveryDocument.References.GetEnumerator();
            while (myEnumerator.MoveNext())
            {
                DiscoveryDocumentReference myNewReference =
                    (DiscoveryDocumentReference)myEnumerator.Current;
                // Set the ClientProtocol of myNewReference.
                DiscoveryClientProtocol myNewProtocol = myNewReference.ClientProtocol;
                // Verify for all the valid references.
                myNewReference.ResolveAll();

                // Get the document of myNewReference.
                DiscoveryDocument myNewDiscoveryDocument =
                    myNewReference.Document;

                IEnumerator myNewEnumerator =
                    myNewDiscoveryDocument.References.GetEnumerator();
                Console.WriteLine("The valid discovery document is : \n");
                while (myNewEnumerator.MoveNext())
                {
                    // Display the references of myNewDiscoveryDocument on the console.
                    Console.WriteLine(((DiscoveryDocumentReference)myNewEnumerator.Current).Ref);
                }
            }
// </Snippet1>
        }
        catch (Exception e)
        {
            Console.WriteLine("Exception :{0}", e.Message);
        }
    }
    public static void Main()
    {
        try
        {
// <Snippet1>
            DiscoveryDocumentReference myDiscoveryDocumentReference =
                new DiscoveryDocumentReference(
                    "http://localhost/Sample_cs.disco");
// </Snippet1>

            Console.WriteLine("The reference to the discovery document is: ");

// <Snippet2>
            // Display the discovery document reference.
            Console.WriteLine(myDiscoveryDocumentReference.Ref.ToString());
// </Snippet2>
            Console.WriteLine();
            Console.WriteLine(
                "The URL of the referenced discovery document is: ");

// <Snippet3>
            // Display the URL of the referenced discovery document.
            Console.WriteLine(myDiscoveryDocumentReference.Url.ToString());
// </Snippet3>
            Console.WriteLine();
            Console.WriteLine("The name of the default disco file is: ");

// <Snippet4>
            // Display the name of the default file used for reference.
            Console.WriteLine(
                myDiscoveryDocumentReference.DefaultFilename.ToString());
// </Snippet4>
        }
        catch (Exception e)
        {
            Console.WriteLine("Exception: {0}", e.Message);
        }
    }
        public override WebServiceDiscoveryResult Load(WebReferenceItem item)
        {
            FilePath       basePath = item.MapFile.FilePath.ParentDirectory;
            ReferenceGroup resfile  = ReferenceGroup.Read(item.MapFile.FilePath);

            // TODO: Read as MetadataSet

            var protocol = new DiscoveryClientProtocol();

            foreach (MetadataFile dcr in resfile.Metadata)
            {
                DiscoveryReference dr;
                switch (dcr.MetadataType)
                {
                case "Wsdl":
                    dr = new ContractReference();
                    break;

                case "Disco":
                    dr = new DiscoveryDocumentReference();
                    break;

                case "Schema":
                    dr = new SchemaReference();
                    break;

                default:
                    continue;
                }

                dr.Url = dcr.SourceUrl;
                var fs = new FileStream(basePath.Combine(dcr.FileName), FileMode.Open, FileAccess.Read);
                protocol.Documents.Add(dr.Url, dr.ReadDocument(fs));
                fs.Close();
                protocol.References.Add(dr.Url, dr);
            }
            return(new WebServiceDiscoveryResultWCF(protocol, null, item, resfile, DefaultClientOptions));
        }
Exemple #16
0
    public static void Main()
    {
// <Snippet5>
// <Snippet2>
// <Snippet1>
        DiscoveryClientReferenceCollection myDiscoveryClientReferenceCollection =
            new DiscoveryClientReferenceCollection();

        ContractReference myContractReference = new ContractReference();
        string            myStringUrl1        = "http://www.contoso.com/service1.disco";

        myContractReference.Ref = myStringUrl1;
        myDiscoveryClientReferenceCollection.Add(myContractReference);

// </Snippet1>
// </Snippet2>
        // myDiscoveryClientReferenceCollection is an instance collection.
        object myObject = myDiscoveryClientReferenceCollection[myStringUrl1];

        Console.WriteLine("Object representing the URL: " + myObject.ToString());
// </Snippet5>
        Console.WriteLine("");
// <Snippet4>
// <Snippet3>
        DiscoveryDocumentReference myDiscoveryDocumentReference =
            new DiscoveryDocumentReference();
        string myStringUrl = "http://www.contoso.com/service.disco";

        myDiscoveryClientReferenceCollection.Add(myStringUrl,
                                                 myDiscoveryDocumentReference);
// </Snippet3>
        myDiscoveryClientReferenceCollection.Remove(myStringUrl);
// </Snippet4>

        // Retrieve the keys in the collection.
        ICollection myCollection = myDiscoveryClientReferenceCollection.Keys;

        object[] myObjectCollection =
            new object[myDiscoveryClientReferenceCollection.Count];
        myCollection.CopyTo(myObjectCollection, 0);

        Console.WriteLine("The discovery documents, service descriptions, and");
        Console.WriteLine("XML schema definitions in the collection are:");
        for (int iIndex = 0; iIndex < myObjectCollection.Length; iIndex++)
        {
            Console.WriteLine(myObjectCollection[iIndex]);
        }

        Console.WriteLine("");

        // Retrieve the values in the collection.
        ICollection myCollection1 = myDiscoveryClientReferenceCollection.Values;

        object[] myObjectCollection1 =
            new object[myDiscoveryClientReferenceCollection.Count];
        myCollection1.CopyTo(myObjectCollection1, 0);

        Console.WriteLine("The objects in the collection are:");
        for (int iIndex = 0; iIndex < myObjectCollection1.Length; iIndex++)
        {
            Console.WriteLine(myObjectCollection1[iIndex]);
        }
    }
        public void SetUpFixture()
        {
            // Set up the project.
            MSBuildBasedProject project = WebReferenceTestHelper.CreateTestProject("C#");

            project.FileName = "c:\\projects\\test\\foo.csproj";

            // Web references item.
            WebReferencesProjectItem webReferencesItem = new WebReferencesProjectItem(project);

            webReferencesItem.Include = "Web References\\";
            ProjectService.AddProjectItem(project, webReferencesItem);

            // Web reference url.
            WebReferenceUrl webReferenceUrl = new WebReferenceUrl(project);

            webReferenceUrl.Include       = "http://localhost/test.asmx";
            webReferenceUrl.UpdateFromURL = "http://localhost/test.asmx";
            webReferenceUrl.RelPath       = "Web References\\localhost";
            ProjectService.AddProjectItem(project, webReferenceUrl);

            FileProjectItem discoFileItem = new FileProjectItem(project, ItemType.None);

            discoFileItem.Include = "Web References\\localhost\\test.disco";
            ProjectService.AddProjectItem(project, discoFileItem);

            FileProjectItem wsdlFileItem = new FileProjectItem(project, ItemType.None);

            wsdlFileItem.Include = "Web References\\localhost\\test.wsdl";
            ProjectService.AddProjectItem(project, wsdlFileItem);

            // Proxy
            FileProjectItem proxyItem = new FileProjectItem(project, ItemType.Compile);

            proxyItem.Include       = "Web References\\localhost\\Reference.cs";
            proxyItem.DependentUpon = "Reference.map";
            ProjectService.AddProjectItem(project, proxyItem);

            // Reference map.
            FileProjectItem mapItem = new FileProjectItem(project, ItemType.None);

            mapItem.Include = "Web References\\localhost\\Reference.map";
            ProjectService.AddProjectItem(project, mapItem);

            // System.Web.Services reference.
            ReferenceProjectItem webServicesReferenceItem = new ReferenceProjectItem(project, "System.Web.Services");

            ProjectService.AddProjectItem(project, webServicesReferenceItem);

            // Set up the web reference.
            DiscoveryClientProtocol    protocol     = new DiscoveryClientProtocol();
            DiscoveryDocumentReference discoveryRef = new DiscoveryDocumentReference();

            discoveryRef.Url = "http://localhost/new.asmx";
            protocol.References.Add(discoveryRef);

            ContractReference contractRef = new ContractReference();

            contractRef.Url            = "http://localhost/new.asmx?wsdl";
            contractRef.ClientProtocol = new DiscoveryClientProtocol();
            ServiceDescription desc = new ServiceDescription();

            contractRef.ClientProtocol.Documents.Add(contractRef.Url, desc);
            protocol.References.Add(contractRef);

            WebReferenceTestHelper.InitializeProjectBindings();

            SD.WebReference webReference = new SD.WebReference(project, "http://localhost/new.asmx", "localhost", "ProxyNamespace", protocol);
            changes = webReference.GetChanges(project);
        }