我打算使用XML,尽管据我所知,PaperCut -RPC不支持Node.JS,或者我找不到合适的客户机来实现这个目的。下面是与PaperCut接口的链接:https://www.papercut.com/support/resources/manuals/ng-mf/common/topics/tools-web-services.html
我想知道谁能够让它在JavaScript中工作。我在QNAP中使用Node.js (在集装箱车站)。如果它可以在Python中运行,我应该安装Python容器吗?我可以使用Python中的一段代码向Node.js请求它吗?
发布于 2020-12-18 12:37:45
我在PaperCut软件公司工作
很抱歉,我花了这么长时间才回复这篇文章,但我最终找到了一个空闲的下午来拼凑一些代码。
var xmlrpc = require('xmlrpc')
const authToken = 'token'
const hostAddress = "172.24.96.1"
// Waits briefly to give the XML-RPC server time to start up and start
// listening
setTimeout(function () {
// Creates an XML-RPC client. Passes the host information on where to
// make the XML-RPC calls.
var client = xmlrpc.createClient({ host: hostAddress, port: 9191, path: '/rpc/api/xmlrpc'})
// Sends a method call to the PaperCut MF/NG server
client.methodCall(`api.${process.argv[2]}`, [authToken].concat(process.argv.slice(3)), function (error, value) {
// Results of the method response
if (undefined === error || null === error) {
console.log(`Method response for \'${process.argv[2]}\': ${value}`)
}
else
{
console.log(`Error response for \'${process.argv[2]}\': ${error}`)
}
})
}, 1000)要从命令行运行此命令,请尝试执行以下命令
node main.js getUserProperty alec balancehttps://stackoverflow.com/questions/63983125
复制相似问题