Webサービス統合でプリンターや印刷ジョブに関する情報を返すにはどうすればよいですか?
質問
%Response% 変数には、印刷が失敗した場合の情報が含まれていません。プリンターや印刷ジョブのステータス情報を返すように、Webサービス連携を設定するにはどうすればよいですか?
回答
この目的のために利用できる変数がいくつかあります。
連携内のレスポンスアクションでは、プリンターのジョブやステータスに関する情報を取得できる2つの変数が用意されています。これら2つの変数は、ジョブが成功した場合には有効な情報を返し、失敗した場合には変数名がそのまま表示されます。
3つ目の変数は連携ベースの変数で、連携が失敗した場合のみ情報が表示されます。
レスポンスの作成
連携のレスポンスアクションでは、独自のレスポンスを作成する必要があります。ここでは分かりやすくするためにプレーンテキストを使用しています。
埋め込みレスポンステンプレート:
Print Job Status = %PrintJobStatus%
Print Job Messages = %PrintJobMessages%
Last error message = %LastErrorMessage%
レスポンス例
印刷が成功した場合は、ステータスが「成功」と表示され、メッセージでもそれが確認できます。エラーメッセージは空なので、変数名だけが表示されます。
Job Status = Success
Print Job Messages = BarTender successfully sent the print job to the spooler.
Job Name: resttest2.btw
Document: resttest2.btw
Printer: Zebra ZT420 (300 dpi)
Last error message = %LastErrorMessage%
失敗した場合のレスポンス例では、エラーメッセージは表示されますが、印刷ステータスは表示されません。
Print Job Status = %PrintJobStatus%
Print Job Messages = %PrintJobMessages%
Last error message = Print job 'resttest2.btw' did not complete due to the following error: BarTender cannot use printer 'fakeprinter' to design, print, or export a template due to a printer setup problem.
A Windows error code was returned: 1801
Error message: The printer name is invalid.
There are several possible reasons:
1) The printer is not turned on or is off line. Try printing a test page from Windows.
2) The printer does not exist on your system or network.
3) Security settings prevent access to the printer.
4) If you use a network for printing, there may be a problem with the network connection or the printer driver.
5) There may not be enough memory available. Try closing files and programs you aren't using.
6) The printer driver is installed incorrectly. Try reinstalling the printer driver.