IMPORT com
IMPORT xml
MAIN
DEFINE req com.HTTPRequest
DEFINE resp com.HTTPResponse
DEFINE writer xml.StaxWriter
TRY
LET req = com.HTTPRequest.Create("http://localhost:8090/MyXmlProcess")
CALL req.setMethod("PUT") # Perform an HTTP PUT method
CALL req.setHeader("MyHeader","Value of my header")
# Retrieve an xml.StaxWriter to start xml streaming
LET writer = req.beginXmlRequest()
CALL writer.startDocument("utf-8","1.0",true)
CALL writer.comment("My first XML document sent in streaming with genero")
CALL writer.startElement("root")
CALL writer.attribute("attr1","value1")
CALL writer.endElement()
CALL writer.endDocument()
CALL req.endXmlRequest(writer) # End streaming request
LET resp = req.getResponse()
IF resp.getStatusCode() != 201 OR resp.getStatusCode() != 204 THEN
DISPLAY "HTTP Error ("||resp.getStatusCode()||") ",
resp.getStatusDescription()
ELSE
DISPLAY "XML document was correctly put on the server"
END IF
CATCH
DISPLAY "ERROR :",STATUS||" ("||SQLCA.SQLERRM||")"
END TRY
END MAIN