Anatomy of a Session

Putting it all together

A session consists of performing a login request, generating a contextId, creating or loading an entity bean, performing a collection updates to this in the bean store, and writing the changes back to the platform, finally logging out and removing the session from the store. Thus completing the life-cycle.

1. Login

**Request** Make a request to the context FACADE, with the unique process *login*, load on to the entity the parameters *userName* and *password*

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:localhost-paint" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
   <SOAP-ENV:Body>
     <ns1:handleRequest>
       <contextId xsi:nil="true"/>
       <className xsi:type="xsd:string">bus_facade_context</className>
       <processName xsi:type="xsd:string">login</processName>
       <entityData xsi:type="ns2:Map">
         <item>
           <key xsi:type="xsd:string">userName</key>
           <value xsi:type="xsd:string">API USERNAME HERE</value>
         </item>
         <item>
           <key xsi:type="xsd:string">password</key>
           <value xsi:type="xsd:string">API PASSWORD HERE</value>
         </item>
       </entityData>
       <processData xsi:nil="true"/>
     </ns1:handleRequest>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
**Response** Assuming the result is successful, capture the beanId, this is the contextID of the session. This is used to tie together all subsequent requests until the session ends. *Omitted are a number of other returned fields, this request returns an associative array / or key value pairs (map) representation of the entity bean, in this case the context bean associated with this API login.*
	<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:localhost-paint" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://xml.apache.org/xml-soap" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <SOAP-ENV:Body>
  <ns1:handleRequestResponse>
   <Result xsi:type="ns2:Map">
    <item>
     <key xsi:type="xsd:string">result</key>
     <value xsi:type="xsd:string">success</value>
    </item>
    <item>
     <key xsi:type="xsd:string">resultData</key>
     <value xsi:type="ns2:Map">
      <item>
          <key xsi:type="xsd:string">bus_entity_context</key>
          <value xsi:type="ns2:Map">
            <item>
                <key xsi:type="xsd:string">userName</key>
                <value xsi:type="xsd:string">API USERNAME LOGGED IN WITH</value>
            </item>
            <item>
              ......
            </item>
            <item>
              <key xsi:type="xsd:string">beanId</key>
              <value xsi:type="xsd:string">C-XPzaXk6LndjcI9D99dCnIUZ</value>
            </item>
            <item>
              .....
            </item>
          </value>
        </item>
      </Result>
   </ns1:handleRequestResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

2. Create empty list entity in bean store

**Request** Using the contextID generated during the login request to access the session in the bean store, call the FACADE bean associated with lists, with a create process. This doesn't take any parameters as it is generating a new, empty bean within the bean store.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:localhost-paint" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <SOAP-ENV:Body>
  <ns1:handleRequest>
   <contextId xsi:type="xsd:string">C-XPzaXk6LndjcI9D99dCnIUZ</contextId>
   <className xsi:type="xsd:string">bus_facade_campaign_list</className>
   <processName xsi:type="xsd:string">create</processName>
   <entityData xsi:nil="true"/>
   <processData xsi:nil="true"/>
  </ns1:handleRequest>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
**Response** Assuming the result is successful, capture the beanId, this is the reference to the new list entity created in the bean store, and is the reference for updating the bean and writing this back to the platform. *Omitted are a number of other returned fields, this request returns an associative array / or key value pairs (map) representation of the entity bean, in this case the list bean associated with this create process.*
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:localhost-paint" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <SOAP-ENV:Body>
  <ns1:handleRequestResponse>
   <Result xsi:type="ns2:Map">
    <item>
     <key xsi:type="xsd:string">result</key>
     <value xsi:type="xsd:string">success</value>
    </item>
    <item>
     <key xsi:type="xsd:string">resultData</key>
     <value xsi:type="ns2:Map">
      <item>
       <key xsi:type="xsd:string">bus_entity_campaign_list</key>
       <value xsi:type="ns2:Map">
        <item>
         <key xsi:type="xsd:string">listName</key>
         <value xsi:nil="true"/>
        </item>
        <item>
         <key xsi:type="xsd:string">languageCode</key>
         <value xsi:type="xsd:string">en_GB.ISO8859-15</value>
        </item>
        <item>
         <key xsi:type="xsd:string">emailCol</key>
         <value xsi:type="xsd:int">-1</value>
        </item>
        <item>
         <key xsi:type="xsd:string">mobileCol</key>
         <value xsi:type="xsd:int">-1</value>
        </item>
        <item>
         <key xsi:type="xsd:string">signupDateCol</key>
         <value xsi:type="xsd:int">-1</value>
        </item>
        <item>
         <key xsi:type="xsd:string">uploadFileNotifyEmail</key>
         <value xsi:type="xsd:string">test@pure360.com</value>
        </item>
        <item>
         <key xsi:type="xsd:string">uploadTransactionType</key>
         <value xsi:type="xsd:string">CREATE</value>
        </item>
              ..........    
        <item>
         <key xsi:type="xsd:string">beanId</key>
         <value xsi:type="xsd:string">a32613d87404d626f342068e52c13701</value>
        </item>
            ......
       </value>
      </item>
     </value>
    </item>
   </Result>
  </ns1:handleRequestResponse>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

