事务协议版本 1.0

Windows Communication Foundation(WCF)的第一个版本实现了 WS-Atomic 事务和 WS-Coordination 协议的 1.0 版本。 有关版本 1.1 的详细信息,请参阅 事务协议

规范/文档 链接
WS-Coordination http://specs.xmlsoap.org/ws/2004/10/wscoor/wscoor.pdf
WS-AtomicTransaction http://specs.xmlsoap.org/ws/2004/10/wsat/wsat.pdf

这些协议规范的互作性需要两个级别:应用程序和事务管理器之间(请参阅下图)。 规范详细介绍了两种互作性级别的消息格式和消息交换。 应用程序到应用程序交换的某些安全性、可靠性和编码与常规应用程序交换一样适用。 但是,事务管理器之间的成功互作性需要就特定绑定达成协议,因为它通常不是由用户配置的。

本主题介绍具有安全性的 WS-Atomic Transaction (WS-AT) 规范的组合,并介绍了用于事务管理器之间通信的安全绑定。 本文档中介绍的方法已成功测试 WS-AT 和 WS-Coordination 的其他实现,包括 IBM、IONA、Sun Microsystems 等。

下图描述了两个事务管理器、事务管理器 1 和 Transaction Manager 2 之间的互作性,以及两个应用程序(应用程序 1 和应用程序 2):

显示事务管理器之间的交互的屏幕截图。

假设一个典型的 WS-Coordination/WS-Atomic Transaction 方案具有一个发起方 (I) 和一个参与者 (P)。 发起方和参与者都有事务管理器(ITM 和 PTM)。 两阶段提交在本主题中称为 2PC。

  1. CreateCoordinationContext
  2. CreateCoordinationContextResponse
  3. 注册(完成)
  4. RegisterResponse
  5. 应用程序消息
  6. 使用上下文的 CreateCoordinationContext
  7. 注册(持久)
  8. RegisterResponse
  9. CreateCoordinationContextResponse
  10. 注册(持久)
  11. RegisterResponse
  12. 应用程序消息响应
  13. 提交(完成)
  14. 准备 (2PC)
  15. 准备 (2PC)
  16. 已准备 (2PC)
  17. 已准备 (2PC)
  18. 已提交(完成)
  19. 提交 (2PC)
  20. 提交 (2PC)
  21. 已提交 (2PC)
  22. 已提交 (2PC)

本文档介绍具有安全性的 WS-AtomicTransaction 规范的组合,并介绍了用于事务管理器之间通信的安全绑定。 本文档中介绍的方法已经使用 WS-AT 和 WS-Coordination 的其他实现成功进行了测试。

图和表从安全性的角度说明了四类消息:

  • 激活消息(CreateCoordinationContext 和 CreateCoordinationContextResponse)。

  • 注册消息(Register 和 RegisterResponse)

  • 协议消息(Prepare、Rollback、Commit、Aborted 等)。

  • 应用程序消息。

前三个消息类被视为 Transaction Manager 消息,其绑定配置将在本主题后面的“应用程序消息交换”中介绍。 第四类消息是应用程序消息的应用程序,本主题后面的“消息示例”部分对此进行介绍。 本部分介绍 WCF 用于其中每个类的协议绑定。

本文档中使用以下 XML 命名空间和关联的前缀。

前缀 命名空间 URI
s11 http://schemas.xmlsoap.org/soap/envelope
wsa http://www.w3.org/2004/08/addressing
wscoor http://schemas.xmlsoap.org/ws/2004/10/wscoor
wsat http://schemas.xmlsoap.org/ws/2004/10/wsat
t http://schemas.xmlsoap.org/ws/2005/02/trust
o http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd
xsd http://www.w3.org/2001/XMLSchema

事务管理器绑定

R1001:事务管理器必须使用 SOAP 1.1 和 WS-Addressing 2004/08 进行 WS-Atomic 事务和 WS-Coordination 消息交换。

应用程序消息不受这些绑定的约束,稍后将进行说明。

