Client Workspace Code
The Smalltalk expression below uses the Web Services framework. The Insurance Policy web service is deployed into a container. The container can be re-used but the sample creates a new one for each invocation of the web service in order to minimize the objects in the framework.
[
| op aContainer aServiceCollection aService aPolicy |
 
SstWSContainer clearAll.
aContainer := SstWSContainer createContainerNamed: 'ClientContainer'
using: (SstWSContainerConfiguration defaultConfiguration).
aContainer startUp.
 
aServiceCollection := aContainer deploy:
(AbtXmlConfiguration current defaultResourceQualifier),
'SstWSInsurancePolicyClientInterface.xml'.
aService := aServiceCollection first.
 
"the 'about' operation for doc-literal contains one nillable argument to conform with convention. "
" (aService about: nil) inspect. "
"the operation for rpc is
aService about inspect.
(aService invoke: 'about' withArguments: #( )) inspect."
 
" (aService ratePolicy: '29467810') inspect."
" (aService invoke: 'ratePolicy' withArguments: #( '29467810' )) inspect."
 
"the 'getallPolicies' operation for doc-literal contains one nillable argument to conform with convention. "
" (aService getAllPolicies: nil) inspect. "
"the operation for rpc is
aService getAllPolicies inspect. "
" (aService invoke: 'getAllPolicies' withArguments: #( )) inspect."
 
" (aService getInfoForPolicy:'29467810') inspect.
(aService invoke: 'getInfoForPolicy' withArguments: #( '29467810' )) inspect."
 
"
aPolicy := (aService getInfoForPolicy:'29467810').
aPolicy owner name: aPolicy owner name, 'Else'.
(aService invoke: 'updatePolicy' withArguments: (Array with: aPolicy)) inspect.
(aService invoke: 'getInfoForPolicy' withArguments: #( '29467810' )) inspect."
 
aService inspect.
] fork.
 
The container name used is not significant and can be any name. If the web service is invoked correctly, an inspector should open with a floating point result. The result value will vary as the ratePolicy: method uses a random number to generate its result. The code shows two ways to invoke the web service. The expression (aService ratePolicy: '29467810') inspect delivers the same result. However (aService invoke: 'ratePolicy' withArguments: #( '29467810' )) guarantees that the remote path will be taken. If SstWSInsurancePolicyInterface is present in the client image, (aService ratePolicy: '29467810') inspect may result in a Smalltalk method call if the deployment descriptor file was not edited correctly.
Last modified date: 08/16/2019