| 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
|
|
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
|
 |
 |
|
|
subject: client program using apache xmlrpc libraries
|
|
|