XML-RPC, Basics

XML-RPC (Extensible Markup Language Remote Procedure Call) allows software on different operating systems to make procedure calls over the internet. XML-RPC uses HTTP for the transport and XML for the encoding. It sends the procedure call to a remote server through HTTP. The call is an XML document and it receives the response as XML.

XML-RPC is a protocol for web services, similar to SOAP but much simpler. It is easy to use and fast. You can easily transmit and return data structures. See http://www.xmlrpc.org.

The WinCC OA CtrlXmlRpc is a CONTROL extension including XML-RPC functions. Therefore, you have to load the CONTROL extension in your code or load it in the config.level file (see chapter To load CONTROL library).

In order to run an XML-RPC server, you have to start the HTTP server and install a handler. The default URL for XML-RPC is "/RPC2". See chapters xmlrpcHandler() and httpConnect().

Furthermore, you have to start the client and establish a connection to the server (see the functions at the end of this chapter). XML-RPC clients support authentication via Basic or Negotiate, if required by the server. User name and Password for "Basic" authentication are either given in the host parameter (e.g. "root:@localhost" or "http://root:@localhost") or are retrieved from the config file entries "userName" and "password". You can also build a secure HTTPS connection to the server. Under Windows the OpenSSL installation is required for the HTTPS connection. OpenSSL is an open source implementation of the SSL and TLS protocols and implements cryptographic functions. See http://www.openssl.org/source/.

The transfer can also be compressed by using the WinCC OA gzip functions. To use the gzip functions, you have to load the CtrlZlib. It is a shared library with functions for data compression. It is based on libz (gzip, gunzip).

Several standard XML-RPC methods are additionally available in the xmlrpcHandlerCommon.ctl located in wincc_oa_path/scripts/libs. Using these methods you can query data points etc. in the XML-RPC handler (see the figures below).

Figure 1. XML-RPC overview
Figure 2. XML-RPC transfer (detailed)

For more information on the individual XML-RPC functions, see the specific chapters:

xmlrpcHandler()

xmlrpcConnectToServer()

xmlrpcClient()

xmlrpcCall()

xmlrpcDecodeRequest()

xmlrpcEncodeResponse()

xmlrpcCloseServer()

xmlrpcEncodeValue()

xmlrpcDecodeValue()

xmlrpcSetGzipLimit()

For more information on the individual zip functions for compression, see the specific chapters:

gzip()

gunzip()

gzread()

gzwrite()