aspose file tools
The moose likes Web Services and the fly likes client program using apache xmlrpc libraries Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Web Services
Reply Bookmark "client program using apache xmlrpc libraries" Watch "client program using apache xmlrpc libraries" New topic
Author

client program using apache xmlrpc libraries

Prasath Nadarajah
Greenhorn

Joined: Sep 18, 2010
Posts: 18
Hi,
i,m developing an weblog client application using java and apache xmlrpc libraries.
I wrote a simple program i used to communicate with WordPress.
but it throws the following exception:

Exception: Failed to parse server's response: Expected methodResponse element, got html

I cannot figure out what's wrong with the code
can anyone help me on this??

Program

import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
import java.net.URL;
import java.util.Vector;

public class SimpleXmlrpc {

public SimpleXmlrpc() {
}

public static void main(String[] args) {

XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();

try{

config.setServerURL(new URL("http://localhost/wordsite"));
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);

Object[] params = new Object[]{ new String("usrername"),
new String("password")
};

String result = (String)client.execute("sayHello", params); .
System.out.println("Results" + result);
}
catch(Exception e)
{
System.out.println("Exception: " + e.getMessage());
}
}
}



http://codex.wordpress.org/XML-RPC_wp
Prasath Nadarajah
Greenhorn

Joined: Sep 18, 2010
Posts: 18
The sayHello method is a test method that returns a string "hello". it does,nt requires an authentication.
Prasath Nadarajah
Greenhorn

Joined: Sep 18, 2010
Posts: 18
Also i,m glad if someone will provide some guidelines how i can commicate blog's xmlrpc
any alternative other than using apache xml-rpc libraries...
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12271
    
    1
Exception: Failed to parse server's response: Expected methodResponse element, got html


Your client code was expecting XML formatted response but got HTML. Probably because the server sent a plain HTML error message.

A utility like TCPMON or SOAPui will let you see exactly what is being sent and what is being received.

Bill

Java Resources at www.wbrogden.com
Prasath Nadarajah
Greenhorn

Joined: Sep 18, 2010
Posts: 18
Thanks bill
the actual error i made was i must insert the URL of the xml-rpc file (not the site URL)

config.setServerURL(new URL("http://localhost/wordsite")) // wrong

config.setServerURL(new URL(""http://localhost/wordsite/xmlrpc.php"")) // correct
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: client program using apache xmlrpc libraries
 
Similar Threads
Using Apache XML-RPC with a Proxy Server
Tomcat & XML-rpc
Struct array
how to implement XML-RPC
need help with apache's XmlRpcServlet example...