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
- Open BarTender.
- From the File menu, select New to open the New Document Wizard.
- Select Blank Template, and then click Finish to close the New Document Wizard. A new document appears in BarTender.
- From the File menu, select Print to open the Print dialog.
- From the Name dropdown list, select the printer you want to use.
- Click Close to close the Print dialog.
- From the File menu, select Page Setup to open the Page Setup dialog and configure your page as needed.
- When you're finished configuring your page, click OK to close the Page Setup dialog.
- From the Create menu, select Text, then select Single Line.
- Click on the template to place the text object.
- From the Create menu, select Barcode, then select Code 128.
- Click on the template to place the barcode object.
- Double-click the border around the text object to open the Text Properties dialog.
- On the Data Source tab, at the right of the Name field, click to open the Change Data Source Name Wizard.
- In the Name field, enter "Company" (without the quotation marks).
- Click OK to close the Change Data Source Name Wizard.
- Leave the Type as Embedded Data.
- In the Embedded Data field, enter your company name.
- Click Close to close the Text Properties dialog.
- Double-click the barcode object to open the Barcode Properties dialog.
- On the Data Source tab, at the right of the Name field, click to open the Change Data Source Name Wizard.
- Select Name the data source.
- In the Name field, enter "IDNumber" (without the quotation marks).
- Click OK to close the Change Data Source Name Wizard.
- Leave the Type as Embedded Data.
- In the Embedded Data field, enter any 4-digit number.
- Click Close to close the Barcode Properties dialog.
- Save the file as GETSampleDocument.btw.
- Close BarTender.
Create the Integration File
- Open Integration Builder.
- Click Create New Integration to open the New Integration dialog.
- Click Web Service and then click OK.
- In the Web Service Integration pane, ensure that Service is selected.
- In the Web Service Integration pane, select Integration.
- In the Properties pane, name your integration and enter a description if you wish.
- From the Start Integration dropdown list, select Automatic.
- In the Web Service Integration pane, select Response.
- In the Properties pane under Response, select application/json from the Content-type dropdown list.
- From the Source dropdown list, select Action Summary, so you will receive a summary after your integration executes.
- In the Web Service Integration pane, select Variables.
- Scroll to the bottom of the Properties pane and click Name field, enter "Company" (without the quotation marks).
- Click to create another new variable. In the Name field, enter "IDNumber" (without the quotation marks).
- In the Web Service Integration pane under Actions, select Print Document.
- In the Properties pane under Document, enter the path and file name for the previously created BarTender document, GETSampleDocument.btw.
- Click to add the Named Data Sources and Print Option Overrides to the integration.
- Scroll down to Named Data Sources. If it isn't already enabled, check Specify Values for Named Data Sources.
- In the Named Data Sources list, delete the current value for the Company named data source.
- At the right of the Value column, click and select Variables.
- From the Insert Variable dialog, select Company and click OK. This will set the value of the Company named data source to %Company%.
- In the Named Data Sources list, delete the current value for the IDNumber named data source.
- At the right of the Value column, click and select More Variables.
- From the Insert Variable dialog, select IDNumber and click OK. This will set the value of the IDNumber named data source to %IDNumber%.
- 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
- From the Integration Builder toolbar, click Deploy Integration to open the New Deployment dialog.
- In the New Deployment dialog, enter a name and description for your deployment.
- Ensure that the Integration File setting lists WebRequestPrint.btin. Otherwise, click Browse and browse to and select
WebRequestPrint.btin.
- For Target Servers, add the server(s) you want to deploy the integration file to.
- Specify the desired Error Handling settings.
- Click OK to close the dialog and deploy the integration file.
- Administration Console will open on the Integrations node, displaying your integration.
Run the scenario and view integration processing
- 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
.
<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.- The Integration Service reads the web request and passes the values to BarTender.
- The BarTender document's named data sources are now populated by the values in the web request.
- The BarTender document prints.