3. Update empty list entity in bean store

**Request** Using the contextID generated during the login request to access the session in the bean store, call the FACADE bean associated with lists, with an update process. Use the beanId to reference the newly created list entity bean within the bean store, passing in the writable fields that make up creating a new list (bus_facade_campaign_list), the facade will validate these fields and update the entity bean with the beanId passed in the bean store with these fields of data.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:localhost-paint" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <SOAP-ENV:Body>
  <ns1:handleRequest>
   <contextId xsi:type="xsd:string">C-XPzaXk6LndjcI9D99dCnIUZ</contextId>
   <className xsi:type="xsd:string">bus_facade_campaign_list</className>
   <processName xsi:type="xsd:string">update</processName>
   <entityData xsi:type="ns2:Map">
    <item>
     <key xsi:type="xsd:string">emailCol</key>
     <value xsi:type="xsd:int">0</value>
    </item>
    <item>
     <key xsi:type="xsd:string">signUpDateCol</key>
     <value xsi:type="xsd:int">1</value>
    </item>
    <item>
     <key xsi:type="xsd:string">field1Col</key>
     <value xsi:type="xsd:int">2</value>
    </item>
    <item>
     <key xsi:type="xsd:string">field1Name</key>
     <value xsi:type="xsd:string">Name</value>
    </item>
    <item>
     <key xsi:type="xsd:string">field2Col</key>
     <value xsi:type="xsd:int">3</value>
    </item>
    <item>
     <key xsi:type="xsd:string">field2Name</key>
     <value xsi:type="xsd:string">dob</value>
    </item>
    <item>
     <key xsi:type="xsd:string">field2DataType</key>
     <value xsi:type="xsd:string">date</value>
    </item>
    <item>
     <key xsi:type="xsd:string">field2DataFormat</key>
     <value xsi:type="xsd:string">dd/mm/yyyy</value>
    </item>
    <item>
     <key xsi:type="xsd:string">uploadFileNotifyEmail_base64</key>
     <value xsi:type="xsd:string">dGVzdEBwdXJlMzYwLmNvbQ==</value>
    </item>
    <item>
     <key xsi:type="xsd:string">uploadFileNotifyType</key>
     <value xsi:type="xsd:string">EMAIL</value>
    </item>
    <item>
     <key xsi:type="xsd:string">uploadTransactionType</key>
     <value xsi:type="xsd:string">CREATE</value>
    </item>
    <item>
     <key xsi:type="xsd:string">replacePendingFileInd</key>
     <value xsi:type="xsd:string">Y</value>
    </item>
    <item>
     <key xsi:type="xsd:string">listName_base64</key>
     <value xsi:type="xsd:string">VGVzdExpc3QtMjAxNA==</value>
    </item>
    <item>
     <key xsi:type="xsd:string">pasteFile_base64</key>
     <value xsi:type="xsd:string">ZW1haWwsc2lnblVwLE5hbWUsZG9iDQp0ZXN0MUB0ZXN0LmNvbSwyMDEzLTEyLTAxLGJvYiwyNC8xMS8xOTg3DQp0ZXN0MkB0ZXN0LmNvbSwyMDEyLTA2LTIxLGJvYiwxNi8xMC8xOTgy</value>
     </item>
     <item>
      <key xsi:type="xsd:string">beanId</key>
      <value xsi:type="xsd:string">a32613d87404d626f342068e52c13701</value>
     </item>
    </entityData>
    <processData xsi:nil="true"/>
   </ns1:handleRequest>
  </SOAP-ENV:Body>
 </SOAP-ENV:Envelope>
