The SOAP envelope request
This cook book entry marks the point in the Web services framework where a SOAP envelope is constructed and sent from client to server. The web service used is based on the SstWSInsurancePolicyInterface example shipped with VAST Platform and described .in
Getting Started: Web services in 1 Hour.
In order to observe the SOAP envelope, one of the web services based on the insurance policy example must be deployed in server and client images.
o Passing strings to and from your service using document literal, RPC literal or RPC Encoded styles.
o Passing complex data types to and from your service using document literal, RPC literal or RPC Encoded styles.
o Using specialized handlers using document literal, RPC literal or RPC Encoded styles.
This cookbook entry considers the operation getInfoForPolicy. Once the service is deployed, a service operation, getInfoForPolicy, can be invoked. The policy number is 29467810.
The example uses the specialized handlers as an additional operation of interest: getInfoForPolicyWithVerification. The policy number is 85496328 and 'Acme Insurance' is used to verify if the policy belongs to a recognized company.
Where to stop in client
The method of interest is SstWSHttpDispatchHandler>> postSOAPMessage:to:context: ; the parameter aString contains the string representation of the SOAP envelope which is the request for the operation getInfoForPolicy. Set a breakpoint at the beginning of the method.
In order to be able to stop in this method, turn off exception trapping and forwarding for http. To do this, choose Tools>SST>Trap Exceptions from the Transcript pull downs. In the resulting dialog, move http from the enabled to the disabled list. Repeat for Tools>SST>Forward Exceptions.
Calling getInfoForPolicy
Execute the following Smalltalk expression in the client side web service inspector.
(self invoke: 'getInfoForPolicy'
withArguments: #( '29467810' )) inspect.
A debugger will open. Inspecting aString will show the SOAP envelope which is the request for the operation getInfoForPolicy. The envelope body contains the information on which policy to get.
document literal
'<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="literal"
xmlns:swsipi="urn:SstWSInsurancePolicyInterface"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="literal"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<swsipi:getInfoForPolicy xsi:type="xsd:string">29467810</swsipi:getInfoForPolicy>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>'
rpc literal
'<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="literal"
xmlns:xsd1="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="literal"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<swsipi:getInfoForPolicy
xmlns:swsipi="urn:SstWSInsurancePolicyInterface">
<getInfoForPolicy xsi:type="xsd1:string">29467810</getInfoForPolicy>
</swsipi:getInfoForPolicy>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>'
rpc encoded
'<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="encoded"
xmlns:xsd1="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="encoded"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<swsipi:getInfoForPolicy
xmlns:swsipi="urn:SstWSInsurancePolicyInterface">
<getInfoForPolicy xsi:type="xsd1:string">29467810</getInfoForPolicy>
</swsipi:getInfoForPolicy>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>'
Calling getInfoForPolicyWithVerification
Execute the following Smalltalk expression in the client side web service inspector.
(self invoke: 'getInfoForPolicyWithVerification'
withArguments: #( '85496328' 'Acme Insurance' )) inspect.
A debugger will open. Inspecting aString will show the SOAP envelope which is the request for the operation getInfoForPolicyWithVerification. The envelope body contains the information on which policy to get. Notice the addition of a header to the SOAP envelope. The verification is accomplished through the processing of the header.
document literal
'<SOAP-ENV:Envelope
xmlns:tin="urn:SstWSInsurancePolicyInterface"
xmlns:swsipi="urn:SstWSInsurancePolicyInterface"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header>
<tin:QueryString>Acme Insurance</tin:QueryString>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<tin:getInfoForPolicyWithVerification>85496328</tin:getInfoForPolicyWithVerification>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>'
rpc literal
'<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="literal"
xmlns:xsd1="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tin="http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface"
xmlns:SOAP-ENC="literal"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header>
<tin:QueryString>Acme Insurance</tin:QueryString>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<swsipi:getInfoForPolicyWithVerification
xmlns:swsipi="urn:SstWSInsurancePolicyInterface">
<getInfoForPolicy xsi:type="xsd1:string">85496328</getInfoForPolicy>
</swsipi:getInfoForPolicyWithVerification>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>'
rpc encoded
'<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd1="http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tin="http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header>
<tin:QueryString>Acme Insurance</tin:QueryString>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<swsipi:getInfoForPolicyWithVerification
xmlns:swsipi="urn:SstWSInsurancePolicyInterface">
<getInfoForPolicy xsi:type="xsd1:string">85496328</getInfoForPolicy>
</swsipi:getInfoForPolicyWithVerification>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>'
Where to stop in server
The method of interest is SstWSHttpResponseHandler>> invoke: ; the parameter aMessageContext contains, among other things, the SOAP envelope which is the request for the operation getInfoForPolicy. Set a breakpoint at the first line.
In order to be able to stop in this method, turn off exception trapping and forwarding for http. To do this, choose Tools>SST>Trap Exceptions from the Transcript pull downs. In the resulting dialog, move http from the enabled to the disabled list. Repeat for Tools>SST>Forward Exceptions.
Calling the web service operation
Execute the following Smalltalk expression in the client side web service inspector.
(self invoke: 'getInfoForPolicy'
withArguments: #( '29467810' )) inspect.
For getInfoForPolicy or if the insurance policy based web service employs a custom handler via the operation getInfoForPolicyWithVerification, execute the Smalltalk expression
(self invoke: 'getInfoForPolicyWithVerification'
withArguments: #( '85496328' 'Acme Insurance' )) inspect.
A debugger will open. Inspecting the wsTransportMessageRequest property aMessageContext will show a SstHttpServletRequest.
SstHttpRequestHeader{
POST /SstWSServlet HTTP/1.1
SOAPAction: "http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface-interface/getInfoForPolicy"
Content-Type: text/xml; charset=utf-8
Content-Length: 541
Host: vasthost:7374
}
This contains a header like the one above and a contents of the SOAP envelope which is the request for the operation. The exact contents of the envelope will vary according to whether the encoding is document literal, rpc literal or rpc encoded and whether the operation invoked was getInfoForPolicyWithVerification or getInfoForPolicyWithVerification.
Where to stop in Client described the SOAP envelope.