Aracılığıyla paylaş


soap oturumları hareketleri kullanma

Bu özellik Microsoft SQL Server'ın ilerideki bir sürümünde kaldırılacaktır. Yeni geliştirme işlerinde bu özelliği kullanmaktan kaçının ve bu özelliği kullanmakta olan uygulamalarda değişiklik yapmayı planlayın.

Bir hareketi sıkça yapılan bir dizi toplu işleminin birbiri ardına gönderilmiş ve sıralı biçimde yürütülmesini gerektirir.Herhangi bir toplu iş iş hareket tamamlanırsa, hareket, hareket kapsam içinde önceki toplu iş iş işlemleri tarafından yapılan ve etkilenen veri önceki durumuna geri yükleme geri alma değişiklikleri geri.

Geleneksel sql veri erişimi, temel ağ bağlantısı üzerine işlenen ve yürütülen tüm toplu multibatched hareket olarak hizmet vermek üzere dayanıyordu.Örneğin, arasındaki ilişkiyi örneği olarak aşağıdakileri dikkate alın bir SQL Server bağlantı ve üç farklı hareketleri:

SQL connection(1)
     --> SQL batch(1)
          --> transaction(1)
     --> SQL batch(2)
          --> transaction(2a)
     --> SQL batch(3)
          --> transaction(2b), transaction(3)

Not Bu hareketleri (1) ve (3) yürütmek bulunan ve içinde; aynı toplu iş iş kaydedilmiş Ancak, hareket (2) toplu işlemleri boyunca uzanır (2) ve (3).Temel alınan bağlantı hareket gerekli sırayla tüm toplu işleri yürütür sağlamak içerik sağlar.http soap erişimle, tek bir alt ağ bağlantı bağlamında varsayılarak işlem gerçekleştirilemez.Bu nedenle, işleme multibatched hareketleri desteklemek için tek bir soap oturum aynı amaca hizmet eder.Örneğin, aşağıdaki kod nasıl toplu işlemleri ve hareketlerinin aynı desen http soap altında yürütmek erişimi gösterir.

SOAP session(1)
     --> SQL batch(1)
          --> transaction(1)
     --> SQL batch(2)
          --> transaction(2a)
     --> SQL batch(3)
          --> transaction(2b), transaction(3)

Uzun aynı soap oturum (1) kalır etkin, her toplu iş kullanarak olarak ayrı soap istek/yanıt iletisi çiftler çalıştırılabilirtemel bir bağlam.

soap tabanlı işlemleri sql Server tarafından yönetilen nasıl

sql işlemleri başlatılan adresindeki örnek, SQL Server bir hareket durumu değişikliği oluştuğunda.Bunun nedeni sunucu istemci bir soap isteği işleme nedeniyle oluşan aşağıdaki olaylardan herhangi biri:

  • Hareket başlar

  • Hareketi tamamlamak

  • Geri alma hareketi

  • dtc içinde hareket listeleme

  • dtc hatası hareketten

Varsayılan olarak, sunucu çalışır autocommit hareket mod.Bu davranış, oldukça basit bir bire bir, toplu iş iş hareket oranı varsayar ve işlem bilgileri (üstbilgiler, tanımlayıcılar) için iade istemci.

Autocommit hareket modu işlemleri için yeterli olabilir (1) ve (3) önceki bir örnek.Ancak, hareket (2) Bu örnekte birden fazla toplu iş gerekli ve bu nedenle duyar el ile yönetme hareket.

Hareketleri el ile yönetme

El ile hareket verdiğimiz taahhütler ve geri alma yönetmek için soap istemci gerekir küme sqloptions:environmentChangeNotification soap oturum başlatmadan önce ve o üstbilgisi içinde seçeneği küme değeri, transactionBoundary öznitelik için true, aşağıdaki örnek soap isteği iletisi örnekte gösterildiği gibi:

