在过去的几年里,网络服务已经被IT产业的 "buzz words"
通常这两个主网络服务的执行是用远程程序调用 (RPC)的:
SOAP/WSDL
XML-RPC
PaperCut NG使用的是XML-RPC。XML-RPC是一项轻量级的网络服务执行和对所有主程序和脚本语言有着很好的支持,如:C#、Java、Visual Basic、Perl和Python。XML-RPC的方法通过PaperCut NG在 http://[server_name]:9191/rpc/api/xmlrpc的概要下有显示。
| Method | Description |
|---|---|
|
| Test to see if a user exists in the system/database. |
|
| Get the user's current account balance. |
|
| Gets a user property. Properties include the user's full name, department, email, notes, office and restriction status among others. |
|
| Sets a user property. Properties include the user's full name, department, email, notes, office, password (for internal users) and restriction status among others. |
|
| Adjust a user's account balance by an adjustment amount. An adjustment may be positive (add to the user's account) or negative (subtract from the account). |
|
| Adjust the account balance for all users in a group by an adjustment amount. An adjustment may be positive (add to the user's account) or negative (subtract from the account). |
|
| Adjust the account balance for all users in a group by an adjustment amount, but not above the given limit. An adjustment may be positive (add to the user's account) or negative (subtract from the account). |
|
| Set the balance on a user's account to a set value. This is conducted as a transaction. |
|
| Set the balance for each member of a group to the given value. |
|
| Reset the counts (pages and job counts) associated with a user account. |
|
| Re-applies initial settings on the user. Initial user settings are based on group membership. |
|
| Disable printing for a user for selected period of time. |
|
|
Triggers the process of adding a new user account defined by a given
|
|
| Rename a user account. Useful when the user has been renamed in the domain / directory, so that usage history can be maintained for the new username. This should be performed in conjunction with a rename of the user in the domain / user directory, as all future usage and authentication will need to use the new username. |
|
| Delete/remove an existing user from the user list. Use this method with care. Calling this will perminently delete the user account from the user list (print and transaction history records remain). |
|
|
List all user accounts (sorted by username) starting at E.g.:
listUserAccounts(0, 1000) -
returns users 0 through 999
listUserAccounts(1000, 1000) -
returns users 1000 through 1999
listUserAccounts(2000, 1000) -
returns users 2000 through 2999
|
|
|
List all shared accounts (sorted by account name) starting at E.g.:
listSharedAccounts(0, 1000) -
returns users 0 through 999
listSharedAccounts(1000, 1000) -
returns users 1000 through 1999
listSharedAccounts(2000, 1000) -
returns users 2000 through 2999
|
|
|
List all shared accounts the user has access to (sorted by account name), starting at
E.g.:
listUserSharedAccounts("username", 0, 1000) -
returns users 0 through 999
listUserSharedAccounts("username", 1000, 1000) -
returns users 1000 through 1999
listUserSharedAccounts("username", 2000, 1000) -
returns users 2000 through 2999
|
|
| Test to see if a shared account exists in the system/database. |
|
| Gets a shared account property. Properties include access groups, balance, comment options, disabled status, notes, pin and restriction status among others. |
|
| Sets a shared account property. Properties include access groups, balance, comment options, disabled status, notes, pin and restriction status among others. |
|
| Sets a shared account's current account balance. |
|
| Adjust a shared account's account balance by an adjustment amount. An adjustment may be positive (add to the account) or negative (subtract from the account). |
|
| Set the balance on a shared account to a set value. This is conducted as a transaction. |
|
| Create a new shared account with the given name. |
|
| Delete a shared account from the system. Use this method with care. Deleting a shared account will permanently delete it from the shared account list (print history records will remain). |
|
| Allow the given user access to the given shared account without using a pin. |
|
| Allow the given group access to the given shared account without using a pin. |
|
| Revoke the given user's access to the given shared account. |
|
| Revoke the given group's access to the given shared account. |
|
| Gets a printer property. Available properties include: disabled, print-stats.job-count, print-stats.page-count. |
|
| Sets a printer property. |
|
| Reset the counts (pages and job counts) associated with a printer. |
|
| Disable a printer for select period of time. |
|
| Instigate an online backup. This process is equivalent to pressing the manual backup button in the web based admin interface. The data is exported into the server/data/backups directory as a timestamped, zipped XML file. |
|
| Start the process of synchronizing the system's group membership with the OS/Network/Domain's group membership. The call to this method will start the synchronization process. The operation will commence and complete in the background. |
|
| Start a full user and group synchronization. This is equivalent to pressing on the "Synchronize Now" button in the admin user interface. The behavior of the sync process, such as deleting old users, is determined by the current system settings as defined in the admin interface. A call to this method will commence the sync process and the operation will complete in the background. |
|
| An advanced version of the user and group synchronization process providing control over the sync behavior. A call to this method will commence the sync process and the operation will complete in the background. |
|
| Calling this method will start a specialized user and group synchronization process optimized for tracking down and adding any new users that exist in the OS/Network/Domain user directory and not in the system. Any existing user accounts will not be modified. A group synchronization will only be performed if new users are actually added to the system. |
|
|
Return the status (completed flag and a status message) associated with a
backgrounded task such as a sync operation started by the performGroupSync API.
This method returns a struct (hashtable/map) containing elements with keys
|
|
| Import the shared accounts contained in the given tab separated import file (located on the server). |
|
| Import the internal users contained in the given tab-delimited import file (located on the server). See the section called “Batch Internal User Import and Update” for details of the required file format. |
|
|
Import the user card/ID numbers and PINs contained in the given tab-delimited import file. |
|
| Gets the value of a configuration settings. |
|
| Sets the value of a configuration setting. NOTE: Take care updating config values. You may cause serious problems which can only be fixed by reinstallation of the application. Use the setConfigValue API at your own risk. |
表格 A.1. XML Web Services的方法
最好的证明如何使用网络服务界面的方法是使用实例码。PaperCut NG使用的实例码的位于:
[app-path]/server/examples/webservices/
C#和Java的例子也包括了Proxy级的全部文档 – Proxy是一个共同的程序类型设计的。Proxy限制和显示网络服务方法作为标准的方法。设置和使用潜在的XML-RPC库是要用所有Proxy级来处理的,这意味着您采用的是集中调用的方法。
对于更多的例子的目录信息请查看 README.txt文件。在examples/webservices/java/docs/api下包括了Java的例子的全部JavaDoc文件格式。
开发者使用其它的语言诸如:Perl或Python将需要使用XML-RPC库调用目录的方法。所有方法通过<code class="literal">http://[server_name]:9191/rpc/api/xmlrpc</code>被显示。
所有 XML Web Services的命令也要通过server-command程序来使用。PaperCut NG通过网络服务自动选择使用一个完整的程序环境,通过诸如批文件或隐藏的脚本来使用 server-comman程序来调用命令。对于一般的在晚间自动同步用户/组的任务这可能是比较简单的解决方案。
更多有关server-command程序的信息在
“服务器命令(server-command)”中可以找到。
网络服务API全部提供的是对系统内部的访问,因此需要确保其安全性。PaperCut NG使用了两个安全层进行安全访问:
IP地址的安全
鉴定记号 – 需要对每种方法都调用
IP地址级的安全通常是由系统控制的,通过IP地址的指示,允许连接到服务器并调用API。默认此限制仅到localhost (127.0.0.1)。如果程序/脚本在其它系统上利用的是API,那么此系统的IP地址将需要在 → → 下被添加到被列入许可的地址范围。
第一个参数对所有调用方法是一个鉴定记号 (authToken)。在当前发布的鉴定记号里是设立了admin用户密码的(此密码是在server.properties文件里被定义的)。密码必须提供给所有的调用方法。
To specify an alternative web service authentication token, to avoid the need to use/share the built-in
admin user's password:
Login to the system.
Navigate to the Options section.
Click on the Config editor link in the list of actions.
Find the auth.webservices.auth-token config setting.
Enter a new value that will be the new web services authentication token.
Press the button to the right to apply the change.
This authentication token can now be used in addition to the built-in admin user's password.