事务管理器 HTTPS 绑定

事务管理器 HTTPS 绑定仅依赖于传输安全性来实现安全性,并在事务树中的每个发送方-接收方对之间建立信任。

HTTPS 传输配置

X.509 证书用于建立事务管理器标识。 需要客户端/服务器身份验证,客户端/服务器授权将保留为实现详细信息:

  • R1111:通过网络传输的 X.509 证书必须具有与发出计算机的完全限定域名(FQDN)匹配的主题名称。

  • B1112:系统中的每个发送方-接收方对之间的 DNS 必须正常工作,才能成功进行 X.509 使用者名称检查。

激活和注册绑定配置

WCF 要求具有通过 HTTPS 关联的请求/答复双工绑定。 (有关请求/回复消息交换模式中的关联性和描述的详细信息,请参阅 WS-Atomic 事务第 8 节。)

2PC 协议绑定配置

WCF 通过 HTTPS 支持单向(数据报)消息。 消息中的关联作为实现详细信息保留。

B2131:实现必须支持 WS-Addressing 中所述的 wsa:ReferenceParameters 以实现 WCF 的 2PC 消息的关联。

事务管理器混合安全绑定

这是一种替代(混合模式)绑定,它结合了传输安全与 WS-Coordination 颁发的令牌模型,用于身份建立。 激活和注册是两个绑定之间唯一不同的元素。

HTTPS 传输配置

X.509 证书用于建立事务管理器标识。 需要客户端/服务器身份验证,客户端/服务器授权将保留为实现详细信息。

激活消息绑定配置

激活消息通常不参与互作性,因为它们通常发生在应用程序与其本地事务管理器之间。

B1221:WCF 使用双向 HTTPS 绑定(在 消息协议中介绍)用于激活时的消息。 请求消息和答复消息是使用 WS-Addressing 2004/08 进行关联的。

WS-Atomic 事务规范第 8 节介绍了有关关联和消息交换模式的更多详细信息。

  • R1222:接收到 CreateCoordinationContext 后,协调程序必须颁发与机密 SecurityContextToken 关联的 STx。 在遵循 WS-Trust 规范的 t:IssuedTokens 标头中返回此令牌。

  • R1223:如果激活出现在现有的协调上下文中,则具有与现有上下文关联的 t:IssuedTokensSecurityContextToken 标头必须对 CreateCoordinationContext 消息进行流处理。

应生成新的t:IssuedTokens标头以附加到传出的wscoor:CreateCoordinationContextResponse消息。

注册消息绑定配置

B1231:WCF 使用双工 HTTPS 绑定(如消息传送协议中所述)。 请求消息和答复消息是使用 WS-Addressing 2004/08 进行关联的。

WS-AtomicTransaction 第 8 节更详尽地说明了关联和消息交换模式。

R1232:传出wscoor:Register消息必须使用IssuedTokenOverTransport安全协议中所述的身份验证模式。

wsse:Timestamp 元素必须使用 SecurityContextToken STx 颁发的令牌进行签名。 此签名是与特定事务关联的令牌的所有权证明,用于对在事务中登记的参与者进行身份验证。 RegistrationResponse 消息通过 HTTPS 发送回。

2PC 协议绑定配置

WCF 通过 HTTPS 支持单向(数据报)消息。 消息中的关联作为实现详细信息保留。

B2131:实现必须支持 WS-Addressing 中所述的 wsa:ReferenceParameters 以实现 WCF 的 2PC 消息的关联。

应用程序消息交换

只要绑定满足以下安全要求,应用程序可以自由地对应用程序到应用程序消息使用任何特定的绑定:

  • R2001:应用程序间消息必须对 t:IssuedTokens 标头与消息头中的 CoordinationContext 一起进行流处理。

  • R2002:必须提供t:IssuedToken的完整性和保密性。

CoordinationContext 标头包含 wscoor:Identifier。 虽然定义xsd:AnyURI允许同时使用绝对 URI 和相对 URI,但 WCF 仅支持wscoor:Identifiers,即只支持绝对 URI。

