Retail:How to use the Hardware Manager proxy
Introduction
New functionality developed in Web POS, like payment gateways, may require access external web services. These external services can be unreachable from Web POS because internal network policies or because the external service is not adapted to be invoked from a web browser due to the Same-origin policy implemented in web browsers.
To workaround this situation, the Hardware Manager provides proxy capabilities that allow to route invocations to external web services coming from Web POS.
Service description
The hardware manager proxy is located in the url http://<host-name>:<host-port>/httpproxy assuming the hardware manager is running in <host-name> and listening the port <host-port>.
To invoke the proxy functionality from the web browser an HTTP POST request must be executed with the following content in JSON format:
{ url: "<external-webservice-url>", method: "<external-webservice-method>", // GET or POST (default) contenttype: "<external-webservice-contenttype>", content: "<external-webservice-content>" }
Or if you want to set an arbitrary list of headers in a POST or in a GET request you can use.
![]() | This feature is available starting from 3.0RR19Q4. |
![]() | This feature is available for GET requests starting from 3.0RR23Q1. |
{ url: "<external-webservice-url>", method: "<external-webservice-method>", //GET or POST (default) headers: { header1: "header1-value", header2: "header2-value" }, content: "<external-webservice-content>" }
The response received by the Web POS has the following JSON format:
{ contenttype: "<external-webservice-response-cont" content: "<?xml version="1.0" encoding="utf-8"?> <string xmlns="http://www.w3schools.com/webservices/">212</string> " }
The response can also be received in JSONP format if you add the parameter callback=yourcallback to the Hardware Manager URL. In this case the response has the following format:
yourcallback({ contenttype: "<external-webservice-response-cont" content: "<?xml version="1.0" encoding="utf-8"?> <string xmlns="http://www.w3schools.com/webservices/">212</string> " });
Example
Asuming the Hardware Manager is runing in the same machine as the web browser (localhost) and listening to the port 8090 that is the default port. the HTTP POST request to the URL http://localhost:8090/httpproxy?callback=mycallback with the following content:
{ url: "http://www.w3schools.com/webservices/tempconvert.asmx/CelsiusToFahrenheit", method: "POST", contenttype: "application/x-www-form-urlencoded", content: "Celsius=100" }
Will return the following response
mycallback({ contenttype: "text/xml; charset=utf-8" content: "<?xml version="1.0" encoding="utf-8"?> <string xmlns="http://www.w3schools.com/webservices/">212</string> " });