Table of Contents
This is the second of two articles that show a method to automate Joomla tasks or applications based on it.
In the first article, I show the server part, a Joomla component that can handle XML message.
For this article, I implemented few VB.NET classes that help you work with the component. These classes allow you to prepare SQL statements with a “Joomla dbo” style, send them and manage the response.
The jsxHelper
class is the main helper class used to send messages.
It has two properties, security_token
and endpoint
, that must be initialized with the parameters of your server, and one function SendMessage()
that takes a jsxRequest
object as input parameter and returns a jsxResponse
object.
Once installed, the SqlXML
Component shows an administrative page, under the menu “Components”.
This panel shows the security token and the endpoint to set the jsxHelper
fields:
The jsxRequest
class is the root message container; during XML serialization, it represents the <msg-req>
tag. It is only a container.
The jsxResponse
represents the root object of the response message, the tag <msg-response>
.
Both jsxRequest
jsxResponse
have a commands
array field that contains one or more jsxCommand
.
The code provided with this article is a Console project written in VB.NET that define the helper classes.
The project shows how to use the helper classes sending different SQL commands.
It executes DDL statements that create and delete a temporary table in the underlying database, and shows how to insert
, update
and select
some rows showing the use of DML statements.
An interesting class is the jsxSQLCommandBuilder
, that is a helper class that builds SQL query with a “joomla dbo” style:
req = New jsxRequest
Dim cmd As jsxCommand
Dim bld As New jsxSQLCommandBuilder
bld.Action = jsxCommandActionEnum.update
bld.Save = "updated"
bld.Table = "#__sqlxml_demo"
bld.Fields("name") = "Test_Changed"
bld.Where("id", ">") = 5
req.Commands.Add(bld.BuildCommand)
resp = jsxHelper.SendMessage(req)
This project shows you a VB.NET client that can quickly connect to the Joomla SqlXML component published in the first article.
Then, you can automate your Joomla tasks from VB.NET program, taking advantage of transaction management.