Setting Up Web Service Integration
Through trial and error I have gotten integration builder to respond and print when a web request is sent to a specific port and integration on the machine it is installed on.
You can see it in action here...
http://screencast.com/t/lhEEn7P1
You can see that integration builder is listening for requests on port 10101 (in this case), and responds by printing a document when I go to that URL with my local web browser. This is about the simplest situation in the world, because all it does it print out a static label when I go to that url (http://192.168.1.26:10101/Integration/robtest/Execute) which is my local machine where bartender is running.
My question now is, how do I pass actual variables when I post to this URL and then use them in the Actions section to be able to dynamically control the printing? I would prefer JSON format post or XML, but I still need to know how it needs to be formatted.
The "Input Data" section of integation builder has a drop down with JSON and XML as two of the options. How does integration take what I pass in the URL post and use it?
Documentation please!
-
Amal: I assume you're trying to use the "Send web service request" action in your integration? To include JSON payload in request you need to use the POST method. A GET request is only the URL with no payload. Note that you'll also need to set the Content-Type header to be "application/json". To get better aquainted with REST based web service requests I suggest you download, install, and use a REST Client application like Insomnia or Postman.
-
Legacy Poster
★ BarTender Hero ★
In addition, the help files say this...
Database Overrides
-
Data Source: Specifies the data source, if any, to use
when printing the document.-
Use Document Setting: Specifies that the data source
specified in the document will be used. -
None: Specifies that no data source will be used.
-
Integration Input Data: Specifies that the data source
to be used is the integration's input data. -
Text File: Specifies that a text file will be used for
the data source. -
SAP IDoc File: Specifies that a SAP IDoc file will be
used for the data source. -
Location: Specifies the file system where the data
source file exists. File systems or locations can include local file systems or
network shares, Librarian, FTP, WebDAV (HTTP), and Dropbox. Available if
either Text File or SAP IDoc File are selected as the Data Source.
But it goes into no further explanation of details in how to tie into the "Integration Input Data" . It seems like that is what I want. But I cannot figure out the details a programmer needs to implement it. The online help always seems to go right up to the point of getting to the "meat" of things, and then stops. Is there other documentation that gets into the technical aspects of implementing this.
0 -
Yes, our technical writers are busy working on additional documentation in the form of white papers, and no doubt BarTender 2016 R2 will add more expansive detail to the Help system on these topics. Please bear with us in the meantime.
Find attached a quick document I've put together for handling GET requests with parameter values used to set the document and printer to use, and to set data directly on the label.
0 -
Legacy Poster
★ BarTender Hero ★
This is great! Thank you. We got it working based on the document you posted above.
0 -
Did you get that working with POSTed JSON data, or did you go another route? I'd be interested to learn what you went with in order to complete the solution. Cheers!
0 -
Update on how to use JSON data.
If we assume the below JSON data is being POSTed to your web service on the Integrations Platform:
{"CompanyName": "Seagull Scientific","Address": "Madrid, Spain","PostCode": "28001"}Make sure the "Input Data" for your integrations is set to "JSON Variables".This would create in the integration at time of the event the following Variables that can then be used in your integration actions. There is no need to create custom variables in a predefined way:%CompanyName%%Address%%PostCode%*Note that these variables are case sensitive.If you wanted to transform this data into a CSV, which BarTender could then deal with as a record set, then add a Set Variables action, give it a name like JSONdata, and then a value like below:"CompanyName","Address","Postcode""%CompanyName%","%Address%","%PostCode%"I hope that helps.0 -
Legacy Poster
★ BarTender Hero ★
Can the host name of url not localhost?
When I start advanced rest client on machine B and make GET request A's ip>/Integration/getlabel/Execute?ctnno=00001 (Integration Builder is hosted in machine A), the rest client returns connection timeout.
Is the call blocked by firewall?
What can the cause be?
Thanks,
Connie
0 -
connie107: Yes of course the URL can be on a different PC, not just the localhost, as otherwise that would be a not very useful feature. I guess it could be firewall problems. I suggest you get in contact with tech-support and do a fault diagnosis.
0 -
Mark Janos
★ BarTender Hero ★
Hi Support,
Is there any way to specify a "RecordSet" directly in JSON?
If I use BTXML I can specify a RecordSet inline with the XML using CDATA, but is there a way to do this using a JSON request body?
My goal is to specify an arbitrary number of "Named Data Sources" (label parameters) without having to manually map these to label parameters.
The reason for this is that I can specify both the name of the label and the printer using a JSON element, but because I have hundreds of label designs, I don't want to manually map all the label parameters to elements in the JSON document.
Thanks for your help,
Mark J
0 -
Mark: Alas, there is no CDATA equivalent value type in JSON. However, as alluded to in the below StackOverflow article, you could cheat by having the record set data be crammed into a single JSON variable value, and then have the Integration Platform make use of it as record data on the server side. Perhaps you'd need to do some transforms on the integration variable that contains the record data should you have encoded the data, or used a special placeholder character for the record separator. Once done, you can then use that transformed integration variable as being the source of your record set in a BarTender Print Document action.
https://stackoverflow.com/questions/14935866/json-is-there-any-xml-cdata-equivalent
0 -
Peter Dyson
★ BarTender Hero ★
Just wondering on how I might be able to put in a custom URL variable for Integration to be able to listen for JSON data? It seems like the URL is set for localhost and I cannot change it.
0 -
The name of the web service endpoint is set in the path of the URL. For example if you set a name of TEST, the the URL path would be: /Integration/TEST/Execute
The "localhost" just refers to the name of the computer on which the web service is running. Therefore, when you're setting this up all on the same computer then localhost refers to itself. If you were to then deploy the integration to a computer named "testserver" then the full URL would look like this: http://testserver/Integration/TEST/Execute
0 -
Amal Hantash
★ BarTender Hero ★
Hello,
My Integration Builder creates only Get (I checked Variables section of the integration), However, get does't allow me to send body. How can I sen json/variables body with a get message? is there a way I can send a post message?
Your prompt response is greatly appreciated
0
Please sign in to leave a comment.
Comments
13 comments