Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/media/mn8/protocol/xmlrpc/TestXmlrpcURL.java


1   /*
2    * $COPYRIGHT$
3    * $Id: TestXmlrpcURL.java,v 1.1 2001/12/14 00:12:25 neuro Exp $
4    *
5    * Date           Author         Changes
6    * sept 28 2001  Antal Attila    Created
7    */
8   package org.media.mn8.protocol.xmlrpc;
9   
10  
11  import java.net.*;
12  import java.io.*;
13  
14  
15  /**
16   * This is an application which uses our new xmlrpc
17   * protocol handler to obtain information.
18   */
19  public class TestXmlrpcURL {
20      
21      /**
22       * The method launches the application.
23       * @param args Arguments which are the query string.
24       */
25      public static void main (String args[]) {
26  
27          TestXmlrpcURL app = new TestXmlrpcURL ( args );
28      }
29      
30      /**
31       * This constructor does all of the work of obtaining
32       * the data from the server.
33       * @param args The tokens of the query string.
34       */
35      public TestXmlrpcURL( String args[] ) {
36          URL url;
37          URLConnection con;
38          BufferedReader input;
39          String nextLine;
40  
41          String protocol = "xmlrpc:";
42          String url1 = "//guest:guest@localhost:10300/url.executeSep?sep=" + 
43              "<request    reqno='1'     >< fetch><union><intersect> \n" +          
44              "<compare subtree='xmlrpctest.7'>" +                                
45              "<path/><value></value></compare>" +                                
46              "</intersect></union></fetch></request>" +
47              "&db=XMLDB&user=guest&hash=74f459661a03946a";
48  
49          String url2 = "//guest:guest@localhost:10300/url.echo?x=Test";
50    
51          String _url = URLEncoder.encode( url1 );
52  
53          try {
54              url = new URL( protocol + _url );
55              con = url.openConnection();
56  
57              input = new BufferedReader( new InputStreamReader ( con.getInputStream() ) );
58              while( ( nextLine = input.readLine() ) != null) System.out.println( nextLine );
59              input.close();
60          } 
61          catch ( MalformedURLException e ) {
62              System.err.println("Mailformed URL: " + e);
63          } 
64          catch ( IOException e ) {
65              System.err.println("Failed I/O: " + e);
66  
67          }
68      }
69  }