• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

client program using apache xmlrpc libraries

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The sayHello method is a test method that returns a string "hello". it does,nt requires an authentication.
 
Prasath Nadarajah
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Prasath Nadarajah
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic