" ---------------------------------------------------------------------------------------
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='document' and use='literal'.    
  
	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.  

	Serialization of document style messages can be considerably different than serialization of rpc messages.  Typically,
	WSDL operations for document style messages are defined with 1 <part>.  
	The WSDL part specifies an 'element' attribute that points to the XML element 	which describes the message payload.  
	During XML serialization, the payload of the SOAP body is serialized according to the schema type of the XML element.

	For this example, all operations are directed to the handler named 'SstWSInsurancePolicyDocLitHandler'.  The handler
	is very generic and processes the 'document' style messages in almost the same manner that the default handlers
	process standard 'rpc' messages.  The doc-literal example uses <operation> elements like the one shown below.

	<operation flow="doclit:docLitExampleHandler" qName="swsipi:getInfoForPolicy" name="getInfoForPolicy:" />

	At deployment time, VAST establishes mappings between WSDL operations and the handlers and methods that
 	are used to process those messages.  Typically, an operation specifies a 'flow' (handler) or a 'name' (selector). 
	For the doc_literal example, both the name and the flow are specified.
	During processing, VAST determines which handler to invoke for the 'getInfoForPolicy'.  The custom
	handler (SstWSInsurancePolicyDocLitHandler) then performs the Smalltalk method that corresponds to  
	'getInfoForPolicy'.

"  -----------   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='document' and use='literal'.  Files will be saved in the image startup directory "
( SstWSXmlGeneration new style: 'document' )
	generateServiceFilesForClass: SstWSInsurancePolicyInterface 


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


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


" Create a new container, and deploy the 'doc_literal' version of the insurance example to the
new container  "
SstWSContainer clearAll.
[ | container resourceName |
	container := SstWSContainer createContainerNamed: 'VastSampleServerContainer'.
	resourceName := SstWebServicesInsuranceExample qualifiedResourceNameFor: 'SstWSInsurancePolicyDocLitServerInterface.xml' subDirectory: 'doc_literal'.
	container deploy: resourceName.
AbtXmlUtility log: 'Server deployment completed' ] fork.



" Create the client container and deploy the example Insurance service  "
[| container resourceName|
	container := SstWSContainer createContainerNamed:  'VastSampleClientContainer'. 
	resourceName := SstWebServicesInsuranceExample qualifiedResourceNameFor: 'SstWSInsurancePolicyDocLitClientInterface.xml' subDirectory: 'doc_literal'.
	container deploy: resourceName.
AbtXmlUtility log: 'Client deployment completed' ] fork.


" Invoke the 'about' operation to verify invocation of a simple operation.  This is because the 'about' operation
for doc-literal contains one nillable argument to conform with convention. "
[|aContainer service args|
aContainer := SstWSContainer containerNamed:  'VastSampleClientContainer' 
	ifNone: [ SstWSContainer createContainerNamed: 'VastSampleClientContainer' ].
service := aContainer serviceNamed: 'SstWSInsurancePolicyInterface'
	inNamespace: 'http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface-impl'.
( service about: nil)  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 mappedElement |
aContainer := SstWSContainer containerNamed:  'VastSampleClientContainer' 
	ifNone: [ SstWSContainer createContainerNamed: '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 retrieves all insurance policies.  Notice that invocation is accomplished using a one-argument
	method despite the fact that 'getAllPolicies' does not actually require an argument.  Using doc-literal encoding,
	operations that don't require arguments must still specify WSDL part elements to describe their message structure "
[|aContainer service  | 
 aContainer := SstWSContainer containerNamed:  'VastSampleClientContainer' 
	ifNone: [ SstWSContainer createContainerNamed: 'VastSampleClientContainer' ].
 service := aContainer serviceNamed: 'SstWSInsurancePolicyInterface' 
  inNamespace: 'http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface-impl'. 
( service getAllPolicies: nil) inspect ] fork.
