T4S4  19.1 C8540 A23673
Teamcenter Gateway for SAP S/4HANA API Reference
create CLIENT/SERVER functions

Functions

 createClient proxyname function
 This function creates a TCL function (stub) to call a TPRPC service. More...
 
 createClientA host port user pass tout prio wthid proxyname function
 This function creates a TCL function (stub) to call a TPRPC service. More...
 
 createClientFor conid tout prio wthid proxyname function
 This function creates a TCL function (stub) to call a TPRPC service. More...
 
 createServer proxyname function args
 This function creates a network service(proxy) to TCL functions. More...
 
 typeDef service type def
 This function defines complex types for SOAP(Document-Style) serives. More...
 

Detailed Description

Function Documentation

◆ createClient()

ProxyGen::createClient   proxyname function  

This function creates a TCL function (stub) to call a TPRPC service.

Parameters
proxynamethe name of the TPRPC service
functiontcl function-name (need namespace)
Returns
none

The created tcl-function has the following parameters.

Parameters
hidsession handle id (see tpco_openSrvSession2)
touttimeout in seconds
priopriority of the command (0-255)
wthidchooses the server worker ID for the command (0= all worker)
argsservice arguments
Returns
if no protocol error then the function returns the service result else "error".
1 ::ProxyGen::createClient ::T4STest::echo ::_echo
2 
3  set hd [tpco_openSrvSession2 demo.example.com 11300 0 0 SOCKET IP6]
4  if {$hd >= 0} {
5  puts [::_echo $hd 10 0 0 p1 p2 p3]
7  }
8 
9  output:
10  p1 p2 p3
1 # Client Code (please look for createServer example)
2 namespace eval ::TestClient {
3  proc testDumpArgs {} {
4  foreach item [_dumpArgs Hallo1 Hallo2 Hallo3] {
5  puts $item
6  }
7  }
8 }; ::ProxyGen::createClientFor BGS 1000 0 0 ::Test::dumpArgs ::TestClient::_dumpArgs
9 ::TestClient::testDumpArgs
10 # Client output
11 Hallo1
12 Hallo2
13 Hallo3
14 \encode

◆ createClientA()

ProxyGen::createClientA   host port user pass tout prio wthid proxyname function  

This function creates a TCL function (stub) to call a TPRPC service.

Deprecated:
Please use createClientFor instead

The created function will open and close a session for every service call (slow).

Parameters
hostthe server ip or hostname
portthe port of the server
userusername (default=0)
passpassword (default=0)
touttimeout in seconds
priopriority of the command (0-255)
wthidchooses the server worker ID for the command (0= all worker)
proxynamethe name of the TPRPC service
functiontcl function-name (need namespace)
Returns
none

The created tcl-function has these parameters.

Parameters
argsservice arguments
Returns
if no protocol error then the function resturns the service result else "error".
1 ::ProxyGen::createClientA demo.example.com 11300 0 0 10 0 0 ::T4STest::echo ::_echo
2 puts [::_echo p1 p2 p3]
3 
4 output:
5 p1 p2 p3

◆ createClientFor()

ProxyGen::createClientFor   conid tout prio wthid proxyname function  

This function creates a TCL function (stub) to call a TPRPC service.

The created function will open and close a session for every service call (slow).

Parameters
conidconnection ID/name to determine the connection settings (host, port, ...)
touttimeout in seconds
priopriority of the command (0-255)
wthidchooses the server worker ID for the command (0= all worker)
proxynamethe name of the TPRPC service
functiontcl function-name (need namespace)
Returns
none

The created tcl-function has these parameters.

Parameters
argsservice arguments
Returns
the service result or "error" in case of a protocol error
1 ::ProxyGen::createClientFor "DEFAULT" 10 0 0 ::T4STest::echo ::_echo
2 puts [::_echo p1 p2 p3]
3 
4 output:
5 p1 p2 p3

◆ createServer()

ProxyGen::createServer   proxyname function args  

This function creates a network service(proxy) to TCL functions.

