We help IT Professionals succeed at work.

Submit strings with special chars (UTF-8) in an array through XML-RPC

mypatek asked
Last Modified: 2009-07-29

I just faced the following problem:

If I make the following XML call with an array of names (@names) it works fine except the names contain special chars.

Working example: Miller, Tommen, Braun
Not working: Miller, Sülden, Braun (I get a http error / server error)

.. RPC::XML::struct->new( email => $in_email, language => $in_language, name=>\@names ));

The names should be submitted by XML RPC in UTF8 encoding. The users enter the name in a html form with the header "<meta http-equiv="content-type" content="text/html; charset=UTF-8"></meta>"

Is it necessary to convert the input to UTF8 or is this already done by the html form with the respective header?

I've tried to convert the names before putting them into an array with the following to avoid the mentioned error. But no success: What exactly does this?

utf8::encode($in_name) if utf8::is_utf8($in_name);
Watch Question

Top Expert 2009
Unlock this solution and get a sample of our free trial.
(No credit card required)


Hmm, unfortunately no success. I still get the following error:
Problem: RPC::XML::Client::send_request: HTTP server error: Internal Server Error

How should I add the strings to the array to avoid this error?

Current way: push(@names,$in_firstname." ".$in_lastname);

Top Expert 2009

You could change $in_firstname and $in_lastname before adding it to the array.
    $in_firstname=encode("utf8", $in_firstname);
    $in_lastname = encode("utf8", $in_lastname);

Or change what is added to the array
    push(@names,encode("utf8", $in_firstname." ".$in_lastname));

Or you could update the array after adding:
    $_=encode("utf8", $_) foreach (@names);


Thanks, but no change. still the same error while submitting..

"Problem: RPC::XML::Client::send_request: HTTP server error: Internal Server Error"

So we should forget the UTF thing.. I thought this would cause the error but as an utf encoded string contains also special chars the encoding itself cannot resolve the above mentioned http error.

If I have the name: "Méndez Tony" in the string, the error occurs

if I change the char "é" to e --> "Mendez Tony", the XML call works
Top Expert 2009

Do you know what type of encoding is needed?
The Encode module can handle many encodings, see here:

There are also other modules for other specific types of encoding.


UTF8 format is requested by the remote server.

If I pass the name with special chars as a single value ($name) to the remote server with the following procedure:
RPC::XML::struct->new( name => $name ));
no error shows up

but submission of multiple values
RPC::XML::struct->new( email => $in_email, language => $in_language, name=>\@names ));
does not work if one name has special chars in it.

So I don't think there is a problem with the data format

Some months ago you recommended to use name=>\@names to submit multiple values to the remote xml server. I suppose if a http error is displayed, the call won't even reach the remote server and the error occurs on the local machine?? Is the array unpacked before the data is transmitted to the remote server?
Top Expert 2009

I'm not sure how the data is actually sent to the server.  Can you access the server error logs?  They might help you figure out what the cause of the error is.


Sorry for the late reply..

I checked my error log with "debug setting" but get no info. The error seems to occur on the remote server and I don't have access there to the errorlogs.

But it seems to be definitely an encoding problem as the error occurs also with single value parameters, not only arrays.


# my $name = "Rübe";
my $name = "Rube";

my $server =  'https://user:pw@xml.server.com/xml-rpc';
my $cli = RPC::XML::Client->new($server, combined_handler => \&problems);

my $req = RPC::XML::request->new('data.getNames', RPC::XML::struct->new( user_id => $user_id, name => $name ));

my $resp = $cli->simple_request($req);

"Rube" works; "Rübe" generates an error


is there a way to tell the xmlrpc handler that the data is submitted in UTF8?
Top Expert 2009

I'm not sure.  The server might not allow those characters.  If so, there is nothing you can do on the client side...

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.