1

我正面临一个异常调用 moses(统计机器翻译)作为安装了 xmlrpc 的服务。我首先打开了一个到摩西服务器的端口

--Listening on port 8082

但主要问题是当我发送一个带有 xml 作为正文参数的休息请求时。

<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>

当我在http://xxx.xxx.xxx.xxx:8082/RPC2上将其作为 POST 请求执行时

我注意到端口上的服务失败并出现异常“在抛出 'xmlrpc_c::fault' Aborted 的实例后调用终止”

我认为主要问题在于 xml 正文结构,但我在网上找不到任何有关翻译方法的文档。有什么建议么?谢谢你。

更新

请注意,如果我打开一个带有设置的端口

--threads all

我从来没有得到回应。

4

1 回答 1

0

一种可行的方法,但可能不是最干净和安全的,是从 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")
                }
            }

客户端类似于client.py

于 2018-06-22T08:17:29.947 回答