createServer supports multiple network protocols:

  • TPRPC T4x own network protocol
  • PXML HTTP(s) rest-style protocol
  • SOAP Document and RPC style protocol
    Parameters
    proxynamethe service name
    functionthe full functionname (::namespace::procname)
    worker-type(optional) In the default case, all services can be executed on the internal or external worker. Use INTONLY to execute the call only on a internal worker.
    itypeonly used in code generated by wsdl2t4x for SOAP services. Do not mess with this parameter.
    partbindonly used in code generated by wsdl2t4x for SOAP services. Do not mess with this parameter.
    TPRPC service :
    Create a TPRPC service ::Test::dumpArgs and bind this to the TCL function ::TestServer::dumpArgs. Please ensure that the "Server Code" is sourced in the BGS or APPS. Please ensure that the proxy is enabled (in the Admin UI for example).
1 # Server Code
2 namespace eval ::TestServer {
3  proc dumpArgs {v1 v2 v3} {
4  puts "v1=>$v1< v2=>$v2< v3=>$v3<"
5  return [list $v1 $v2 $v3]
6  }
7 }; ::ProxyGen::createServer ::Test::dumpArgs ::TestServer::dumpArgs

PXML service :
All PXML services must be in the namespace PXML. The URL for the service is http(s)://<host>:<port>/pxml/<service-name>.

Create a PXML service ::PXML::pxmldemo and bind this to the TCL function ::T4STestHTTPD::pxmldemo.

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

Client output: webbrowser :: http://localhost:11300/pxml/pxmldemo?v1=Hello&v2=PXML&v3=Call CALLER METHODE=GET ARGS=>{v1 Hello} {v2 PXML} {v3 Call}<

SOAP service :
The optional parameter for SOAP are used for generating the WSDL. The URL for the created WSDL is http(s)://<host>:<port>/SOAP(2)/<operation-name>?wsdl. The WSDL can also be read via the Admin UI (Debug/Proxy List/SOAP).

Parameters
-description(optional) Service/Operation description (default="no description")
-host(optional) overwrite the hostname in the WSDL (default=hostname:port)
-rtypes(optional) return types (default=string)
-atypes(optional) argument types (default={})
-service(optional) name of the SOAP service (default=T4xSoap(2))
-docu(optional) documentation for the SOAP service (default="no documentaion")

The order of types in -rtype/-atype corresponds to the order of the arguments.

SOAP(Document-Style) service :
All SOAP(Document-Style) services must be in the namespace SOAP2. T4x supports the simple SOAP(Document-Style) types string, int and double. To define complex types (Record) see T4SSoap2::typeDef.

Create a SOAP service DOCMathTest with the operation ::SOAP2::testdadd and bind this to the TCL function ::T4STestSOAPServer::document_add.

1 # server code
2 namespace eval ::T4STestSOAPServer {
3  proc document_add {w1 w2} {
4  return [expr { $w1 + $w2 }]
5  }
6 }; ::ProxyGen::createServer ::SOAP2::testdadd ::T4STestSOAPServer::document_add -atypes [list double double] -rtypes [list double] -description "add two double" -service DOCMathTest
Returns
0= success

◆ typeDef()

T4SSoap2::typeDef   service type def  

This function defines complex types for SOAP(Document-Style) serives.

Parameters
servicethe name of the TPRPC service
typename of type
deftype definition {fieldname {type typename} fieldname {type typename} ...}
Returns
none

Create the complex types DOCcomplexTestIn and DOCcomplexTestOut for the service DOCcomplexTest.

1 ::T4SSoap2::typeDef DOCcomplexTest DOCcomplexTestOut [list echo [list type string] sum [list type string] cnt [list type int]]
2 ::T4SSoap2::typeDef DOCcomplexTest DOCcomplexTestIn [list name [list type string] add [list type float] cnt [list type int]]
3 
4 proc document_complex {args} {
5  return [list echo $args sum 123.456 cnt 9988]
6 }; ::ProxyGen::createServer ::SOAP2::testdcompex ::T4STestSOAPServer::document_complex -atypes [list DOCcomplexTestIn()] -rtypes [list DOCcomplexTestOut] -service DOCcomplexTest