Internet Interface

Internet access and access to different protocols and date formats from ClassiX® can be realized with several COM objects. These are introduced as follows:

WinHTTP

Official Microsoft Documentation

The Windows WinHTTP interface provides access to the HTTP protocol. It can be used to download files from the internet (e.g. to update data) or generally to use any kind of web page. It is quite simple:

Var(winhttp)
CreateTransObject(CX_COM_OBJECT) -> winhttp
"WinHttp.WinHttpRequest.5.1" winhttp Call(CreateFromProgID)

This generates the COM object and initializes it as WinHTTP.

"GET" "http://www.classix.de" FALSE winhttp Call(Open)
winhttp Call(Send)

To open the address, it gets passed to WinHTTP. The first parameter ("GET") controls, which kind of HTTP request to use (GET or POST). After, the address follows and the last parameter specifies, whether the call should be asynchronous or not. Here, FALSE should always be passed and the synchronous call should be used. Calling 'Send', the actual request gets sent. The send method only returns in the synchronous mode, if the request result is clear. In the asynchronous case it continues straight away, meaning it is not clear, whether data is already available or not. Therefore, as described above, the synchronous mode should be used.

winhttp Call(GetStatus) "200" = if {
winhttp Call(GetResponseText)
...
}

A status query can check, whether the HTTP request had been successful. Here, the HTTP status codes, which have been specified in RFC 2616 are returned. The result can be taken back as a string and subsequently processed with the method GetResponseText.

Example

WDDX

Official documentation in the OpenWDDX.org SDK

WDDX is an XML-based data format to simplify data exchange especially between web applications. There are diverse web applications on the internet, providing a WDDX interface to provide their functionality. Requests for web application are usually sent as normal HTTP requests, and the answer will be a WDDX-coded data stream. To use such web applications in ClassiX®, the WDDX interface can be used via discretionary COM object. The actual communication on HTTP level can be done via WinHTTP interface, as described above.

Var(deserializer, response)
CreateTransObject(CX_COM_OBJECT) -> deserializer
"WDDX.Deserializer" deserializer Call(CreateFromProgID)

Here, the COM object will be generated and initialized as WDDX deserializer.

winhttp Call(GetResponseText) deserializer Call(deserialize) -> response

Here, an answer gets taken from an already processed query. Afterwards, it will be converted via WDDX interface into an answer, which is easy to process.

"date" response Call(getProp)

It is possible to access single data fields via answer object method. Their names depend on the equivalent web application and should be described in the application documentation.

Example

SMTP

Official Microsoft Documentation

SMTP (Simple Mail Transfer Protocol) is default protocol on the internet to send emails. With this protocol, the email gets passed to the internet provider SMTP server, which will send them to the receiver. SMTP can also be used out of ClassiX®. This needs to be done with an according COM object. The Microsoft Collaboration Data Objects (CDO) will be used here, which are partially elements of the operation system (for further information see Microsoft Documentation).

Var(iMsg, iConf)
DropAll

CreateTransObject(CX_COM_OBJECT) -> iMsg
"CDO.Message" iMsg Call(CreateFromProgID)

CreateTransObject(CX_COM_OBJECT) -> iConf
"CDO.Configuration" iConf Call(CreateFromProgID)

First, the message object gets generated which will later receive the email message. A configuration object will be generated additionally to configure the SMTP server.

iConf Call(GetFields) "http://schemas.microsoft.com/cdo/configuration/sendusing"
Swap Call(GetItem) 2 Swap Call(PutValue)

iConf Call(GetFields) "http://schemas.microsoft.com/cdo/configuration/smtpserver"
Swap Call(GetItem) "smtp.1und1.de" Swap Call(PutValue)

iConf Call(GetFields) "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
Swap Call(GetItem) 10 Swap Call(PutValue)

iConf Call(GetFields) Call(Update)

Now, the SMTP server and a timeout are set with the configuration object.

iConf iMsg Call(PutConfiguration)
"test@classix.de" iMsg Call(PutTo)
"max.muster@classix.de" iMsg Call(PutFrom)
"This is the subject" iMsg Call(PutSubject)
"This is the message body" iMsg Call(PutText)
iMsg Call(Send)

After the configuration has been assigned to the message, sender- and receiver address need to be defined, as well as the subject and the actual email text. After this, the email is ready for sending.