Construction of SOAP envelope response
This cook book entry marks the point in the Web services framework where a SOAP envelope is sent to the client from server. The web service used is based on the SstWSInsurancePolicyInterface example shipped with VAST Platform and described .in
Getting Started: Web services in a Day.
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.
•Passing strings to and from your service using document literal, RPC literal or RPC Encoded styles.
•Passing complex data types to and from your service using document literal, RPC literal or RPC Encoded styles.
•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 with 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 in the client image SstWSHttpDispatchHandler>> invoke: ; the parameter aMessageContext contains, among other things, the SOAP envelope which is the result for the operation getInfoForPolicy. Set a breakpoint at the line
self validateHttpResponse: result context: aMessageContext.
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 result will show the SstByteMessage which holds the header and the result for the operation getInfoForPolicy. The header will be nearly identical for any operation or encoding:
SstHttpResponseHeader{
HTTP/1.1 200 OK
Content-Type: text/xml
Content-Length: 1331
}
Only the content-length will vary in the successful responses considered in this cookbook entry. The response itself is contained in the body of a SOAP envelope. The response specifies the insurance policy’s policy number, premium, owner and dependents. The exact structure of the response depends on the encoding style of the web service.
document literal
result contents
'<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:getInfoForPolicyResponse xsi:type="swsipi1:SstWSInsurancePolicy"
xmlns:swsipi1="http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface">
<policyNumber xsi:type="xsd:string">29467810</policyNumber>
<premium xsi:type="xsd:float">453.01</premium>
<owner xsi:type="swsipi1:SstWSPerson">
<tin xsi:type="xsd:string">846-89-3497</tin>
<name xsi:type="xsd:string">Some Name</name>
<policyNumber xsi:type="xsd:string">29467810</policyNumber>
<address xsi:type="swsipi1:SstWSAddress">
<street xsi:type="xsd:string">107 Maple Avenue</street>
<city xsi:type="xsd:string">Toledo</city>
<state xsi:type="xsd:string">OH</state>
<zip xsi:type="xsd:string">28901</zip>
</address>
</owner>
<dependents xsi:type="swsipi1:SstPersonCollection"></dependents>
</swsipi:getInfoForPolicyResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>'
Notice that the data about the constituent parts of the policy is contained in a getInfoForPolicyResponse.
rpc literal
result contents
'<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="literal"
xmlns:tin="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:getInfoForPolicyResponse
xmlns:swsipi="urn:SstWSInsurancePolicyInterface">
<outMsg xsi:type="swsipi1:SstWSInsurancePolicy"
xmlns:swsipi1="http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface">
<policyNumber xsi:type="xsd:string">29467810</policyNumber>
<premium xsi:type="xsd:float">453.01</premium>
<owner xsi:type="swsipi1:SstWSPerson">
<tin xsi:type="xsd:string">846-89-3497</tin>
<name xsi:type="xsd:string">Some Name</name>
<policyNumber xsi:type="xsd:string">29467810</policyNumber>
<address xsi:type="swsipi1:SstWSAddress">
<street xsi:type="xsd:string">107 Maple Avenue</street>
<city xsi:type="xsd:string">Toledo</city>
<state xsi:type="xsd:string">OH</state>
<zip xsi:type="xsd:string">28901</zip>
</address>
</owner>
<dependents xsi:type="swsipi1:SstPersonCollection"></dependents>
</outMsg>
</swsipi:getInfoForPolicyResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>'
Notice that the data about the constituent parts of the policy is contained in an outMsg.
rpc encoded
result contents
'<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="encoded"
xmlns:tin="http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface"
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:getInfoForPolicyResponse
xmlns:swsipi="urn:SstWSInsurancePolicyInterface">
<outMsg xsi:type="tin:SstPolicyOrError">
<policy xsi:type="tin:SstWSInsurancePolicy">
<policyNumber xsi:type="xsd:string">29467810</policyNumber>
<premium xsi:type="xsd:float">436.8</premium>
<owner xsi:type="tin:SstWSPerson">
<tin xsi:type="xsd:string">846-89-3497</tin>
<name xsi:type="xsd:string">Some Name</name>
<policyNumber xsi:type="xsd:string">29467810</policyNumber>
<address xsi:type="tin:SstWSAddress">
<street xsi:type="xsd:string">107 Maple Avenue</street>
<city xsi:type="xsd:string">Toledo</city>
<state xsi:type="xsd:string">OH</state>
<zip xsi:type="xsd:string">28901</zip>
</address>
</owner>
<dependents xsi:type="tin:SstPersonCollection"></dependents>
</policy>
</outMsg>
</swsipi:getInfoForPolicyResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>'
Notice that the data about the constituent parts of the policy is contained in a policy which is in turn contained in an outMsg.
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.
Since this particular call results in a successful verification, the envelope body contains data regarding the policy. The structure of the body will be the same as for the operation getInfoForPolicy. Notice the addition of a header to the SOAP envelope. This is where the results of the verification are stored:
<tin:QueryString>Partner verified by server</tin:QueryString>
QueryString is simply a string. The contents are ‘Partner verified by server’.
document literal
'<SOAP-ENV:Envelope
xmlns:tin="urn:SstWSInsurancePolicyInterface"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tin1="urn:SstWSInsurancePolicyInterface"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header>
<tin:QueryString>Partner verified by server</tin:QueryString>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<tin:PolicyOrError>
<policy>
<policyNumber>85496328</policyNumber>
<premium>1311.17</premium>
<owner>
<tin>895-61-6974</tin>
<name>John Doe</name>
<policyNumber>85496328</policyNumber>
<address>
<street>1969 Mockingbird Lane</street>
<city>Cary</city>
<state>NC</state>
<zip>27522</zip>
</address>
</owner>
<dependents>
<person>
<tin>815-81-6244</tin>
<name>Jane Doe</name>
<policyNumber>85496328</policyNumber>
<address>
<street>1969 Mockingbird Lane</street>
<city>Cary</city>
<state>NC</state>
<zip>27522</zip>
</address>
</person>
<person>
<tin>295-68-6916</tin>
<name>Jim Doe</name>
<policyNumber>85496328</policyNumber>
<address>
<street>1969 Mockingbird Lane</street>
<city>Cary</city>
<state>NC</state>
<zip>27522</zip>
</address>
</person>
</dependents>
</policy>
</tin:PolicyOrError>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>'
rpc literal
'<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="literal"
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:tin1="http://www.SstWSInsurancePolicyInterface.com/SstWSInsurancePolicyInterface"
xmlns:SOAP-ENC="literal"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header>
<tin:QueryString>Partner verified by server</tin:QueryString>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<swsipi:getInfoForPolicyWithVerificationResponse
xmlns:swsipi="urn:SstWSInsurancePolicyInterface">
<outMsgInfo xsi:type="tin:SstPolicyOrError">
<policy xsi:type="tin:SstWSInsurancePolicy">
<policyNumber xsi:type="xsd:string">85496328</policyNumber>
<premium xsi:type="xsd:float">1311.17</premium>
<owner xsi:type="tin:SstWSPerson">
<tin xsi:type="xsd:string">895-61-6974</tin>
<name xsi:type="xsd:string">John Doe</name>
<policyNumber xsi:type="xsd:string">85496328</policyNumber>
<address xsi:type="tin:SstWSAddress">
<street xsi:type="xsd:string">1969 Mockingbird Lane</street>
<city xsi:type="xsd:string">Cary</city>
<state xsi:type="xsd:string">NC</state>
<zip xsi:type="xsd:string">27522</zip>
</address>
</owner>
<dependents xsi:type="tin:SstPersonCollection">
<person xsi:type="tin:SstWSPerson">
<tin xsi:type="xsd:string">815-81-6244</tin>
<name xsi:type="xsd:string">Jane Doe</name>
<policyNumber xsi:type="xsd:string">85496328</policyNumber>
<address xsi:type="tin:SstWSAddress">
<street xsi:type="xsd:string">1969 Mockingbird Lane</street>
<city xsi:type="xsd:string">Cary</city>
<state xsi:type="xsd:string">NC</state>
<zip xsi:type="xsd:string">27522</zip>
</address>
</person>
<person xsi:type="tin:SstWSPerson">
<tin xsi:type="xsd:string">295-68-6916</tin>
<name xsi:type="xsd:string">Jim Doe</name>
<policyNumber xsi:type="xsd:string">85496328</policyNumber>
<address xsi:type="tin:SstWSAddress">
<street xsi:type="xsd:string">1969 Mockingbird Lane</street>
<city xsi:type="xsd:string">Cary</city>
<state xsi:type="xsd:string">NC</state>
<zip xsi:type="xsd:string">27522</zip>
</address>
</person>
</dependents>
</policy>
</outMsgInfo>
</swsipi:getInfoForPolicyWithVerificationResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>'
rpc encoded
'<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
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:tin1="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>Partner verified by server</tin:QueryString>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<swsipi:getInfoForPolicyWithVerificationResponse
xmlns:swsipi="urn:SstWSInsurancePolicyInterface">
<outMsgInfo href="#id1"/>
</swsipi:getInfoForPolicyWithVerificationResponse>
<multiRef1 xsi:type="tin:SstWSInsurancePolicy" id="id1">
<policyNumber xsi:type="xsd:string">85496328</policyNumber>
<premium xsi:type="xsd:float">1311.17</premium>
<owner href="#id2"/>
<dependents href="#id3"/>
</multiRef1>
<multiRef2 xsi:type="tin:SstWSPerson" id="id2">
<tin xsi:type="xsd:string">895-61-6974</tin>
<name xsi:type="xsd:string">John Doe</name>
<policyNumber xsi:type="xsd:string">85496328</policyNumber>
<address href="#id4"/>
</multiRef2>
<multiRef3 xsi:type="tin:SstPersonCollection" id="id3">
<person href="#id5"/>
<person href="#id6"/>
</multiRef3>
<multiRef4 xsi:type="tin:SstWSAddress" id="id4">
<street xsi:type="xsd:string">1969 Mockingbird Lane</street>
<city xsi:type="xsd:string">Cary</city>
<state xsi:type="xsd:string">NC</state>
<zip xsi:type="xsd:string">27522</zip>
</multiRef4>
<multiRef5 xsi:type="tin:SstWSPerson" id="id5">
<tin xsi:type="xsd:string">815-81-6244</tin>
<name xsi:type="xsd:string">Jane Doe</name>
<policyNumber xsi:type="xsd:string">85496328</policyNumber>
<address href="#id7"/>
</multiRef5>
<multiRef6 xsi:type="tin:SstWSPerson" id="id6">
<tin xsi:type="xsd:string">295-68-6916</tin>
<name xsi:type="xsd:string">Jim Doe</name>
<policyNumber xsi:type="xsd:string">85496328</policyNumber>
<address href="#id8"/>
</multiRef6>
<multiRef7 xsi:type="tin:SstWSAddress" id="id7">
<street xsi:type="xsd:string">1969 Mockingbird Lane</street>
<city xsi:type="xsd:string">Cary</city>
<state xsi:type="xsd:string">NC</state>
<zip xsi:type="xsd:string">27522</zip>
</multiRef7>
<multiRef8 xsi:type="tin:SstWSAddress" id="id8">
<street xsi:type="xsd:string">1969 Mockingbird Lane</street>
<city xsi:type="xsd:string">Cary</city>
<state xsi:type="xsd:string">NC</state>
<zip xsi:type="xsd:string">27522</zip>
</multiRef8>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>'