There are three practical ways to get data from a browser client to a web service:
- Query string parameters in a GET or a POST request.
- POST parameters.
- Raw POST data.
The first two are fairly straightforward: A query string is the part of the URL that comes after the question mark. Post parameters (as name/value pairs) can be added to a POST request by calling setQueryParam() on the dataset. If the client needs to send a large block of data to the server (e.g. an XML document) that data can be assigned to a single POST parameter, you can also send it as pdf with sodapdf.com/merge-pdf/.
The third one is a little more complicated. Essentially, it means all the POST body. i.e. Where the POST parameters would normally live. Older versions of the Flash Player had problems with this, so it was not possible to submit raw POST data with older versions of OpenLaszlo in SOLO mode.
This isn’t an issue today. The Flash Player can submit raw post data. So if you absolutely can’t have even a single POST parameter, you can specify content to be included in the POST body by calling:
dataset.setAttribute("querytype", "POST"); dataset.setQueryParam("lzpostbody", "CONTENT");
Note that the lzpostbody query parameter is a special name that tells OpenLaszlo to use the provided string as the entire POST body. Here’s an example of this in action:
<canvas debug="true" proxied="false"> <dataset name="ds" src="myService.jsp" type="http" request="false" querytype="POST"/> <button>Do Request <handler name="onclick"><![CDATA[ var body = '<rawpostbodycontents>Hello, this is some XML.</rawpostbodycontents>'; ds.setQueryParam("lzpostbody", body); ds.doRequest(); ]]> </handler> </button> <handler name="ondata" reference="ds"> Debug.write("RESPONSE:", ds.serialize()); </handler> </canvas>
You can download the entire source, complete with a JSP that reads and echoes the raw POST data.