**Response** Assuming the result is successful, success will be returned in the result, if there is an error the result (associative array) map will contain the type of error as the value to the result key, and the resultData will contain further information regarding the error.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:localhost-paint" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <SOAP-ENV:Body>
  <ns1:handleRequestResponse>
   <Result xsi:type="ns2:Map">
    <item>
     <key xsi:type="xsd:string">result</key>
     <value xsi:type="xsd:string">success</value>
    </item>
   </Result>
  </ns1:handleRequestResponse>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

4. Store list entity in the platform

**Request** Using the contextID generated during the login request to access the session in the bean store, call the FACADE bean associated with lists, with a store process. Use the beanId to reference the newly created, and updated, list entity bean within the bean store. This will write the list back to the platform, and remove the entity bean from the bean store.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:localhost-paint" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <SOAP-ENV:Body>
  <ns1:handleRequest>
   <contextId xsi:type="xsd:string">C-XPzaXk6LndjcI9D99dCnIUZ</contextId>
   <className xsi:type="xsd:string">bus_facade_campaign_list</className>
   <processName xsi:type="xsd:string">store</processName>
   <entityData xsi:type="ns2:Map">
     <item>
      <key xsi:type="xsd:string">beanId</key>
      <value xsi:type="xsd:string">a32613d87404d626f342068e52c13701</value>
     </item>
    </entityData>
    <processData xsi:nil="true"/>
   </ns1:handleRequest>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
**Response** Assuming the result is successful, success will be returned in the result, if there is an error the result (associative array) map will contain the type of error as the value to the result key, and the resultData will contain further information regarding the error.
	<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:localhost-paint" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <SOAP-ENV:Body>
  <ns1:handleRequestResponse>
   <Result xsi:type="ns2:Map">
    <item>
     <key xsi:type="xsd:string">result</key>
     <value xsi:type="xsd:string">success</value>
    </item>
    <item>
     <key xsi:type="xsd:string">resultData</key>
     <value xsi:type="ns2:Map">
      <item>
       <key xsi:type="xsd:string">bus_entity_campaign_list_key</key>
       <value xsi:type="ns2:Map">
        <item>
         <key xsi:type="xsd:string">listId</key>
         <value xsi:nil="true"/>
        </item>
        <item>
         <key xsi:type="xsd:string">beanName</key>
         <value xsi:type="xsd:string">bus_entity_campaign_list</value>
        </item>
       </value>
      </item>
     </value>
    </item>
   </Result>
  </ns1:handleRequestResponse>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

5. Logout

**Request** Using the contextID generated during the login request to access the session in the bean store, call the FACADE bean associated with context, with a logout process. There are no parameters as the contextId is already included in the request. This will end the session removing this context from the bean store.
	<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:localhost-paint" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <SOAP-ENV:Body>
  <ns1:handleRequest>
   <contextId xsi:type="xsd:string">C-XPzaXk6LndjcI9D99dCnIUZ</contextId>
   <className xsi:type="xsd:string">bus_facade_context</className>
   <processName xsi:type="xsd:string">logout</processName>
   <entityData xsi:nil="true"/>
   <processData xsi:nil="true"/>
  </ns1:handleRequest>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
**Response** Assuming the result is successful, success will be returned in the result, if there is an error the result (associative array) map will contain the type of error as the value to the result key, and the resultData will contain further information regarding the error.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:localhost-paint" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
 <SOAP-ENV:Body>
  <ns1:handleRequestResponse>
   <Result xsi:type="ns2:Map">
    <item>
     <key xsi:type="xsd:string">result</key>
     <value xsi:type="xsd:string">success</value>
    </item>
   </Result>
  </ns1:handleRequestResponse>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>