如果 wscoor:Identifierwscoor:CoordinationContext 是相对 URI,则将从事务性 WCF 服务返回错误。

消息示例

CreateCoordinationContext 请求/响应消息

以下消息遵循请求/响应模式。

CreateCoordinationContext

<s:Envelope>  
  <s:Header>  
    <a:Action>http://.../ws/2004/10/wscoor/CreateCoordinationContext</Action>  
    <a:MessageID>urn:uuid:069f5104-fd88-4264-9f99-60032a82854e</MessageID>  
    <a:ReplyTo>  
      <Address>https://...</a:Address>  
    </a:ReplyTo>  
    <a:To>https://...</a:To>  
    <wsse:Security>  
      <u:Timestamp>  
        <wsu:Created>2005-12-15T23:36:09.921Z</wsu:Created>  
        <wsu:Expires>2005-12-15T23:41:09.921Z</wsu:Expires>  
      </u:Timestamp>  
    </wsse:Security>  
  </s:Header>  
  <s:Body xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">  
    <wscoor:CreateCoordinationContext>  
      <wscoor:CoordinationType>...</wscoor:CoordinationType>  
    </wscoor:CreateCoordinationContext>  
  </s:Body>  
</s:Envelope>  

CreateCoordinationContextResponse

<s:Envelope>  
  <!-- Data below is shown in the clear for  
       illustration purposes only. -->  
  <s:Header>  
    <a:Action>./ws/2004/10/wscoor/CreateCoordinationContextResponse </a:Action>  
    <a:RelatesTo>urn:uuid:069f5104-fd88-4264-9f99-60032a82854e</a:RelatesTo>  
    <a:To s:mustUnderstand="1">https://... </a:To>  
    <t:IssuedTokens>  
 <wst:RequestSecurityTokenResponse
    xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"  
    xmlns:wssu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
    xmlns:wst="http://schemas.xmlsoap.org/ws/2005/02/trust"  
    xmlns:wsc="http://schemas.xmlsoap.org/ws/2005/02/sc"  
    xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">  
    <wst:TokenType>http://schemas.xmlsoap.org/ws/2005/02/sc/sct</wst:TokenType>  
    <wst:RequestedSecurityToken>  
      <wsc:SecurityContextToken>  
        <wssu:Identifier>  
          http://fabrikam123.com/SCTi  
        </wssu:Identifier>  
      </wsc:SecurityContextToken>
    </wst:RequestedSecurityToken>  
    <wsp:AppliesTo>  
        http://fabrikam123.com/CCi  
    </wsp:AppliesTo>
    <wst:RequestedAttachedReference>  
      <wsse:SecurityTokenReference >  
        <wsse:Reference
           ValueType="http://schemas.xmlsoap.org/ws/2005/02/sc/sct"  
           URI="http://fabrikam123.com/SCTi"/>  
      </wsse:SecurityTokenReference>  
    </wst:RequestedAttachedReference>  
    <wst:RequestedUnattachedReference>  
      <wsse:SecurityTokenReference>  
        <wsse:Reference
          ValueType="http://schemas.xmlsoap.org/ws/2005/02/sc/sct"  
          URI="http://fabrikam123.com/SCTi"/>  
      </wsse:SecurityTokenReference>  
    </wst:RequestedUnattachedReference>  
    <wst:RequestedProofToken>  
      <wst:BinarySecret
        Type="http://schemas.xmlsoap.org/ws/2005/02/trust/SymmetricKey">  
        <!-- base64 encoded value -->  
      </wst:BinarySecret>  
    </wst:RequestedProofToken>  
    <wst:Lifetime>  
      <wssu:Created>2005-10-24T20:19:26.526Z</wssu:Created>  
      <wssu:Expires>2005-10-25T06:24:26.526Z</wssu:Expires>  
    </wst:Lifetime>  
    <wst:KeySize>256</wst:KeySize>  
</wst:RequestSecurityTokenResponse>  
    </t:IssuedTokens>  
    <o:Security xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">  
      <u:Timestamp u:Id="_0">  
        <u:Created>2005-12-15T23:36:12.015Z</u:Created>  
        <u:Expires>2005-12-15T23:41:12.015Z</u:Expires>  
      </u:Timestamp>  
    </o:Security>  
  </s:Header>  
  <s:Body>  
    <wscoor:CreateCoordinationContextResponse>  
      <wscoor:CoordinationContext>  
        <wscoor:Identifier>  
     http://fabrikam123.com/CCi  
      </wscoor:Identifier>  
        <wscoor:Expires>...</wscoor:Expires>  
        <wscoor:CoordinationType>...</wscoor:CoordinationType>  
        <wscoor:RegistrationService>  
          <a:Address>https://...</a:Address>  
          <a:ReferenceParameters>  
             ...  
          </a:ReferenceParameters>  
        </wscoor:RegistrationService>  
      </wscoor:CoordinationContext>  
    </wscoor:CreateCoordinationContextResponse>  
  </s:Body>  
</s:Envelope>  

注册通知

以下消息是注册消息。

注册

<s:Envelope>  
  <s:Header>  
    <a:Action>http://schemas.xmlsoap.org/ws/2004/10/wscoor/Register</a:Action>  
    <a:MessageID>urn:uuid:ed418b86-a75e-4aea-9d4e-a5d0cb5c088e</a:MessageID>  
    <a:ReplyTo>  
      <a:Address>https://...</a:Address>
    </a:ReplyTo>  
    <a:To>https://...</a:To>  
    <wsse:Security
      s:mustUnderstand="1"
      xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"  
      xmlns:wssu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">  
      <wssu:Timestamp wssu:Id="_0" >  
        <wssu:Created>2005-12-15T23:36:13.827Z</wssu:Created>  
        <wssu:Expires>2005-12-15T23:41:13.827Z</wssu:Expires>  
      </wssu:Timestamp>  
      <wsc:SecurityContextToken>  
      <wssu:Identifier>  
          http://fabrikam123.com/SCTi  
      </wssu:Identifier>  
      </wsc:SecurityContextToken>  
      <!-- supporting signature over the timestamp -->  
      <wsse:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">  
        <ds:SignedInfo>  
          <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>  
          <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#hmac-sha1"/>  
          <ds:Reference URI="#_0">  
            <ds:Transforms>  
              <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>  
            </ds:Transforms>  
            <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>  
            <ds:DigestValue>  
              alRzyhjLgoUOYoh8cx4n75eTcUk=  
            </ds:DigestValue>  
          </ds:Reference>  
        </ds:SignedInfo>  
        <ds:SignatureValue>YZYjnVvSOVasAQqQxaaviTSWtqI=</ds:SignatureValue>  
        <ds:KeyInfo>  
          <wsse:SecurityTokenReference  
            xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">  
            <wsse:Reference
              URI="http://fabrikam123.com/SCTi"/>  
          </wsse:SecurityTokenReference>  
        </ds:KeyInfo>  
      </wsse:Signature>  
    </wsse:Security>  
  </s:Header>  
  <s:Body xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">  
    <wscoor:Register>  
      <wscoor:ProtocolIdentifier>...</wscoor:ProtocolIdentifier>  
      <wscoor:ParticipantProtocolService>  
        <a:Address>https://... </a:Address>  
      </wscoor:ParticipantProtocolService>  
    </wscoor:Register>  
  </s:Body>  
</s:Envelope>  

注册响应

