Loading...
 

Internet

Interfaces to the Internet

Access to the Internet and its various protocols and data formats from ClassiX® can be realized with the help of some COM objects. These are briefly introduced in the following, accompanied by some examples.

  • WinHTTP - HTTP interface of Windows operating systems
  • WDDX - Interface for easy data exchange between web applications
  • SMTP - sending e-mails via the SMTP interface (without Outlook)

WinHTTP

Officials Documentation from Microsoft

The WinHTTP interface of Windows, as the name suggests, provides access to the HTTP protocol. This can be used to download any files from the internet (e.g. to update data) or generally to use any kind of website. The usage is very simple:

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

Here the COM object is created and then initialized as WinHTTP.

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

Now the address to be opened is passed to WinHTTP, the first parameter ("GET") controls which type of HTTP request (GET or POST) should be used, followed by the address and the last parameter specifies whether the call should be asynchronous. FALSE should always be passed here and thus the synchronous call should be used. With the call of Send the actual request is then sent. In synchronous mode, the Send method does not return until the result of the request has been determined. In the asynchronous case, the process continues immediately, that is, you cannot be sure whether data is already available or not. Therefore, as described above, you should use synchronous mode.

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

A status query can now be used to check whether the HTTP request was successful. The HTTP status codes specified in RFC 2616 are returned here. You can then use the method GetResponseText to get the result as a string and process it further.

Examples

WDDX

Official documentation can be found in the SDK of OpenWDDX.org

WDDX is an XML-based data format to simplify the data exchange especially between web applications. There are various web applications on the Internet that offer a WDDX interface to make their functionality available. Requests to the web application are usually sent as normal HTTP requests and the response is then sent as a WDDX-encoded data stream. To use such web applications from within ClassiX®, the WDDX interface can be used via a freely available COM object. The actual communication on HTTP level can be done with the WinHTTP interface described above.

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

Here the COM object is created and then initialized as a WDDX deserializer.

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

Here the answer is fetched from an already existing query via WinHTTP and then converted into an easily processable answer with the help of the WDDX interface.

"date" response Call(getProp)

A method of the response object can then be used to access the individual data fields. The names of the data fields depend on the Web application and should be described in the documentation of the application.

Examples