Epson TM-U220 ePOS-Print XML Users Manual - Page 221
To Call SOAP/HTTP Interface, Development Information for Customer Displays
View all Epson TM-U220 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 221 highlights
Chapter 6 Development Information for Customer Displays To Call SOAP/HTTP Interface Refer to the following program. TITLE function sendDocument() { // Create a display document var request = ''; request += ''; request += ''; request += 'Thanks for coming!'; request += ''; // Create display parameters var param = ''; param += 'local_display'; param += '10000'; param += 'ABC123'; param += ''; // Create a SOAP envelop var soap = '' + '' + param + ' + '' + request + ''; // Create an XMLHttpRequest object var xhr = new XMLHttpRequest(); // Set the end point address var url = 'http://192.168.192.168/cgi-bin/eposDisp/ service.cgi?devid=local_display&timeout=10000'; // Open an XMLHttpRequest object xhr.open('POST', url, true); // xhr.setRequestHeader('Content-Type', 'text/xml; charset=utf-8'); xhr.setRequestHeader('If-Modified-Since', 'Thu, 01 Jan 1970 00:00:00 GMT'); xhr.setRequestHeader('SOAPAction', '""'); //Set a callback function xhr.onreadystatechange = function () { if (xhr.readyState == 4) { if (xhr.status == 200) { //Obtain the response root element var res = xhr.responseXML; var success = res.getElementsByTagName('response')[0].getAttribute('success'); //When the displaying is not successful, display a message if (!/^(1|true)$/.test(success)) { alert('A display error occurred'); } } } } // Send display document xhr.send(soap); } 221