Hi, I'm trying to use the file.save service through xml-rpc from a Java application to upload images files to a Drupal 6 server, but I'm stuck with a weird problem, which I really can't figure out.
I keep getting the same "Parse error. Request not well formed." response from the server over and over (using the undocumented Sun's Base64Encoder which generates a String - and not byte arrays - the server's error message is an empty string - fault code 1...) , and I'm guessing something is going wrong during the request messsage parsing.
I think I'm doing the encoding fine (inputting the generated encoded data to external decoders works fine, I get the original, untouched, file as it should be, but still I'm open to suggestion on this issue too), the data it's enclosed in base64 tags in the request packets.
I've tried both the Apache XML-RPC client and the Redstone one with the same results, not mentioning the number of different base64-encoding ways I gave a chance to.
Here's my code, maybe someone can figure out what I'm doing wrong.

...
File img = ...
...

MessageData md = new MessageData("file.save"); //a "time-saving" class which generates all necessary data for the xml-rpc method call (hash,timestamp,nonce...)
byte[] data = Utils.getBytesFromFile(img); //this retrieves all the file's bytes
byte[] encData = Base64.encode(data); //base64 encoding

//xml-rpc request - using Redstone XML-RPC (but it's similar with Apache's)

Map<String, Object> fileData = new HashMap<String, Object>();
fileData.put("file",encData);
fileData.put("filepath", img.getName());

Object fid = _fileProxy.save(md.hash, md.domain,md.timestamp, md.nonce, _sessid, fileData);
  //here the xmlrpc API throws an exception , due to Drupal's bad response
  //_fileProxy is an XmlRpcClient generated by the API on a custom interface basis
  // note that the MessageData and _sessid related part it's working fine, since I'm able to call every other "default" service
  // I also tried to wrap the Map with an array, no luck obviously

Please feel free to reply with any thought, since I really need to find a solution for this issue, as soon as possible :)

Comments

gdd’s picture

Did you ever resolve this issue? I am unfamilair with Java myself, but I know the patch that implemented this functionality went through some changes before being committed a few weeks ago. You might want to try the most recent -dev. I have been using this with Drupal's built-in XMLRPC in a production environment for some months now with no issues. If I don't hear back in a few day's I'll mark this fixed.

gdd’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.