T4S4  18.2 C7549 A21431
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

◆ 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 ::T4STest::echo and bind this to the TCL function ::T4STestTPRCP::echo.
1 # Server Code
2 proc ::T4STestTPRCP::dumpArgs {v1 v2 v3} {
3  puts "v1=$v1 v2=$v2 v3=$v3"
4  return [list $v1 $v2 $v3]
5 }; ::ProxyGen::createServer ::T4STest::exampleTPRPC ::T4STestTPRCP::dumpArgs
6 
7 # Client Code
8 ProxyGen::createClientFor "BGS" 10 0 0 ::T4STest::exampleTPRPC ::extprpc
9 puts [::extprpc Hello TPRPC Call]
10 
11 # server output:
12 v1=Hello v2=TPRPC v3=Call
13 
14 # client output:
15 Hello TPRPC Call

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  proc pxmldemo {args} {
3  set ret "CALLER METHODE=[::SYSUtils::getCallerMethode] ARGS=>$args<"
4  return [::TPHAP::createHeader "" "" "" [string bytelength $ret] "" ""]$ret
5  }; ::ProxyGen::createServer ::PXML::pxmldemo ::T4STestHTTPD::pxmldemo
6 
7 # client output:
8 # webbrowser :: http://demo.example.com:11300/pxml/pxmldemo?v1=Hello&v2=PXML&v3=Call
9 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. To define an array that can be appended to the type ().

1 # defines a string array and a int type
2 -atypes [list "string()" int]

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

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

SOAP(RPC-Style) service :
All SOAP(RPC-Style) services must be in the namespace SOAP. T4x supports the simple SOAP(RPC-Style) types string, int and double.

Create a SOAP service RPCMathTest with the operation ::SOAP::test_rpcadd and bind this to the TCL function ::T4STestSOAPServer::rpc_add.

1 # server code
2 proc rpc_add {w1 w2} {
3  return [expr $w1 + $w2]
4 }; ::ProxyGen::createServer ::SOAP::test_rpcadd ::T4STestSOAPServer::rpc_add -atypes [list double double] -description "add two double" -service RPCMathTest
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