" ---------------------------------------------------------------------------------------
The files in this directory are as follows:

	SstWSInsurancePolicyInterface-interface.wsdl  - The interface WSDL for the insurance example which 
	describes the abstract interfaces and bindings of all operations supported by the SstWSInsurancePolicyInterface 
	service.  The 'binding' section of this WSDL document specifies that operations will be serialized
	with style='rpc' and use='literal'.      
	Be aware that the WS-I Basic Profile (http://www.ws-i.org/Profiles/Basic/2003-06/BasicProfile-1.0-BdAD.html)
	recommends the usage of literal, non-encoded XML.  


"  -----------   Resource file generation and test setup ---------------------------------------------------------- "

" Generate the Web services interface files for the @WS-API operations in class SstWSInsurancePolicyInterface.
  The 'binding' operations will be created with   style='rpc' and use='literal'.  Files will be saved in the image startup directory "
SstWSXmlGeneration  forClass: SstWSInsurancePolicyInterface saveTo: ''


" Updates configuration so that the 'rpc_literal' test resources are properly resolved.  
  This step establishes settings in the active XML configuration causing unqualified WSDL
  resources to be retrieved from the 'rpc_literal' test directory.  "
SstWebServicesInsuranceExample setupRpcLiteral


" Start an HTTP file server to serve required service deployment files.  The server  "
 |server|
 server := SstHttpServerExample runAt: 'http://:63001' 
	in: SstWebServicesInsuranceExample wsCommonResourceDirectory
        
"  ---------------------------   Invocation of operations ------------------   "


" Deploy using the sample container configuration file.  Using this technique, custom overrides 
specified in the provided container deployment descriptor are applied to the newly deployed container.  "
SstWSContainer clearAll.
[ SstWSContainer deploy: 'http://vasthost:63001/SstWSSampleServerContainer.xml'.
AbtXmlUtility log: 'Server deployment completed' ] fork.


" Create the client container and deploy the example Insurance service  "
[|aContainer serviceCollection |
aContainer := SstWSContainer containerNamed:  'VastSampleClientContainer' 
	ifNone: [ SstWSContainer createContainerNamed: 'VastSampleClientContainer' ].
serviceCollection := aContainer deploy: 'http://vasthost:63001/SstWSInsurancePolicyClientInterface.xml'.
AbtXmlUtility log: 'Client deployment completed' ] fork.


" Invoke the 'getAllPolicies' operation which returns a collection of SstWSInsurancePolicy objects "
[|aContainer service |
aContainer := SstWSContainer containerNamed:  'VastSampleClientContainer' 
	ifNone: [ SstWSContainer createContainerNamed: 'VastSampleClientContainer' ].
service  := aContainer serviceNamed: 'SstWSInsurancePolicyInterface' 
 inNamespace: 'http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface-impl'.
service getAllPolicies inspect ] fork.


" Code sample below invokes multiple operations in same script.  Results are displayed via inspector.
   Code assumes that the 'VastSampleClientContainer' was created by previous steps.  "
[|aContainer service args newPerson policy updatedPolicy newRate|
 aContainer := SstWSContainer containerNamed:  'VastSampleClientContainer'.
service := aContainer serviceNamed: 'SstWSInsurancePolicyInterface' 
 inNamespace: 'http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface-impl'.
( policy := service getInfoForPolicy: '85496328' ) inspect.
newPerson:= policy owner deepCopy.
newPerson name: 'New Person'; tin: '694-17-0804'.
updatedPolicy := policy deepCopy.
updatedPolicy dependents add: newPerson.
		
(newRate:= service ratePolicy: updatedPolicy ) inspect.
updatedPolicy premium: newRate.
(service updatePolicy: updatedPolicy )  inspect.
] fork.


" This operation passes the second method argument as a SOAP:Header.  The WSDL for the operation contains 
header extension descriptions to allow the VAST framework to encode the header automatically  "
[|aContainer service args newPerson policy updatedPolicy newRate|
 aContainer := SstWSContainer containerNamed:  'VastSampleClientContainer' 
	ifNone: [ SstWSContainer createContainerNamed: 'VastSampleClientContainer' ].
 "	service := aContainer serviceNamed: 'SstWSInsurancePolicyInterface' 
  inNamespace: 'http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface-impl'. "
service := (aContainer deploy: 'http://vasthost:63001/SstWSInsurancePolicyClientInterface.xml') first.
(policy:= service getInfoForPolicy: '85496328'  withVerification: 'Acme Insurance' ) inspect.
] fork.


" This code passes an invalid business partner argument (2nd argument) and causes the server application logic to 
  issue an exception.  The exception is passed back to the client as a SOAP fault "
[|aContainer service args newPerson policy updatedPolicy newRate|
 aContainer := SstWSContainer containerNamed:  'VastSampleClientContainer' 
	ifNone: [ SstWSContainer createContainerNamed: 'VastSampleClientContainer' ].
 "	service := aContainer serviceNamed: 'SstWSInsurancePolicyInterface' inNamespace: 'http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface'. "
service := (aContainer deploy: 'http://vasthost:63001/SstWSInsurancePolicyClientInterface.xml') first.
(policy:= service getInfoForPolicy: '85496328'  withVerification: 'Big Boy Insurance' ) inspect.
] fork.