<SOAP-ENV:Envelope  xmlns:SOAP-ENV="https://schemas.xmlsoap.org/soap/envelope/"
              xmlns:sql="https://schemas.microsoft.com/sqlserver/2004/SOAP"
              xmlns:xsi="http://www.w3.org/2004/XMLSchema-instance"
              xmlns:sqlparam="https://schemas.microsoft.com/sqlserver/2004/sqltypes/SqlParameter"
              xmlns:sqlsoaptypes="https://schemas.microsoft.com/sqlserver/2004/sqltypes"
              xmlns:sqloptions="https://schemas.microsoft.com/sqlserver/2004/SOAP/Options">
  <SOAP-ENV:Header>
    <sqloptions:environmentChangeNotifications transactionBoundary="true" />
    <sqloptions:sqlSession initiate="true" timeout="60"/>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <sql:sqlbatch>
      <sql:BatchCommands>
        USE master
        BEGIN TRANSACTION
        CREATE TABLE session_table (col1 int);
      </sql:BatchCommands>
    </sql:sqlbatch>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Bu autocommit hareket modu için geçerli oturum için devre dışı bırakmak için sunucuya bildirir.Sunucu daha sonra soap yanıtı oturum tanımlanmıştır aşağıdakine benzer gönderecektir (jGqn3/X73EGHjFxZ12zovw==) ve bir SqlTransaction değer bir sunucu ve bir işlem tanımlayıcısı BEGIN TRANSACTION olay doğrulayan döndürülür (AQAAADMAAAA=) bir parçası aynı hareketi. sonraki soap istekleri kullanmak üzere istemci için

<SOAP-ENV:Envelope xml:space="preserve"
                   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                   xmlns:SOAP-ENV="https://schemas.xmlsoap.org/soap/envelope/"
                   xmlns:sql="https://schemas.microsoft.com/sqlserver/2004/SOAP"
                   xmlns:sqlsoaptypes="https://schemas.microsoft.com/sqlserver/2004/SOAP/types"
                   xmlns:sqlrowcount="https://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlRowCount"                    xmlns:sqlmessage="https://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlMessage"                    xmlns:sqlresultstream="https://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlResultStream"                    xmlns:sqltransaction="https://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlTransaction"                    xmlns:sqltypes="https://schemas.microsoft.com/sqlserver/2004/sqltypes">
  <SOAP-ENV:Header xmlns:sqloptions="https://schemas.microsoft.com/sqlserver/2004/SOAP/Options">
    <sqloptions:sqlSession sessionId="jGqn3/X73EGHjFxZ12zovw==" timeout="1200">
    </sqloptions:sqlSession>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <sql:sqlbatchResponse>
       <sql:sqlbatchResult>
          <sqlresultstream:SqlTransaction xsi:type="sqltransaction:SqlTransaction">
             <sqltransaction:Descriptor>AQAAADMAAAA=</sqltransaction:Descriptor>
             <sqltransaction:Type>Begin</sqltransaction:Type>
          </sqlresultstream:SqlTransaction>
       </sql:sqlbatchResult>
    </sql:sqlbatchResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

istemci daha sonra el ile yapabilmesi birleştirmek aynı oturum kimliği ve önceki yanıtında sunucunun işlem tanımlayıcısını kullanarak hareket sonraki SOAP istekleri.Bu, aşağıdaki örnekte gösterilmiştir.

<SOAP-ENV:Envelope  xmlns:SOAP-ENV="https://schemas.xmlsoap.org/soap/envelope/"
                    xmlns:sql="https://schemas.microsoft.com/sqlserver/2004/SOAP"
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xmlns:sqlparam="https://schemas.microsoft.com/sqlserver/2004/sqltypes/SqlParameter"
                    xmlns:sqlsoaptypes="https://schemas.microsoft.com/sqlserver/2004/sqltypes"
                    xmlns:sqloptions="https://schemas.microsoft.com/sqlserver/2004/SOAP/Options">
  <SOAP-ENV:Header>
    <sqloptions:sqlSession sessionId="jGqn3/X73EGHjFxZ12zovw==" transactionDescriptor="AQAAADMAAAA="/>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <sql:sqlbatch>
      <sql:BatchCommands>
        INSERT INTO session_table values (2005)
        COMMIT TRANSACTION
      </sql:BatchCommands>
    </sql:sqlbatch>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

