public override void Run()
        {
            WebReferenceNode node = Owner as WebReferenceNode;

            if (node != null && node.Project != null && node.ProjectItem != null)
            {
                WebReferenceUrl url = (WebReferenceUrl)node.ProjectItem;
                try {
                    // Discover web services at url.
                    DiscoveryClientProtocol protocol = DiscoverWebServices(url.UpdateFromURL);
                    if (protocol != null)
                    {
                        // Save web services.
                        WebReference webReference = new WebReference(url.Project, url.UpdateFromURL, node.Text, url.Namespace, protocol);
                        webReference.Save();

                        // Update project.
                        WebReferenceChanges changes = webReference.GetChanges(url.Project);
                        if (changes.Changed)
                        {
                            foreach (ProjectItem itemRemoved in changes.ItemsRemoved)
                            {
                                ProjectService.RemoveProjectItem(url.Project, itemRemoved);
                                FileService.RemoveFile(itemRemoved.FileName, false);
                            }
                            foreach (ProjectItem newItem in changes.NewItems)
                            {
                                ProjectService.AddProjectItem(url.Project, newItem);
                                FileNode fileNode = new FileNode(newItem.FileName, FileNodeStatus.InProject);
                                fileNode.InsertSorted(node);
                            }
                            ProjectBrowserPad.Instance.ProjectBrowserControl.TreeView.Sort();
                            url.Project.Save();
                        }

                        // Update code completion.
                        SD.ParserService.ParseFileAsync(FileName.Create(webReference.WebProxyFileName), parentProject: url.Project).FireAndForget();
                    }
                } catch (WebException ex) {
                    LoggingService.Debug(ex);
                    MessageService.ShowError(GetRefreshWebReferenceErrorMessage(ex, url.UpdateFromURL));
                }
            }
        }
        public override void Run()
        {
            WebReferenceNode node = Owner as WebReferenceNode;

            if (node != null && node.Project != null && node.ProjectItem != null)
            {
                WebReferenceUrl url = (WebReferenceUrl)node.ProjectItem;
                try {
                    // Discover web services at url.
                    DiscoveryClientProtocol protocol = DiscoverWebServices(url.UpdateFromURL);
                    if (protocol != null)
                    {
                        // Save web services.
                        WebReference webReference = new WebReference(url.Project, url.UpdateFromURL, node.Text, url.Namespace, protocol);
                        webReference.Save();

                        // Update project.
                        WebReferenceChanges changes = webReference.GetChanges(url.Project);
                        if (changes.Changed)
                        {
                            foreach (ProjectItem itemRemoved in changes.ItemsRemoved)
                            {
                                ProjectService.RemoveProjectItem(url.Project, itemRemoved);
                                FileService.RemoveFile(itemRemoved.FileName, false);
                            }
                            foreach (ProjectItem newItem in changes.NewItems)
                            {
                                ProjectService.AddProjectItem(url.Project, newItem);
                                FileNode fileNode = new FileNode(newItem.FileName, FileNodeStatus.InProject);
                                fileNode.InsertSorted(node);
                            }
                            ProjectBrowserPad.Instance.ProjectBrowserControl.TreeView.Sort();
                            url.Project.Save();
                        }

                        // Update code completion.
                        ParserService.ParseFile(webReference.WebProxyFileName);
                    }
                } catch (WebException ex) {
                    MessageService.ShowError(ex, String.Format(StringParser.Parse("${res:ICSharpCode.SharpDevelop.Commands.ProjectBrowser.RefreshWebReference.ReadServiceDescriptionError}"), url.UpdateFromURL));
                }
            }
        }
        public override void FixtureSetUp()
        {
            base.FixtureSetUp();
            // Set up the project.
            MSBuildBasedProject project = WebReferenceTestHelper.CreateTestProject("C#");

            project.FileName = FileName.Create("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();

            var webReference = new Gui.WebReference(project, "http://localhost/new.asmx", "localhost", "ProxyNamespace", protocol);

            changes = webReference.GetChanges(project);
        }