by rssbus | April 20, 2018

Receive cXML Orders and Insert into a SQLite Database


Download Package

Receive cXML Orders and Insert into a SQLite Database

The sample project featured in this article has built-in templates and a script for authenticating cXML requests, extracting orders and storing them in a local SQLite database.

The cXMLMapping and SQLite ports are configured to operate automatically after a cXML request has been received by the application's API, at http://[your.domain.com]:8001/port/API/cXML.rst, where [your.domain.com] is the public domain you have configured in the AS2 Profile section from the Profile tab. The API port includes an example.xml file that can be used as the payload in a request to the application API.

In order to configure the example, please follow these steps:

  1. Go to the Ports tab and click the gear icon next to the ports list. Select Import Port Settings from the drop-down menu to extract the ports included in the cXMLreceiver.zip file.
  2. The next step is to adjust the API port to receive and authenticate cXML requests. Access the Public folder in the physical location of the API port (the default path is C:\Program Files\RSSBus\RSSBus Connect\data\API\Public) and open the cXML.rst file with a text editor. In the file, there are comments that detail what needs to be edited to with your settings.
  3. Modify the password to one you have agreed with your partner. In the sample it is 'passw0rd-here'.
  4. Next, check to make sure that the correct file destination where the cXML payload will be sent to for further processing. In the sample the destination is C:\Program Files\RSSBus\RSSBus Connect\data\cXMLMapping\Send\input.xml. Note that for this example, cXMLMapping is the name of a configured Map port.
  5. You must also modify the response you will send to your partner. The sample sends the result to http://localhost:8888, but this should be configured for your trading partner's remote IP address and port.
  6. Finally establish a connection to the SQLite database. Open the SQLite port and navigate to the Settings tab. In the sample, there is already a data source set in the Data Source field for an included sample database. The path is set to C:\Program Files\RSSBus\RSSBus Connect\data\SQLite\sample.db, but you might need to modify this path depending on where you have installed the application. Click the Test Connection button to verify that the port can access the database.

The cXMLMapping port is configured to map the incoming cXML elements with the correct database columns. The resulting orders contained in each received cXML document will be stored as a separate row in the SQLite database. You can open the SQLite database file with any SQL database viewer to check the new items.

Downloads