E
Erik Wasser
Today I've tried to do some XML-RPC calls with 3 different libraries.
And I failed. Or - to be more exact - the libraries failed, but read on.
Here's an client example for the 'Frontier::Client' library:
#!/usr/bin/perl
use strict;
use warnings;
use Frontier::Client;
use Data:umper;
use utf8;
use encoding 'utf8';
my $client = Frontier::Client->new(
# please ignore the fact that google is not offering
# any services under this adress
url => 'http://www.google.com',
encoding => 'utf-8',
use_objects => 0,
);
print Dumper($client->call('double', 'ä'));
The script have to be saved in UTF8 mode otherwise the umlaut will not
be saved correctly. Here's the output of the RPC request call:
0x0000: 4500 00ce fd6e 4000 4006 8183 0a00 10dc E....n@.@.......
0x0010: 42f9 5d63 c507 0050 574e 1362 7e4c ff2e B.]c...PWN.b~L..
0x0020: 5018 16d0 bbf8 0000 3c3f 786d 6c20 7665 P.......<?xml.ve
0x0030: 7273 696f 6e3d 2231 2e30 2220 656e 636f rsion="1.0".enco
0x0040: 6469 6e67 3d22 7574 662d 3822 3f3e 0a3c ding="utf-8"?>.<
0x0050: 6d65 7468 6f64 4361 6c6c 3e0a 3c6d 6574 methodCall>.<met
0x0060: 686f 644e 616d 653e 646f 7562 6c65 3c2f hodName>double</
0x0070: 6d65 7468 6f64 4e61 6d65 3e0a 3c70 6172 methodName>.<par
0x0080: 616d 733e 0a3c 7061 7261 6d3e 3c76 616c ams>.<param><val
0x0090: 7565 3e3c 7374 7269 6e67 3ee4 3c2f 7374 ue><string>.</st
0x00a0: 7269 6e67 3e3c 2f76 616c 7565 3e3c 2f70 ring></value></p
0x00b0: 6172 616d 3e0a 3c2f 7061 7261 6d73 3e0a aram>.</params>.
0x00c0: 3c2f 6d65 7468 6f64 4361 6c6c 3e0a </methodCall>.
The XML was correctly marked with UTF-8 but the german umlaut is encoded
in one octet (0xe4) but german umlauts are two octets in UTF-8.
The two others libraries (RPC::XML::Client and XMLRPC::Lite) failed in
nearly the same way. But I don't want to pretend that I'm the super
programmer so maybe I'm here the problem.
Is there anyone out there who is using XML-RPC in perl with real UTF-8
parameters (not encoded in Base64)? A lot of example scripts from the
internet are still using plain 7-Bit ASCII and that is not a problem at
all.
Any hints or urls are welcome.
And I failed. Or - to be more exact - the libraries failed, but read on.
Here's an client example for the 'Frontier::Client' library:
#!/usr/bin/perl
use strict;
use warnings;
use Frontier::Client;
use Data:umper;
use utf8;
use encoding 'utf8';
my $client = Frontier::Client->new(
# please ignore the fact that google is not offering
# any services under this adress
url => 'http://www.google.com',
encoding => 'utf-8',
use_objects => 0,
);
print Dumper($client->call('double', 'ä'));
The script have to be saved in UTF8 mode otherwise the umlaut will not
be saved correctly. Here's the output of the RPC request call:
0x0000: 4500 00ce fd6e 4000 4006 8183 0a00 10dc E....n@.@.......
0x0010: 42f9 5d63 c507 0050 574e 1362 7e4c ff2e B.]c...PWN.b~L..
0x0020: 5018 16d0 bbf8 0000 3c3f 786d 6c20 7665 P.......<?xml.ve
0x0030: 7273 696f 6e3d 2231 2e30 2220 656e 636f rsion="1.0".enco
0x0040: 6469 6e67 3d22 7574 662d 3822 3f3e 0a3c ding="utf-8"?>.<
0x0050: 6d65 7468 6f64 4361 6c6c 3e0a 3c6d 6574 methodCall>.<met
0x0060: 686f 644e 616d 653e 646f 7562 6c65 3c2f hodName>double</
0x0070: 6d65 7468 6f64 4e61 6d65 3e0a 3c70 6172 methodName>.<par
0x0080: 616d 733e 0a3c 7061 7261 6d3e 3c76 616c ams>.<param><val
0x0090: 7565 3e3c 7374 7269 6e67 3ee4 3c2f 7374 ue><string>.</st
0x00a0: 7269 6e67 3e3c 2f76 616c 7565 3e3c 2f70 ring></value></p
0x00b0: 6172 616d 3e0a 3c2f 7061 7261 6d73 3e0a aram>.</params>.
0x00c0: 3c2f 6d65 7468 6f64 4361 6c6c 3e0a </methodCall>.
The XML was correctly marked with UTF-8 but the german umlaut is encoded
in one octet (0xe4) but german umlauts are two octets in UTF-8.
The two others libraries (RPC::XML::Client and XMLRPC::Lite) failed in
nearly the same way. But I don't want to pretend that I'm the super
programmer so maybe I'm here the problem.
Is there anyone out there who is using XML-RPC in perl with real UTF-8
parameters (not encoded in Base64)? A lot of example scripts from the
internet are still using plain 7-Bit ASCII and that is not a problem at
all.
Any hints or urls are welcome.