soap isteği açıkça olabilir birleştirmek toplu altında hareket başlatılmışsa aynı soap oturum içinde yürütülüyorsa, bir hareket.Aksi takdirde, aşağıdaki koşullardan biri doğruysa, bir soap hatası döndürdü:

  • Farklı bir soap oturum kimliği belirtildi.

  • soap oturum kimliği belirtilmemiş.

  • İşlem tanımlayıcısı geçerli bir soap oturum için geçerli değil.

Tek bir hareket bir saat 'de kullanılan transactionDescriptor için öznitelik sqlSession üstbilgileri.Aynı oturum içinde birden çok bağımsız hareketler oluşturmak için oturum sırasında kullanarak listeleme sqlSession belirtmeden başlığı transactionDescriptor öznitelik.Bu yaklaşım istemci uygulaması farklı izlemek emin olduğunu varsaydığını unutmayın transactionDescriptor değerler.Aynı oturum içinde birden çok bağımsız hareket etkin olduğunda bir hareket katılma içinde fark yoktur, yalnızca belirttiğiniz transactionDescriptor üzerindeki öznitelik sqlSession soap istek başlığı.

Not

To determine the level of nested transactions that are active, you can read and use the value of the Transact-SQL @@TRANCOUNT function.

SqlTransaction xsd şeması

Aşağıdaki xsd şeması olan sqlTransaction soap iletilerini kullanılan başlığı:

<xsd:schema
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    attributeFormDefault="qualified"
    elementFormDefault="qualified"
    targetNamespace="https://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlTransaction">
<xsd:annotation><xsd:documentation xml:lang="en">&#xd;&#xa;(c) Copyright 2004, Microsoft Corporation&#xd;&#xa;&#xd;&#xa;The following schema for Microsoft SQL Server is presented in XML format and is for informational purposes only. Microsoft Corporation ("Microsoft") may have trademarks, copyrights, or other intellectual property rights covering subject matter in the schema.&#xd;&#xa;&#xd;&#xa;Microsoft does not make any representation or warranty regarding the schema or any product or item developed based on the schema. The schema is provided to you on an AS IS basis.  Microsoft disclaims all express, implied and statutory warranties, including but not limited to the implied warranties of merchantability, fitness for a particular purpose, and freedom from infringement. Without limiting the generality of the foregoing, Microsoft does not make any warranty of any kind that any item developed based on the schema, or any portion of the schema, will not infringe any copyright, patent, trade secret, or other intellectual property right of any person or entity in any country. It is your responsibility to seek licenses for such intellectual property rights where appropriate.&#xd;&#xa;&#xd;&#xa;MICROSOFT SHALL NOT BE LIABLE FOR ANY DAMAGES OF ANY KIND ARISING OUT OF OR IN CONNECTION WITH THE USE OF THE SCHEMA, INCLUDING WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL (INCLUDING ANY LOST PROFITS), PUNITIVE OR SPECIAL DAMAGES, WHETHER OR NOT MICROSOFT HAS BEEN ADVISED OF SUCH DAMAGES.&#xd;&#xa;</xsd:documentation></xsd:annotation>
  <xsd:complexType name="SqlTransaction">
    <xsd:sequence minOccurs="1" maxOccurs="1">
      <xsd:element name="Descriptor" type="xsd:base64Binary" />
      <xsd:element name="Type">
         <xsd:simpleType>
            <xsd:restriction base="xsd:string">
              <xsd:enumeration value="Begin"/>
              <xsd:enumeration value="Commit"/>
              <xsd:enumeration value="Rollback"/>
              <xsd:enumeration value="EnlistDTC"/>
              <xsd:enumeration value="Defect"/>
            </xsd:restriction>
         </xsd:simpleType>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>
</xsd:schema>

sql işlem XSI türüdür xsi:type="typesNs:SqlTransaction", nerede typesNs bağlı https://schemas.microsoft.com/sqlserver/2004/SOAP/types/SqlTransaction ad.