I'm trying to use the HTTP POST trigger documented in Chapter 10 to send data contained in an XML template associated with the trigger. It is a Login request. The remote service (controlled by a third party) only responds to Transfer-Encoding: chunked requests.
Although the request I'm sending is only one chunk, the remote side does not seem to respond when the Content-Length header is supplied to indicate the size of the request body. It seems to need the value (in hexadecimal) prepended to the XML template, and terminated with a null character (0). When this is done manually (and specify the HTTP Header "Transfer-Encoding: chunked") the request goes through ok.
Posted by Admin on 22-Mar-2012 12:43
The main problem I am having is that the merge tokens in the XML template will cause the size to be adjusted with each different SOAP Login request to the 3rd party service. I will not be able to specify an optimal value for the chunk size after the merge tokens have been substituted. I don't think I have a way to do that at the moment.
Posted by Admin on 22-Mar-2012 21:01
Try this: Create a formula field on the same object, return type int; input your XML code in a variable, var xmlCode = "xml template"... dont forget to escape chars if needed, or convert double quotes (") to single quotes (') so that it's a valid Js string.
The XML code inside should also include your merge tokens so you can compute the length dynamically.
Then return the length as an int return xmlCode.length; on your formula field.
Then you can manipulate to return the Hex value.
Hope this helps,
Posted by Admin on 22-Mar-2012 21:57
I'll add "chunked transfer" option in the next release (this weekend).
Posted by Admin on 23-Mar-2012 11:43
This is such a creative solution! Thanks for your input! :)