1 16 17 18 package org.apache.xmlrpc.applet; 19 20 import java.applet.Applet ; 21 import java.io.IOException ; 22 import java.net.MalformedURLException ; 23 import java.net.URL ; 24 import java.util.Vector ; 25 26 27 32 public class XmlRpcApplet extends Applet { 33 34 SimpleXmlRpcClient client; 35 36 37 42 public void initClient() 43 { 44 int port = 80; 45 String p = getParameter("PORT"); 46 if (p != null) 47 { 48 try 49 { 50 port = Integer.parseInt(p); 51 } 52 catch (NumberFormatException nfx) 53 { 54 System.out.println("Error parsing port: " + nfx); 55 } 56 } 57 initClient(port); 58 } 59 60 64 public void initClient(int port) 65 { 66 String uri = getParameter("URI"); 67 if (uri == null) 68 { 69 uri = "/RPC2"; 70 } 71 else if (!uri.startsWith("/")) 72 { 73 uri = "/" + uri; 74 } 75 initClient(port, uri); 76 } 77 78 82 public void initClient(int port, String uri) 83 { 84 String host = getCodeBase().getHost(); 85 try 86 { 87 URL url = new URL ("http://" + host + ":" + port + uri); 88 System.out.println("XML-RPC URL: " + url); 89 client = new SimpleXmlRpcClient(url); 90 } 91 catch (MalformedURLException unlikely) 92 { 93 System.out.println("Error constructing XML-RPC client for " 94 + host + ":" + port + ": " + unlikely); 95 } 96 } 97 98 101 public Object execute(String methodName, Vector arguments) 102 throws XmlRpcException, IOException 103 { 104 if (client == null) 105 { 106 initClient (); 107 } 108 Object returnValue = null; 109 return returnValue = client.execute(methodName, arguments); 110 } 111 } 112 | Popular Tags |