Table of Contents

HttpClientAbstract

Namespace
ZAux
Implements

Used to send HTTP requests and receiving HTTP responses from a resource identified by a URI.

Note

The TwinCAT implementation of HttpClient, additionally to Zeugwerk Framework, requires an installation of Zeugwerk HttpClientProxy on a computer in your local network and an ADS route to this server. For questions, contact the support.

FUNCTION_BLOCK ABSTRACT HttpClientAbstract IMPLEMENTS ZCore.IHttpClient, ZCore.IObject, ZCore.IError

Properties

Busy

This property returns TRUE if the object is Busy executing a sequence or still in its initialization phase (if applicable). It returns FALSE if the object is Idle or in an Error state.

Use State to find out if the object is busy executing its initialization phase, or it is busy performing an actual sequence.

PROPERTY Busy : BOOL

Property Value

BOOL

Done

If the object is in idle state (often mentioned as "the object is not busy and not on error"), this is indicated by this property returning TRUE.

PROPERTY Done : BOOL

Property Value

BOOL

StatusCode

This property returns the statuscode of a server's response. The value is only valid if Busy=FALSE.

PROPERTY StatusCode : ZCore.HttpClientStatusCode

Property Value

HttpClientStatusCode

Methods

GetAsync

Send a GET request to the specified Uri as an asynchronous operation. Use Busy property and its derivatives to retrieve the status of the asynchronous operation. As soon as Busy=FALSE the StatusCode method can be used to check if the request was successful (StatusCode=200) or not. The response of the GET request is written to the responseBuffer, which is passed as a parameter to this method. Make sure that the buffer size is big enough for the response, which is returned by the server.

METHOD GetAsync (
 startToken : ZCore.IStartToken,
 uri : STRING(ZCore.ParameterList.MaxHttpClientUriLength),
 responseBuffer : ZCore.ZPointer,
 responseSize : UDINT)

Inputs

startToken IStartToken

uri STRING(ZCore.ParameterList.MaxHttpClientUriLength)

responseBuffer ZPointer

responseSize UDINT

PostAsync

Send a POST request to the specified Uri as an asynchronous operation. Use Busy property and its derivatives to retrieve the status of the asynchronous operation. As soon as Busy=FALSE the StatusCode method can be used to check if the request was successful (StatusCode=200) or not. The payload that should be send to the server is is passed as a parameter to this method.

METHOD PostAsync (
 startToken : ZCore.IStartToken,
 uri : STRING(ZCore.ParameterList.MaxHttpClientUriLength),
 payloadBuffer : ZCore.ZPointer,
 payloadSize : UDINT)

Inputs

startToken IStartToken

uri STRING(ZCore.ParameterList.MaxHttpClientUriLength)

payloadBuffer ZPointer

payloadSize UDINT

SetHttpClientProxy

This method is used to set a server, which acts as a proxy for the PLC. Refer to the implementation to get more details about this.

METHOD SetHttpClientProxy (
 on : BOOL,
 target : STRING)

Inputs

on BOOL

Use proxy (on:=TRUE) or try to use native mode (on:=FALSE)

target STRING

TraceErrorStack

This method is used internally when recording an error trace.

METHOD TraceErrorStack (
 trace : ZCore.IErrorTrace)

Inputs

trace IErrorTrace