What is the default response returned by a web-service Integration type?
Question
What is the default response returned by a Web Service Integration?
Answer
For each of the responses, the structure will look different depending upon the Content-type setting selected.
Content-type formatting:
- application/json: json style string that has information nested in { brackets }
- text/xml: Standard XML-style formatting. When sending this response, a visual client like Insomnia will format this and make it easy to read.
- application/soap-xml: Standard XML-style formatting like above but sent as a SOAP message instead of plain text
- text: XML response in an unformatted response.
%response% variable
Sample response formatted as XML:
<Response Version="2.0" AppName="BarTender" AppVersion="2016 R8" AppVersionId="1100" AppVersionMajor="11" AppVersionMinor="0" AppVersionBuild="3146" AppInstancePid="29400" AppInstanceGuid="{303F1806-45E6-451E-9EA6-4C13CA93B299}">
<User>XXXXXX</User>
<Server>XXXXX</Server>
<Command Name="Print Document">
<Print ID="25" GUID="{59C2B1CF-B7E9-4572-B97B-66E4955993D7}" JobLastStatus="Queued" JobCompleted="true" JobName="resttest2.btw">
<JobStatus Completed="true">
<TimeJobStart>2018-07-05T10:38:38.183</TimeJobStart>
<TimeJobQueued>2018-07-05T10:38:38.261</TimeJobQueued>
<TimeJobSent>2018-07-05T10:38:38.261</TimeJobSent>
<LastStatus>Queued</LastStatus>
<Description>Print job now waiting to be sent to printer.</Description>
</JobStatus>
<Message Id="1750" Guid="{889B2413-F92A-4774-A0E8-E931F25F12EC}" Severity="Information" Category="Printing" Response="OK">
<Text>BarTender successfully sent the print job to the spooler.
Job Name: resttest2.btw
Document: resttest2.btw
Printer: Zebra 140XiIII Plus</Text>
</Message>
</Print>
</Command>
</Response>
For those looking to check the print status, this parameter in the print tag may be the best option:
JobCompleted="true"
Or the following:
JobStatus Completed="true"
These tags confirm the print job being successfully sent to the print spooler. At this point, it has left the realm of control of the integration. The message further down in the Message tag reports this same information in a more human-readable format. If there are errors that prevent the print job from being spooled, the response will be:
%Response%
You may get a false positive (or in this case, a false negative) if the Printer Maestro service isn't running:
<Print ID="29988" GUID="{22999A4F-40C7-4F30-BB44-BED5F93691C8}" JobLastStatus="Unknown" JobCompleted="false" JobName="Label_v1.btw">
<JobStatus Completed="false">
.....
<LastStatus>Unknown</LastStatus>
<Description>Print job status is unknown because the Printer Maestro Service that is running on the computer that the printer is attached to is not responding.</Description>
</JobStatus>
While the job has successfully completed, the response says it has not simply because it isn't able to communicate with the Printer Maestro service.
Values for the response variable
- JobLastStatus: almost always "queued" to indicate the job has been spooled. If it says unknown, the Integration is unable to communicate with the Maestro Service.
- JobCompleted: will be "True" if the job has been spooled. May show false if the Maestro Service isn't communicating properly.
- Job Status Completed: confirms the job has finished
- Command Name: the name of the printing action on the Integration
Action Summary
Sample successful response formatted as JSON:
{
"Version": "1.0",
"Status": "RanToCompletion",
"WaitStatus": "Completed",
"Validated": true,
"Messages": [
{
"ActionName": "Print Document",
"Level": 2,
"Text": "BarTender successfully sent the print job to the spooler.\r\n\r\nJob Name: resttest.btw\r\nDocument: resttest.btw\r\nPrinter: Datamax I-4208"
}
]
}
Sample errored response:
{
"Version": "1.0",
"Status": "Faulted",
"WaitStatus": "Faulted",
"Validated": true,
"Messages": [
{
"ActionName": "Print Document",
"Level": 4,
"Text": "BarTender cannot use printer 'fakeprinter' to design, print, or export a template due to a printer setup problem."
}
]
}
This example response is short as this integration only has one action listed. The actions responding here are the actions listed in the integration itself:
Values for the Action Response
- Status: Values are "RanToCompletion" and "Faulted"
- WaitStatus: Values are "Completed" and "Faulted"
- ActionName: the name of the action that is printing. The Action response only reports information on print actions, even if other actions are present.
- Text: the message that you can also see in the integration messages on the Admin Console or in Integration Builder.
See Also
How to put printer data into a response for a web service integration
Web service integration response falsely reports print job as not completing
Internal notes
While the print job information seem to rely on the spooler service, it seems to get the information from the Printer Maestro service instead. If the Maestro service isn't running properly, the response may yield a false positive (or negative in this case). As there is no confirmation on exactly how the two talk to each other from dev, we simply have these symptoms to work with.
This affects the XML variables JobLastStatus and LastStatus as well as the JSON variables Status and WaitStatus
Variable response
Anything can legitimately be sent in this response. This article only goes over the BarTender-generated response. It has more useful job information until the integration fails. Then it simply sends the variable in return.
Action responses
There is 0 documentation on this response. It isn't even mentioned in the help documentation. Apparently this was added but JIRA has no confirmation as to exactly when it was added.
It is unclear as to what the difference is between Status and WaitStatus. They seem to report the same information but with different words.
The Level parameter seems to reference what position in the action list the current action is, starting at the "Action" section as value 1. So the image above, Action is value 1 and Print Document is value 2. This might be a reference to the way the integration is written and seems to be absolutely no use to the customer.