T4S4  18.1 C7177 A20283
Teamcenter Gateway for SAP S/4HANA API Reference
HTML and XML utility functions

Functions

 baseHttpUrlForConnection connectionID
 Returns an base HTTP URL for a certain connection. More...
 
 connectTo channelID urlSuffix args
 HTTP client call to a URL defined by a communication channel. More...
 
 createBinaryHeader date lastmod contype conlen cdis_fname cencoding
 This function creates a http header for binary data. More...
 
 createFileLinkHeader date lastmod contype conlen cdis_fname cencoding
 This function creates a http header for binary data. More...
 
 createGenericHeader date lastmod contype conlen cdis_fname cencoding statusCode statusMessage args
 This function creates a generic http header. More...
 
 createHeader date lastmod contype conlen cdis_fname cencoding
 This function creates a http header. More...
 
 createWSockRes type data
 This function creates a websocket protocol response. More...
 
 httpdDate seconds
 create a http date string More...
 
 httpdDecodeCGI string
 decode a string to the URL-encoding More...
 
 httpdEncodeCGI string
 encode a string from the URL-encoding More...
 
 httpdSplitQueryString query
 split a http query string to a tcl-list More...
 
 httpdStatusMessage statusCode
 retrieves the HTTP status message given a HTTP status code More...
 
 setAttaLink link dname
 This function create a attachment link for a logfile. More...
 
 tcl2html data
 convert tcl-script code to HTML More...
 
 XMLAppendB64Arg tag value args
 This function create a B64 text tag. More...
 
 XMLAppendCLNArg tag value args
 This function create a clear text tag. More...
 
 XMLResFooter args
 This function create a default XML footer. More...
 
 XMLResHeader args
 This function create a default XML header. More...
 

Detailed Description

Function Documentation

◆ baseHttpUrlForConnection()

TPHAP::baseHttpUrlForConnection   connectionID  

Returns an base HTTP URL for a certain connection.

Parameters
connectionIDid of the connection to get a base URL for
Returns
base HTTP URL

Returns an URL in the format of <protocol>://<host>:<port> for the given connection ID. Throws an exception if the transport of the connection is not set to HTTP or HTTPS.

1 set BGS_baseURL [::TPHAP::baseHttpUrlForConnection "BGS_WEB"]
2 puts "Base HTTP URL for BGS is: $BGS_baseURL"
3 output:
4 Base HTTP URL for BGS is: http://localhost:11300

Referenced by TPHAP::connectTo().

◆ connectTo()

TPHAP::connectTo   channelID urlSuffix args  

HTTP client call to a URL defined by a communication channel.

Parameters
channelIDid of the communication channel to get the base URL and further connection information (e.g. certificates) from
urlSuffixremaining URL information that will be attached to the determined base URL
-user(optional) username for authentication
-password(optional) password for authentication
-agent(optional) change the client agent name
-extendHeaderBy(optional) extend header by further data passed as name value list
-connectionTimeoutInSec(optional) client connection timeout in seconds
-timeoutInSec(optional) request timeout in seconds
-httpMethod(optional) HTTP method do be used: POST, PUT, DELETE or GET (default). POST and PUT require the -payload parameter additionally.
-payload(required for POST and PUT HTTP method) Payload to be passed via POST or PUT HTTP method.
-hexEncoded(optional) true to return the result hex encoded.
-includeHeader(optional) true to include the HTTP response header in the result as [list <payload> <http-header>]
Returns
result of the http(s) service or an exception

This function can be used to call a URL from PL4x (also see tpco_httpClient) where the configuration has already been provided in the communication channels settings. After determining the needed configuration (e.g. certificates) and the base URL, the urlSuffix is added and the resulting URL called. The function returns the result of the webservice or an exception.

1 set result [::TPHAP::connectTo DEFAULT_WEB /pxml/perfticker -user t4adm -password geheim -httpMethod GET -includeHeader true]
2 puts $val
3 
4 output:
5 {<?xml version="1.0"?>
6 <arguments>
7 <srvstat>
8 <cpuusage>100</cpuusage>
9 <queuesz>0</queuesz>
10 ...
11 </srvstat>
12 </arguments>
13 } {HTTP/1.1 200 OK
14 Server: T4x_11.4
15 Date: Wed, 07 Mar 2018 15:31:31 GMT
16 Last-Modified: Wed, 07 Mar 2018 15:31:30 GMT
17 Content-Type: text/xml
18 Content-Length: 762
19 Keep-Alive: timeout=15, max=100
20 Connection: Keep-Alive
21 Cache-Control: no-cache
22 }

