Results 1 to 2 of 2
  1. #1
    kievari is offline Member
    Join Date
    Nov 2009
    Posts
    28
    Rep Power
    0

    Default xml-rpc php joomla java

    Hi,
    I am going to have a Java client that connects to the Joomla! xml-rpc client. I am doing the popular test of adding two number. The server side is already working well. To test the server side, I added 4.2 to 9.6 and got 13.8!!! :D

    To check it, I used the debugger at:
    gggeek.raprap.it/debugger/XMLRPC Debugger

    putting the site address, say example.com, port 80, path /brian/xmlrpc which is the path to the server root of Joomla. Next chose Execute method, name foobar.add, and the payload as:
    Java Code:
    <param><value><double>4.2</double></value></param><param><value><double>9.6</double></value></param>
    and I got this response after executing:
    Java Code:
    <methodResponse> <params> <param> <value><struct> <member><name>value1</name> <value><double>4.2</double></value> </member> <member><name>value2</name> <value><double>9.6</double></value> </member> <member><name>product</name> <value><double>13.8</double></value> </member> </struct></value> </param> </params> </methodResponse>
    Now the Java side which still does not want to work:
    Java Code:
    package ipkgXmlPrcTechTest;
    import org.apache.xmlrpc.client.XmlRpcClient;
    import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
    import java.net.*;
    
    public class JavaClient {
    	public static void main (String [] args) {
    		  try {
    
    		     XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
    		     config.setServerURL(new URL("ADDRESS_TO_SERVER_PATH_CORRECTLY_WRITTEN"));
    		     XmlRpcClient server = new XmlRpcClient();
    		     server.setConfig(config);
    		     
    		     Object[] params = new Object[]{new Double(33.0), new Double(9.0)};
    
    		     Object result = server.execute("foobar.add", params);
    
    		     double sum = ((Double) result).doubleValue();
    		     System.out.println("The sum is: "+ sum);
    
    		   } catch (Exception exception) {
    		     System.err.println("JavaClient: " + exception);
    		   }
    		  }
    
    }
    The problem is that after performing "Run as" 1 java application, I get this error and can't figure out where from it is coming:
    JavaClient: org.apache.xmlrpc.XmlRpcException: XML error: Invalid document end at line 1, column 1

    Could anyone please guide me how to get rid of it??:)

  2. #2
    kievari is offline Member
    Join Date
    Nov 2009
    Posts
    28
    Rep Power
    0

    Default a version that worked!

    Well I altered the code and here you are with a version that works ok. Anyway, I still can't figure it out why the first one did not work. So any comment is welcome.

    Java Code:
    package ipkgXmlPrcTechTest;
    import org.apache.xmlrpc.client.XmlRpcClient;
    import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
    import java.net.*;
    
    public class CrudePing {
    
        public static void main( String args[] ) throws Exception {
    
    	     XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
    	     config.setServerURL(new URL("PATH_TO_XMLRPC_SERVER"));
    	     XmlRpcClient client = new XmlRpcClient();
    	     client.setConfig(config);
    
            Object[] params = new Object[]{new Double(4.0), new Double(5.0)};
            
            Object result = client.execute( "foobar.add", params );
            System.out.println(result.toString());
            
    
            if ( result != null )
                System.out.println( "Successfully pinged XML-RPC server!" );
        }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •