Question

I'm trying to use Apache XMLRPC to manage posts at a small weblog service. The support isn't great there and they can't really help. They say the weblog supports the metaweblog api.

I'm trying to retrieve all my posts using the rpc "metaWeblog.getPost":

token = client.invoke("metaWeblog.getPost", new Object[] {123, // also tried "123" and "\"123\""
                                                          "username", 
                                                          "password"});

When I use 123 (no quotes), I get this response: java.lang.Exception: java.lang.Integer cannot be cast to java.lang.String

When I use "123" or "\"123\"" (quotes), I get this response: java.lang.Exception: Invalid postid format: 123

This code does work with my Wordpress weblog's.

Was it helpful?

Solution

Wordpress probably works because it is in PHP and isn't as type sensitive as java.

The docs for metaWeblog say that the raw xml representation of a request looks like this:

<?xml version="1.0"?>

<methodCall>

    <methodName>metaWeblog.getPost</methodName>

    <params>

        <param>

            <value><i4>1829</i4></value>

            </param>

        <param>

            <value>Bull Mancuso</value>

            </param>

        <param>

            <value><base64>bm93YXk=</base64></value>

            </param>

        </params>

    </methodCall>

So you need to try establishing the params as variables of the right type

The postId needs to be a 32 big integer, the password is base64 encoded, the username is a string.

Declare your variables properly and pass variables, not quoted constants, to the invoke method.

Then, the xml that is formed under the hood by the rpc library will make sure that <i4></i4> is around the post id, etc.

Hope this helps a little. At the very least, you can prove that the other side isn't properly implementing metaWeblog. At best, you've solved your problem and can keep moving.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top