<s:Envelope>  
  <s:Header>  
    <a:Action>  
      http://schemas.xmlsoap.org/ws/2004/10/wscoor/RegisterResponse  
    </a:Action>  
    <a:MessageID>urn:uuid:ed418b86-a75e-4aea-9d4e-a5d0cb5c088d</a:MessageID>  
    <a:RelatesTo>  
      urn:uuid:ed418b86-a75e-4aea-9d4e-a5d0cb5c088e
    </a:RelatesTo>  
    <a:To>https://...</a:To>  
    <wsse:Security
      s:mustUnderstand="1"
      xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"  
      xmlns:wssu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">  
      <wssu:Timestamp>  
        <wssu:Created>2005-12-15T23:36:13.827Z</wssu:Created>  
        <wssu:Expires>2005-12-15T23:41:13.827Z</wssu:Expires>  
      </wssu:Timestamp>  
    </wsse:Security>  
  </s:Header>  
  <s:Body xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">  
    <wscoor:RegisterResponse>  
      <wscoor:CoordinatorProtocolService>  
        <a:Address>https://...</a:Address>  
        <a:ReferenceParameters>  
          ...  
        </a:ReferenceParameters>  
      </wscoor:CoordinatorProtocolService>  
    </wscoor:RegisterResponse>  
  </s:Body>  
</s:Envelope>  

两阶段提交协议消息

以下消息与两阶段提交 (2PC) 协议相关。

提交

<s:Envelope>  
  <s:Header>  
    <a:Action>http://.../ws/2004/10/wsat/Commit</a:Action>  
    <a:To>https://...</a:To>  
    <wsse:Security
      s:mustUnderstand="1"
      xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"  
      xmlns:wssu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">  
      <wssu:Timestamp wssu:Id="_0" >  
        <wssu:Created>2005-12-15T23:36:13.827Z</wssu:Created>  
        <wssu:Expires>2005-12-15T23:41:13.827Z</wssu:Expires>  
      </wssu:Timestamp>  
   </wsse:Security>  
  </s:Header>  
  <s:Body xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">  
    <wsat:Commit />  
  </s:Body>  
</s:Envelope>  

应用程序消息

以下消息是应用程序消息。

应用程序消息请求

<s:Envelope>  
  <s:Header>  
<!-- Addressing headers, all signed-->  
    <wsse:Security s:mustUnderstand="1">  
      <wssu:Timestamp wssu:Id="timestamp">
        <wssu:Created>2005-10-25T06:29:18.703Z</wssu:Created>  
        <wssu:Expires>2005-10-25T06:34:18.703Z</wssu:Expires>  
      </wssu:Timestamp>  
      <wsse:BinarySecurityToken
          wssu:Id="IA_Certificate"
          ValueType="...#X509v3"
          EncodingType="...#Base64Binary">  
        <!-- IA certificate -->  
      </wsse:BinarySecurityToken>  
      <e:EncryptedKey Id="encrypted_key">  
            <!-- ephemeral key encrypted for PA certificate -->
        <e:ReferenceList xmlns:e="http://www.w3.org/2001/04/xmlenc#">  
          <e:DataReference URI="#encrypted_body"/>  
          <e:DataReference URI="#encrypted_CCi"/>  
          <e:DataReference URI="#encrypted_issuedtokens"/>  
        </e:ReferenceList>  
      </e:EncryptedKey>  
      <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">  
        <!-- signature over Addressing headers, Timestamp, and Body -->  
      </Signature>  
    </wsse:Security>  
    <wsse11:EncryptedHeader>  
     <!-- encrypted wscoor:CoordinationContext header containing CCi -->  
    </wsse11:EncryptedHeader>  
    <wsse11:EncryptedHeader>
      <!-- encrypted wst:IssuedTokens header containing SCTi -->  
      <!-- wst:IssuedTokens header is taken verbatim from message #2 above, omitted for brevity -->  
    </wsse11:EncryptedHeader>  
  </s:Header>  
  <s:Body wssu:Id="body">  
    <!-- encrypted content of the Body element of the application message -->
    <e:EncryptedData Id="encrypted_body"
           Type="http://www.w3.org/2001/04/xmlenc#Content"
           xmlns:e="http://www.w3.org/2001/04/xmlenc#">  
...  
    </e:EncryptedData>  
  </s:Body>  
</s:Envelope>