References TPHAP::baseHttpUrlForConnection(), and tpco_httpClient().

◆ createBinaryHeader()

TPHAP::createBinaryHeader   date lastmod contype conlen cdis_fname cencoding  

This function creates a http header for binary data.

Parameters
date: Date attribute (default= "" <- internal fill)
lastmod: Last-Modified attribute (default= "" <- internal fill)
contype: Content-Type attribute (default= "" <- text/html; charset=utf-8)
conlen: Connection attribute, content size in byte (default= "" <- close)
cdis_fname: filename for download (default= "" <- internal fill)
cencoding: Content-Transfer-Encoding attribute (default= "" <- not set)
Returns
the http header string

References TPHAP::createHeader(), and tpco_scanHEX16().

◆ createFileLinkHeader()

TPHAP::createFileLinkHeader   date lastmod contype conlen cdis_fname cencoding  

This function creates a http header for binary data.

Parameters
date: Date attribute (default= "" <- internal fill)
lastmod: Last-Modified attribute (default= "" <- internal fill)
contype: Content-Type attribute (default= "" <- text/html; charset=utf-8)
conlen: Connection attribute, content size in byte (default= "" <- close)
cdis_fname: filename for download (default= "" <- internal fill)
cencoding: Content-Transfer-Encoding attribute (default= "" <- not set)
Returns
the http header string

References TPHAP::createHeader(), and tpco_scanHEX16().

◆ createGenericHeader()

TPHAP::createGenericHeader   date lastmod contype conlen cdis_fname cencoding statusCode statusMessage args  

This function creates a generic http header.

Parameters
date: Date attribute (default= "" <- internal fill)
lastmod: Last-Modified attribute (default= "" <- internal fill)
contype: Content-Type attribute (default= "" <- text/html; charset=utf-8)
conlen: Connection attribute, content size in byte (default= "" <- close)
cdis_fname: filename for download (default= "" <- internal fill)
cencoding: Content-Transfer-Encoding attribute (default= "" <- not set)
statusCode: the http status code
statusMessage: the http status message
args: additional http headers
Returns
the http header string

Common use in a PXML call.

1 puts [::TPHAP::createGenericHeader "" "" "" 1234 "" "" 200 OK]
2 
3 output:
4 HTTP/1.1 200 OK
5 Server: T4x_100
6 Date: Wed, 18 Jul 2012 13:09:05 GMT
7 Last-Modified: Wed, 18 Jul 2012 13:09:04 GMT
8 Content-Type: text/html; charset=utf-8
9 Content-Length: 1234
10 Keep-Alive: timeout=15, max=100
11 Connection: Keep-Alive
12 Cache-Control: no-cache

References TPHAP::httpdDate(), and TPHAP::httpdStatusMessage().

◆ createHeader()

TPHAP::createHeader   date lastmod contype conlen cdis_fname cencoding  

This function creates a http header.

Parameters
date: Date attribute (default= "" <- internal fill)
lastmod: Last-Modified attribute (default= "" <- internal fill)
contype: Content-Type attribute (default= "" <- text/html; charset=utf-8)
conlen: Connection attribute, content size in byte (default= "" <- close)
cdis_fname: filename for download (default= "" <- internal fill)
cencoding: Content-Transfer-Encoding attribute (default= "" <- not set)
Returns
the http header string

Common use in a PXML call.

1 proc pxmldemo {args} {
2  set ret "CALLER METHODE=[::SYSUtils::getCallerMethode] ARGS=>$args<"
3  return [::TPHAP::createHeader "" "" "" [string bytelength $ret] "" ""]$ret
4 }; ::ProxyGen::createServer ::PXML::pxmldemo ::T4STestHTTPD::pxmldemo

References TPHAP::httpdDate().

