Print Document Using a Web Service

Overview

The goal of this example is to use a Web Service Integration to print a BarTender document. A web service is a software system designed to support interoperable machine-to-machine interaction over a network. Any application that can send a web service request can trigger the integration.

This example enables a web service to send a GET request to the BarTender Integration Service through a Web Service integration. The web service will pass values that the integration will use for named data sources in the BarTender document.

Scenario

A company with an external ERP system needs to populate a text field and a barcode value on a BarTender document using a web request. To accomplish this, the web request data will be passed to an integration, which passes the data to the named data sources of the specified BarTender Document. The named data sources then populate the text object and the barcode object on a document at print-time.

Implementation

The following procedures describe how to set up, deploy, and verify the integration for the scenario outlined above.

Create the BarTender Document

  1. Open BarTender.
  2. From the File menu, select New to open the New Document Wizard.
  3. Select Blank Template, and then click Finish to close the New Document Wizard. A new document appears in BarTender.
  4. From the File menu, select Print to open the Print dialog.
  5. From the Name dropdown list, select the printer you want to use.
  6. Click Close to close the Print dialog.
  7. From the File menu, select Page Setup to open the Page Setup dialog and configure your page as needed.
  8. When you're finished configuring your page, click OK to close the Page Setup dialog.
  9. From the Create menu, select Text, then select Single Line.
  10. Click on the template to place the text object.
  11. From the Create menu, select Barcode, then select Code 128.
  12. Click on the template to place the barcode object.
  13. Double-click the border around the text object to open the Text Properties dialog.
  14. On the Data Source tab, at the right of the Name field, click  to open the Change Data Source Name Wizard.
  15. In the Name field, enter "Company" (without the quotation marks).
  16. Click OK to close the Change Data Source Name Wizard.
  17. Leave the Type as Embedded Data.
  18. In the Embedded Data field, enter your company name.
  19. Click Close to close the Text Properties dialog.
  20. Double-click the barcode object to open the Barcode Properties dialog.
  21. On the Data Source tab, at the right of the Name field, click  to open the Change Data Source Name Wizard.
  22. Select Name the data source.
  23. In the Name field, enter "IDNumber" (without the quotation marks).
  24. Click OK to close the Change Data Source Name Wizard.
  25. Leave the Type as Embedded Data.
  26. In the Embedded Data field, enter any 4-digit number.
  27. Click Close to close the Barcode Properties dialog.
  28. Save the file as GETSampleDocument.btw.
  29. Close BarTender.

Create the Integration File

  1. Open Integration Builder.
  2. Click Create New Integration to open the New Integration dialog.
  3. Click Web Service and then click OK.
  4. In the Web Service Integration pane, ensure that Service is selected.
  5. In the Web Service Integration pane, select Integration.
  6. In the Properties pane, name your integration and enter a description if you wish.
  7. From the Start Integration dropdown list, select Automatic.
  8. In the Web Service Integration pane, select Response.
  9. In the Properties pane under Response, select application/json from the Content-type dropdown list.
  10. From the Source dropdown list, select Action Summary, so you will receive a summary after your integration executes.
  11. In the Web Service Integration pane, select Variables.
  12. Scroll to the bottom of the Properties pane and click  Name field, enter "Company" (without the quotation marks).
  13. Click   to create another new variable.  In the Name field, enter "IDNumber" (without the quotation marks).
  14. In the Web Service Integration pane under Actions, select Print Document.
  15. In the Properties pane under Document, enter the path and file name for the previously created BarTender document, GETSampleDocument.btw.
  16. Click  to add the Named Data Sources and Print Option Overrides to the integration.
  17. Scroll down to Named Data Sources. If it isn't already enabled, check Specify Values for Named Data Sources.
  18. In the Named Data Sources list, delete the current value for the Company named data source.
  19. At the right of the Value column, click  and select Variables.
  20. From the Insert Variable dialog, select Company and click OK. This will set the value of the Company named data source to %Company%.
  21. In the Named Data Sources list, delete the current value for the IDNumber named data source.
  22. At the right of the Value column, click  and select More Variables.
  23. From the Insert Variable dialog, select IDNumber and click OK. This will set the value of the IDNumber named data source to %IDNumber%.
  24. Click  in the top left corner of Integration Builder to save the integration file as WebRequestPrint.btin.

The integration is now ready to be deployed.

Deploy the Integration

  1. From the Integration Builder toolbar, click  Deploy Integration to open the New Deployment dialog.
  2. In the New Deployment dialog, enter a name and description for your deployment.
  3. Ensure that the Integration File setting lists WebRequestPrint.btin. Otherwise, click Browse and browse to and select WebRequestPrint.btin.
  4. For Target Servers, add the server(s) you want to deploy the integration file to.
  5. Specify the desired Error Handling settings.
  6. Click OK to close the dialog and deploy the integration file.
  7. Administration Console will open on the Integrations node, displaying your integration.

Run the scenario and view integration processing

  1. The BarTender Integration Service is monitoring the selected web service. Send the web request through the url using your preferred method. The url will look something like this: http://<host>/Integration/WebRequestPrint/Execute.
Note that <host> is the name of the host computer on which BarTender and the Integration Web Service are running, and WebRequestPrint is the name given in the Service Name box above the url.
  1. The Integration Service reads the web request and passes the values to BarTender.
  2. The BarTender document's named data sources are now populated by the values in the web request.
  3. The BarTender document prints.

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Please sign in to leave a comment.