[英]Call for translation method on Moses as a service using xml-rpc fails
I am facing an exception calling moses (Statistical Machine Translation) as a service with xmlrpc installed. 我遇到一个异常,将moses(统计机器翻译)作为安装了xmlrpc的服务调用。 I firstly open a port to the Moses server
我首先打开一个连接到Moses服务器的端口
--Listening on port 8082
but the main problem is when I send a rest request with an xml as body parameter. 但是主要的问题是当我发送带有xml作为主体参数的rest请求时。
<methodCall>
<methodName>translate</methodName>
<params>
<param>
<value>
<array>
<data>
<value>
<array>
<data>
<value>
<string>struct</string>
</value>
<value>
<string>struct</string>
</value>
</data>
</array>
</value>
</data>
</array>
</value>
</param>
</params>
</methodCall>
When I execute it as a POST request on http://xxx.xxx.xxx.xxx:8082/RPC2 当我在http://xxx.xxx.xxx.xxx:8082/RPC2上将其作为POST请求执行时
I notice that service on port fails with exception "terminate called after throwing an instance of 'xmlrpc_c::fault' Aborted " 我注意到端口上的服务失败,出现异常“抛出'xmlrpc_c :: fault'中止的实例后终止调用”
I think the main problem is with xml body structure but I cannot find any documentation on the web for translate method. 我认为主要问题与xml主体结构有关,但我在网上找不到任何有关翻译方法的文档。 Any suggestions?
有什么建议么? Thank you.
谢谢。
UPDATE 更新
Note that if I open a port with setting 请注意,如果我使用设置打开端口
--threads all
I never get response back. 我再也没有得到回应。
A working approach but may not the most clean and safe, is calling a python client from c# or java since does not exists library on nuget for doing this work. 一种可行的方法,但可能不是最干净,最安全的方法,是从c#或java调用python客户端,因为nuget上不存在执行此工作的库。
ProcessStartInfo start = new ProcessStartInfo();
start.FileName = "C:\\python\\python.exe";
start.Arguments = $"C:\\python27\\client.py {word}";
start.UseShellExecute = false; // Do not use OS shell
start.CreateNoWindow = true; // We don't need new window
start.RedirectStandardOutput = true; // Any output, generated by application will be redirected back
start.RedirectStandardError = true; // Any error in standard output will be redirected back (for example exceptions)
using (Process process = Process.Start(start))
{
using (StreamReader reader = process.StandardOutput)
{
string stderr = process.StandardError.ReadToEnd(); // Here are the exceptions from our Python script
string output = process.StandardOutput.ReadToEnd();
string result = reader.ReadToEnd(); // Here is the result of StdOut(for example: print "test")
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.