Referenced by TPHAP::createBinaryHeader(), TPHAP::createFileLinkHeader(), BatchSWA::WASDisableJobServerBackend(), BatchSWA::WASDisableJobServerFrontend(), BatchSWA::WASEnableJobServerBackend(), BatchSWA::WASEnableJobServerFrontend(), BatchSWA::WASGetJobServerBackendStatus(), and BatchSWA::WASGetJobServerFrontendStatus().

◆ createWSockRes()

TPHAP::createWSockRes   type data  

This function creates a websocket protocol response.

Parameters
type: BIN or TXT
data: the message data
Returns
the server call result string

References tpco_scanHEX16().

◆ httpdDate()

TPHAP::httpdDate   seconds  

create a http date string

Parameters
seconds:: c-time
Returns
http data string

Referenced by TPHAP::createGenericHeader(), and TPHAP::createHeader().

◆ httpdDecodeCGI()

TPHAP::httpdDecodeCGI   string  

decode a string to the URL-encoding

Parameters
string
Returns
the string in URL-encoding

◆ httpdEncodeCGI()

TPHAP::httpdEncodeCGI   string  

encode a string from the URL-encoding

Parameters
string
Returns
the clear string

Referenced by TPHAP::httpdSplitQueryString().

◆ httpdSplitQueryString()

TPHAP::httpdSplitQueryString   query  

split a http query string to a tcl-list

Parameters
query:: the http query string
Returns
tcl list

References TPHAP::httpdEncodeCGI().

◆ httpdStatusMessage()

TPHAP::httpdStatusMessage   statusCode  

retrieves the HTTP status message given a HTTP status code

Parameters
statusCode: the http status code
Returns
the http status message

Referenced by TPHAP::createGenericHeader().

◆ setAttaLink()

TPHAP::setAttaLink   link dname  

This function create a attachment link for a logfile.

Parameters
linkthe link-ID of the attachment (see tpco_udpWriteRemoteAttachment2)
dnamelink name (description)
Returns
logfile link

create a smal XML document with a text tag.

1 set atl [::TPHAP::setAttaLink 50055CEF0000236D "My Attachment Link"]
2 puts $atl
3 output:
4 !#!50055CEF0000236D/4d7920417474617863686d656e74204c696e6b!%!
5 
6 # write the link into a logfile
7 tpwrite "My test-link :: $atl"

Referenced by T4X::CORE::writeLogLineWithAttachment2BGS().

◆ tcl2html()

TPHAP::tcl2html   data  

convert tcl-script code to HTML

Parameters
data: the tcl code string
Returns
the html code

◆ XMLAppendB64Arg()

TPHAP::XMLAppendB64Arg   tag value args  

This function create a B64 text tag.

Returns
XML B64 text tag

create a smal XML document with a B64 tag.

1 append xmldoc [::TPHAP::XMLResHeader]
2 append xmldoc [::TPHAP::XMLAppendB64Arg test 0123456789]
3 append xmldoc [::TPHAP::XMLResFooter]
4 puts $xmldoc
5 
6 output:
7 <?xml version="1.0"?>
8 <arguments>
9 <test>MDEyMzQ1Njc4OQ==</test>
10 </arguments>

◆ XMLAppendCLNArg()

TPHAP::XMLAppendCLNArg   tag value args  

This function create a clear text tag.

Returns
XML clear text tag

create a smal XML document with a text tag.

1 append xmldoc [::TPHAP::XMLResHeader]
2 append xmldoc [::TPHAP::XMLAppendCLNArg test 0123456789]
3 append xmldoc [::TPHAP::XMLResFooter]
4 puts $xmldoc
5 
6 output:
7 <?xml version="1.0"?>
8 <arguments>
9 <test>0123456789</test>
10 </arguments>

◆ XMLResFooter()

TPHAP::XMLResFooter   args  

This function create a default XML footer.

Returns
XML footer

◆ XMLResHeader()

TPHAP::XMLResHeader   args  

This function create a default XML header.

Returns
XML start header

create a smal XML document

1 append xmldoc [::TPHAP::XMLResHeader]
2 append xmldoc <test>xyz</test>\n
3 append xmldoc [::TPHAP::XMLResFooter]
4 puts $xmldoc
5 
6 output:
7 <?xml version="1.0"?>
8 <arguments>
9 <test>xyz</test>
10 </arguments>