Simple webservice

Hi,

one of my customers asked for a simple webservice that is able to receive an XML file and store it in database or folder structure.
I studied one of the Youtube Xojo examples but that listens to specific call to deliver info fetched out of a database.

The things I want is:

  1. listen to a specific port
  2. if a request comes in receive the file
  3. notify the sender
  4. store the file.

How to accomplish this?
I would be happy if someone can put me in that direction.

Alexander

Check out the WebFileUploader example that comes with Xojo. It’s in the Web Examples Folder under Controls.

Thanks for your reply, but that actually has an user interface to interact with. I need a SOAP service that receives files.

Found the URLConnections in example. Not quite clear how to approach such a service though.

Aloe express can do that for you…

I looked into that. Looks promising! Is there any demo code available?

Here’s a simple demo that I put together that might help you get this project going using Aloe:
https://s3.amazonaws.com/aloe-zone/downloads/File-Receiver.xojo_binary_project.zip

Here’s an example request that you can use to test it:

[code]## POST Example Duplicate
curl -X “POST” “http://127.0.0.1:8080/” \
-H ‘Content-Type: text/plain; charset=utf-8’ \
-d $’<?xml version="1.0" encoding="UTF-8"?>

The World
Tim Dietrich
Xojo

Xojo rocks! '[/code]

The app:
• Listens on port 8080 by default. You can adjust this using the Server’s Port property (in the App.Run event handler).
• Stores the body of an HTTP POST request in the app’s directory. The files generated are named like this - 20190214-135328-127.0.0.1.xml - but you can change this to meet your requirements.
• Responds with “OK” and an HTTP status code of 200.

A couple of comments:
• You will probably want to authenticate the requests. For ideas on how to do this, see: https://forum.xojo.com/52456-aloe-express-authentication-options
• You might want to evaluate the payload to ensure that it is a well-formed XML file.
• And you might also want to look at the request “Content-Type” header to ensure that the payload is supposed to be an XML file.

Let me know if you have any questions - and best of luck with your project!

  • Tim

That is very kind of you Tim, thanks a lot. I was already setting it up and running the ‘Hello World’.

Ah, then you’re nearly finished ?

Works like a charm. It checks the readability of the data, and now I’m looking into the well-formedness of the XML file.
I noticed it is very fast. Thanks again.