function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
yhyh 

How can you find out the encoding when using XML-RPC

I'm still using the XML RPC API and I would like to find out what encoding my server is configured for. I noticed in SOAP there is the concept of a describeGlobal. Does anyone know the equivalent in the XML RPC api? Does anyone even know how to get a copy of the documention for XML-RPC anymore? I can't seem to find it anywhere.
ScotScot

As I am sure you know, you really want to convert to the newer SOAP API, since so many of the new features are not available through the XML-RPC.

For XML-RPC, you'll want the 2.0 API reference - the last one which included XML-RPC as a full player.  I'll try attaching a copy ...

Scot

yhyh
Ok, i used a the describe call with type 'global' and it returned an encoding of 'UTF8'. What is confusing here is that i keep getting an exception when i do an insert..and the exception complains that:

java.io.IOException: Invalid character data corresponding to XML entity Œ

At first i thought it was because the sfdc server was not utf8 but it looks like it is...now i'm stumped. Anyone have any ideas why this is happening? By the way, the character in question here is 'Å'
yhyh
Ok, i used a the describe call with type 'global' and it returned an encoding of 'UTF8'. What is confusing here is that i keep getting an exception when i do an insert..and the exception complains that:

java.io.IOException: Invalid character data corresponding to XML entity Å

At first i thought it was because the sfdc server was not utf8 but it looks like it is...now i'm stumped. Anyone have any ideas why this is happening? By the way, the character in question here is 'Å'
SuperfellSuperfell
Its likely that the actual encoding the of XML-RPC request doesn't match the encoding its claiming to be. You could capture the HTTP traffic and examine the bytes to make sure the actual xml on the wire really is UTF-8
yhyh
I'm using Apache XML-RPC client API. I can't find a way to 'grab the http bytes'. The api to execute the describe call returns a java object (Hashtable). Do you know of a way to grab the HTTP bytes?
SuperfellSuperfell
change your code to make an HTTP request instead of HTTPS and use a network sniffer or proxy tool to capture it (try YATT http://www.pocketsoap.com/YATT/ or ethereal http://www.ethereal.com/)
yhyh
Actually, I suspect that i'm sending the data to the server using iso-8859-1. Here is a sample of the login command

sfdc.loginversion2.0passwordfoousernamefoo@bar.com


Does anyone know how to set the encoding of the xml-rpc call to server?

I'm using Apache's XML RPC API
djordandjordan

I found that getting the Apache XML-RPC library to read UTF-8 responses was a bit tricky. It seems to interpret a stream of bytes as a stream of characters, assuming each is 8 bits. If you break the stream up and reconstruct the string then the non-ASCII characters are interpreted correctly by Java:

import org.apache.xmlrpc.*;

During init()

        XmlRpcClient xmlrpc = new XmlRpcClient(this.serverUrl);
        XmlRpc.setEncoding("UTF-8");

 

Then:
Object value = hashTableofSforceValues.get(sfdcFieldName);
if (value instanceof String) {
                        try {
                            value = new String(((String) value).getBytes(), "UTF-8"); // Break the string into bytes and re-interpret
                        } catch (UnsupportedEncodingException e) {
                            logger.warn("Error converting " + (String) htContactSFDC.get(sfdcFieldName) + " to UTF-8", e);
                        }
                    }

 

Hope this helps,

David