bhinks.com | random geekery

I recently hit a bit of a speed bump during a project that involved making calls to a remote system which exposes an XML-RPC API. Most of my experience consuming APIs in Java has revolved around SOAP. XML-RPC seemed like it would be a walk in the park by comparison, especially after I found the Apache XML-RPC library.

Once I started to write some code, I paused and looked back at the spec of the remote method. The method takes a single parameter which is a struct containing several named members.

<methodCall>
  <methodName>SomeMethod</methodName>
  <params>
    <param>
      <value>
        <struct>
          <member>
            <name>SomeNumber</name>
            <value><int>0</int></value>
          </member>
          <member>
            <name>SomeString</name>
            <value>Blah</value>
          </member>
        </struct>
      </value>
    </param>
  </params>
</methodCall>

It wasn’t obvious how I should handle this. I wanted to pass my parameters in a HashMap, but XmlRpcClient only takes parameters in a List or an Object[]. Neither of those options allow me to name values and mix types, as the spec above requires. Google results for this issue were pretty thin (for API clients written in Java, anyway.) I did finally find an answer which was simple enough that I really should have figured it out on my own, but here it is: http://developer.wikidot.com/forum/t-251326/solved-java-xmlrpcexception-calling-parameters-do-not-match

Object[] params = new Object[1];
HashMap map = new HashMap();
map.put("SomeNumber", 0);
map.put("SomeString", "Blah");
params[0] = map;

Since it took me a little while to track down a solution, I’m hoping that adding this extra search result to The Googles will help somebody else.

No tags

Nov/11

2

It’s Back.

Yesterday was my friend Orion’s birthday. He recently introduced me to a web comic called Gunshow. A couple of my favorite strips involve one of my least favorite sandwiches: the dreaded McRib. Here are the comics:

http://gunshowcomic.com/368

http://gunshowcomic.com/463

Since the McRib is indeed back, I decided that we needed to have a McDonald’s feast for Orion’s birthday. Orion, my cousin Jon, and I dined on McRibs, french fries, and bottles of Yuengling Light. It was terrible (the beer was OK). I think the McRib actually made Orion mildly ill. Nevertheless, I think this may become a new tradition. When I was leaving my house to run this twisted errand, my wife asked what I was up to.

“I’m going to go eat McRib with Orion and Jon,” I told her.

She looked confused. “Don’t you hate the McRib?”

“Yes I do,” I replied, “but it’s back!”

So the hourglass of saucy doom has been reset. Will McRib come back next year? I hope not. If it does, you can be sure that somewhere three dudes will be consuming it begrudgingly to carry on a joke that will hopefully still be as funny to me as it is now.

No tags

Theme Design by devolux.nh2.me