/* * * Copyright 2005 Bruce Werner. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * */ package net.thepostmodern.fatima.xml; import org.apache.xmlrpc.*; import java.util.*; /** * This class uses XML-RPC to ping integrators using a simple interface that can ping multiple * vendors at one time. It requires Apache's xml-rpc-1.2 code not Sun Microsystem's XML-RPC. *
* NOTE:Since SUN Microsystem's API(s) insist on using SOAP as the transmission protocol * but integrators wish to have XML sent instead, you have to use the xmlrpc-1.2 code from * Apache Foundation instead. *
* *
* @author Bruce B. Werner * @version 0.9 * */ public class PingIntegrator { String postName; String postURI; String pingClient; String pingMethod; /** * This method gathers information necessary to do an XML-RPC ping. *
* @param name The name of the blog or blog entry, but that * could cause problems with Technorati. * @param URI The URI of the post or blog you are sending * @param client This is the client RPC name, usually something like * "http://rpc.technorati.com/rpc/ping" * @param method Check with your integrator for this, usually "weblogUpdates.ping" * @return void * */ public PingIntegrator() { super(); // TODO Auto-generated constructor stub } /** * This method does the ping after you've called PingIntegrator() *
* @return void */ public void doPing(String name, String URI, String client, String method) { try { this.postName = name; this.postURI = URI; this.pingClient = client; this.pingMethod = method; final XmlRpcClient xmlrpc = new XmlRpcClient(this.pingClient); final Vector params = new Vector(); params.addElement(this.postName); params.addElement(this.postURI); final Object result = xmlrpc.execute(this.pingMethod,params); if((result != null)){ System.out.println( "Successfully pinged account for " + client + "at" + URI);} System.out.println(this.postName); System.out.println(this.postURI); System.out.println(this.pingClient); System.out.println(this.pingMethod); } catch (Exception ex) { ex.printStackTrace(); System.out.println("ERROR: "+ex.getMessage()); } } }