" ---------------------------------------------------------------------------------------
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='encoded'.     

	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='encoded'.  Files will be saved in the image startup directory "
SstWSXmlGeneration  withSoapEncodingStyle
	generateServiceFilesForClass: SstWSInsurancePolicyInterface 


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


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


" 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 args|
aContainer := SstWSContainer containerNamed:  'VastSampleClientContainer' 
	ifNone: [ SstWSContainer createContainerNamed: 'VastSampleClientContainer' ].
serviceCollection := aContainer deploy: 'http://vasthost:63001/SstWSInsurancePolicyClientInterface.xml'.
AbtXmlUtility log: 'Client deployment completed' ] fork.



"  ---------------------------   Invocation of operations  ----------------------------------------"

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


" Invoke the 'getAllPoliciesUsingSoapArray' executes the 'getAllPolicies' operation, but results are 
returned as a SOAP:Array "
[|aContainer service|
 aContainer := SstWSContainer containerNamed:  'VastSampleClientContainer'.
 service := aContainer serviceNamed: 'SstWSInsurancePolicyInterface' 
	 inNamespace: 'http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface-impl'.
 service getAllPoliciesUsingSoapArrays 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   policy  |
 aContainer := SstWSContainer containerNamed:  'VastSampleClientContainer'.
 service := aContainer serviceNamed: 'SstWSInsurancePolicyInterface' 
	 inNamespace: 'http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface-impl'.
(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   policy  |
 aContainer := SstWSContainer containerNamed:  'VastSampleClientContainer'.
 service := aContainer serviceNamed: 'SstWSInsurancePolicyInterface' 
	 inNamespace: 'http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface-impl'.
(policy:= service getInfoForPolicy: '85496328'  withVerification: 'Big boy insurance' ) inspect.
] fork.



" Modify the client input message constructor so that it appends global header information to 
all outgoing SOAP messages.  Subsequent executions cause the server handler named 
SstWSSampleContainerHeaderInputHandler to be invoked, and write a message to the Transcript. "
| chain |
chain := ( SstWSContainer containerNamed:  'VastSampleClientContainer' ) handlerFactory
	handlerNamed: 'wsClientInputMessageConstructor'.
chain addHandler: (SstWSSampleContainerHeaderOutputHandler new name: 'containerHeaderHandler' )
