All,
I’m working on a Flash application that’s supposed to send XML data to a Java Servlet.
I’m responsible for the Flash app; another team is responsible for the Java Servlet.
The problem we’re having is that I’m familiar with Flash but not Java and Servlets; the other team is expert in Java and Servlets, but unfamiliar with Flash.
Anyway, I have some AS2 code that uses sendAndLoad() to send XML data to a server.
It works great when I send it to PHP, or ASP, or ASP.net (stuff I’m familiar with).
However, the Java team is having trouble receiving the information with their servlet.
One of the developers sent me a log entry:
GET /portal/delegate/ParticipantService?svc=someServiceName&XMLStr=[the encoded xml I sent]
As I understand it, xml.sendAndLoad uses POST, not GET, so I don’t understand why this shows up in the log as a GET. Any ideas or explanation?
Also, any suggestions about what to tell the developers about how to receive the XML?
Obviously, it’s possible that the issue is with my Actionscript code, but as I said, it works if I send it to a PHP page, where I pick it up with something like this:
$doc = new DomDocument();
$doc->loadXML(file_get_contents("php://input"));
UPDATE:
Here’s what an Adobe Technote says about this:
When loadVariables or getURL actions are
used to send data to Java servlets it
can appear that the data is being sent
using a GET request, when the POST
method was specified in the Flash
movie.This happens because Flash sends the
data in a GET/POST hybrid format. If
the data were being sent using a GET
request, the variables would appear in
a query string appended to the end of
the URL. Flash uses a GET server
request, but the Name/Value pairs
containing the variables are sent in a
second transmission using POST.
Although this causes the servlet to
trigger the doGet() method, the
variables are still available in the
server request.
So, I guess what I need to know is how to tell the Java team to look for and capture the XML that’s been sent…
Many thanks in advance!
Flash is doing something really weird. It may not be illegal but it’s very unconventional. Servlet doesn’t expect this for sure. It includes a message body in GET request. Basically, it’s doing a POST with GET. Servlet ignores message body for GET.
To handle this, Java servlet has to process the message body. It’s not hard to do. Just read the InputStream and convert it into a string. It’s in x-www-urlencoded format.
Here is the code I use to parse it,
mapcontains the parameters included in the message body.