using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Web; using System.Web.Services; using System.Web.Services.Protocols; namespace PageBox { /// ///

Query Web Service. Invoked by Web Applications.

///

Copyright (c) 2002 Alexis Grandemange
/// Mail: alexis.grandemange@pagebox.net

///
This program is free software; you can redistribute it and/or
	/// modify it under the terms of the GNU Lesser General Public
	/// License as published by the Free Software Foundation; version
	/// 2.1 of the License.
	/// This library is distributed in the hope that it will be useful,
	/// but WITHOUT ANY WARRANTY; without even the implied warranty of
	/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
	/// GNU Lesser General Public License for more details.
	/// A copy of the GNU Lesser General Public License lesser.txt should be
	/// included in the distribution.
///
[WebService(Namespace="PageBox")] public class Query : System.Web.Services.WebService { public Query() { //CODEGEN: This call is required by the ASP.NET Web Services Designer InitializeComponent(); } #region Component Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { } #endregion /// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { } /// /// Get the URL of the other subscribing Web Applications. /// /// web Application archive name [WebMethod] public string[] GetSubscribers(string archive) { if (!Global.pbArchives.archives.Contains(archive)) { Log.write(Context.Request.ServerVariables["REMOTE_HOST"], archive, "Query.GetSubscribers(" + archive + ", " + Global.DeployURL + ") returned archive doesn't exist"); return new String[] {archive + "doesn't exist" }; } Archive a = (Archive)Global.pbArchives.archives[archive]; string repoQURL = a.downloadURL.Replace("/download/", "/Repository/WebServices/RepoQuery.asmx"); if (!repoQURL.StartsWith("http://")) repoQURL = "http://" + repoQURL; RepoQuery rq = new RepoQuery(repoQURL); try { rq.Discover(); } catch(Exception e) { Log.write(Context.Request.ServerVariables["REMOTE_HOST"], archive, "Query.GetSubscribers(" + archive + ", " + Global.DeployURL + ") returned " + repoQURL + " repository not found"); return null; } try { string[] rc = rq.GetSubscribers(archive, Global.DeployURL); if (rc == null) { Log.write(Context.Request.ServerVariables["REMOTE_HOST"], archive, "Query.GetSubscribers(" + archive + ", " + Global.DeployURL + ") found no other subscriber"); return null; } else { Log.write(Context.Request.ServerVariables["REMOTE_HOST"], archive, "Query.GetSubscribers(" + archive + ", " + Global.DeployURL + ") returned " + rc[0]); return rc; } } catch(System.Net.WebException we) { Log.write(Context.Request.ServerVariables["REMOTE_HOST"], archive, "Query.GetSubscribers(" + archive + ", " + Global.DeployURL + ") returned " + we.Message); return null; } catch(System.Web.HttpException he) { Log.write(Context.Request.ServerVariables["REMOTE_HOST"], archive, "Query.GetSubscribers(" + archive + ", " + Global.DeployURL + ") returned " + he.Message); return null; } catch(SoapException se) { Log.write(Context.Request.ServerVariables["REMOTE_HOST"], archive, "Query.GetSubscribers(" + archive + ", " + Global.DeployURL + ") returned " + se.Message); return null; } } } }