3.1.3.2 Initialization for HTTP Transport

The client sends the following command to retrieve the session token from the server that has X-AS-GetSessionToken that contains the value "true" in the HTTP header.

 <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
   <Header>
     <BeginGetSessionToken soap:mustUnderstand="1" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:schemas-microsoft-com:xml-analysis" />
     <Version Sequence="400" xmlns="http://schemas.microsoft.com/analysisservices/2003/engine/2" />
   </Header>
   <Body>
     <Execute xmlns="urn:schemas-microsoft-com:xml-analysis">
       <Command>
         <Statement />
       </Command>
     </Execute>
   </Body>
 </Envelope>

The following is included in the SOAP response message from the server.

 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Header>
     <SessionToken> 
     <!--if the SOAP response body receives the session token, the-->
     <!--BeginSession header embeds the session token in the-->
     <!--body of the message here.-->
     </SessionToken>
   </soap:Header>
   <soap:Body>
     <ExecuteResponse xmlns="urn:schemas-microsoft-com:xml-analysis">
       <return />
     </ExecuteResponse>
   </soap:Body>
 </soap:Envelope>
  

If SessionToken is received in the SOAP response message, the BeginSession SOAP header embeds SessionToken in the body of the message as shown in the following example.

 <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
   <Header>
     <BeginSession soap:mustUnderstand="1" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:schemas-microsoft-com:xml-analysis" />
     <Version Sequence="400" xmlns="http://schemas.microsoft.com/analysisservices/2003/engine/2" />
   </Header>
   <Body>
     <Execute xmlns="urn:schemas-microsoft-com:xml-analysis">
       <Command>
       <ExtAuth>
     <AuthenticationScheme>DelegateToken</AuthenticationScheme>
                <ExtAuthInfo>
        <!--if the SOAP response body receives the session token,-->
        <!--the BeginSession header embeds the session token-->
        <!--in the body of the message here.-->
      </ExtAuthInfo>
       </ExtAuth>
         </Command>
       <Properties>
         <PropertyList>
           <LocaleIdentifier>1033</LocaleIdentifier>
         </PropertyList>
       </Properties>
     </Execute>
   </Body>
 </Envelope>

If the SessionToken is not received in the SOAP response message or if there is an error in the response, the BeginSession SOAP header is as shown in the following example.

 <?xml version="1.0" encoding="utf-8"?>
 <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
   <Header>
     <BeginSession xmlns="urn:schemas-microsoft-com:xml-analysis" mustUnderstand="1"/>
    </Header>
    <Body>
     ...<!-- Discover or Execute element goes here.-->
    </Body>
 </Envelope>

The SOAP response message from the server includes the session ID in the SOAP header.

 <Header>
  <Session
   xmlns="urn:schemas-microsoft-com:xml-analysis"
   SessionId="537C61C6-827C-4305-83A6-C8CE4A91001B"/>
 </Header>

For each subsequent request, the client MUST include the session ID that is provided by the server.

 <Header>
  <Session
   xmlns="urn:schemas-microsoft-com:xml-analysis"
   mustUnderstand="1"
   SessionId="537C61C6-827C-4305-83A6-C8CE4A91001B"/>
 </Header>

To end the session, the client MUST send the EndSession header that contains the related session ID value to the server.

 <Header>
  <EndSession
   xmlns="urn:schemas-microsoft-com:xml-analysis"
   mustUnderstand="1"
   SessionId="537C61C6-827C-4305-83A6-C8CE4A91001B"/>
 </Header>

Sessions MUST be supported on the server.<119>

Multiple commands can be executed in the context of a single session. The server MAY<120> choose to time out an active session after a period of inactivity.

The SOAP header elements and attributes for initiating, maintaining, and closing a session for HTTP transport are the same as the SOAP header elements and attributes that this protocol defines for non-HTTP transport (section 3.1.3.1).

If the session ID that is specified in the Session or EndSession SOAP header is not valid or has timed out, the server MUST return a SOAP fault.