Hi there

I need to send some XML data to a server and I've been given the following specifications.

Server: http://myserver.com/parseXML.jsp
Request method: POST
Form request data name: xmldata

The XML structure is quite simple:

<XML>
<RECEIVE_RESPONSE user=12345678>
<SMS_RECEIVE uid=”1” to=”+275550000001” type=”6”/>
<SMS_RECEIVE uid=”2” to=”+275550000002” type=”1”>thanks for the
message</SMS_RECEIVE>
</RECEIVE_RESPONSE>
</XML>

I'm assuming that xmldata is just the name of the form, but my question is, how do I include XML into a normal HTML form? Or do I submit an XML form? How would I do that?

Help much appreciated

H

    You really need a proper spec, rather than the above.

    It's fairly likely that this is a form-encoded HTTP POST. You need to package the XML file into a string, then encode it appropriately to make a HTTP POST. For example, that might look like something like:

    xmldata=your XML file, url encoded as necessary
    

    Assuming they are actually expecting a form-encoded POST.

    Then you make the HTTP post from your server to theirs, making sure you send the appropriate headers (e.g. content-length, content-type). This can be done using fopen by creating a stream context (for instance).

    Note that the above does not look like a valid XML file - because it uses the wrong type of quotes.

    Check your XML file using a tool like xmllint.

    Be mindful of the encoding that the XML file is using.

    Mark

      Write a Reply...