So I'm trying to send an xml-rpc message to moses xml-rpc server in Java, but keep getting error:
org.apache.xmlrpc.XmlRpcException: Parameter that is supposed to be a structure is not
I'm using Apache xmlrpc client 3.1.3 from http://ws.apache.org/xmlrpc/client.html. My guess is the parameter definition is not compatible, but after experimenting with different type to use as input, the output is still the same. I have an example of the client, but it's written in perl:
#!/usr/bin/env perl
use Encode;
use XMLRPC::Lite;
use utf8;
$url = "http://localhost:8080/RPC2";
$proxy = XMLRPC::Lite->proxy($url);
$text = "il a souhaité que la présidence trace à nice le chemin pour l' avenir .";
# Work-around for XMLRPC::Lite bug
$encoded = SOAP::Data->type(string => Encode::encode("utf8",$text));
my %param = ("text" => $encoded, "align" => "true");
$result = $proxy->call("translate",\%param)->result;
print $result->{'text'} . "\n";
if ($result->{'align'}) {
print "Phrase alignments: \n";
$aligns = $result->{'align'};
foreach my $align (@$aligns) {
print $align->{'tgt-start'} . "," . $align->{'src-start'} . ","
. $align->{'src-end'} . "\n";
}
}
and here is my code:
XmlRpcClientConfigImpl tConf = new XmlRpcClientConfigImpl();
try {
tConf.setServerURL(new URL("http://127.0.0.1:8080/RPC2"));
tConf.setBasicEncoding("UTF-8");
} catch (MalformedURLException ex) {
ex.printStackTrace(System.out);
}
XmlRpcClient tClient = new XmlRpcClient();
tClient.setConfig(tConf);
List<List<String>> tInPar = new ArrayList<>();
tInPar.add(Arrays.asList(new String[]{"text", "hello"}));
tInPar.add(Arrays.asList(new String[]{"align", "true"}));
String tResult = null;
try {
tResult = (String) tClient.execute("translate", tInPar);
} catch (XmlRpcException ex) {
ex.printStackTrace(System.out);
}
Is it correct?
Thank you for your help
After consulting in moses mailing list, I've been given this java client example for moses server: https://github.com/moses-smt/mosesdecoder/blob/master/contrib/server/SampleClient.java
Thanks