sqloptions:clientPID 标头元素

后续版本的 Microsoft SQL Server 将删除该功能。 请避免在新的开发工作中使用该功能,并着手修改当前还在使用该功能的应用程序。

sqloptions:clientPID 登录选项使客户端可以指定登录的客户端进程 ID,例如:

<SOAP-ENV:Header
  xmlns:SOAP-ENV="https://schemas.xmlsoap.org/soap/envelope/"
  xmlns:sqloptions="https://schemas.microsoft.com/sqlserver/2004/SOAP/Options">
    <sqloptions:clientPID          SOAP-ENV:mustUnderstand="1"          value="ID of client process "/>

</SOAP-ENV:Header>

sqloptions:clientPID 登录选项显示为 SOAP 标头。它由一个名为 sqloptions:clientPID 的元素构成。该元素具有一个必需的属性 value。这是一个长整数值(64 位有符号)。value 属性给出为登录设置的客户端进程 ID。显示在 sys.sysprocesses 兼容性视图的 hostprocess 列中。

一个请求中只能有一个 sqloptions:clientPID 选项的实例。此选项不能出现在响应中。多个选项实例将会生成错误。

服务器可能会限制 sqloptions:clientPID 值的可识别值的范围。如果客户端提交的值超出了允许的范围,则服务器将自行截断该值,截断方式不定。

如果使用 SOAP 会话,则必须在与 sqloptions:sqlsession initiate 属性相同的请求中显示此选项。如果此选项与不包含 initiate 属性的 sqloptions:sqlSession 标头同时出现在任何请求中,都会生成错误。

下面是 sqloptions:clientPID 选项的架构片段:

<xs:element name="clientPID" form="qualified">
    <xs:annotation>
        <xs:documentation>
            Set the client process ID for the login.
        </xs:documentation>
    </xs:annotation>
    <xs:complexType>
        <xs:attribute use="required" name="value" type="xs:long" form="unqualified">
            <xs:annotation>
                <xs:documentation>
                    The client process ID to set for the login.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>
</xs:element>

示例

以下是在 SOAP 请求和响应消息中使用 sqloptions:clientPID 标头的示例。

请求

<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/SOAP/types/SqlParameter"
                    xmlns:sqlsoaptypes="https://schemas.microsoft.com/sqlserver/2004/SOAP/types"
                    xmlns:sqloptions="https://schemas.microsoft.com/sqlserver/2004/SOAP/Options">
  <SOAP-ENV:Header>
    <sqloptions:clientPID SOAP-ENV:mustUnderstand="1" value="1234" />
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <sql:sqlbatch>
      <sql:BatchCommands>
        SELECT hostprocess FROM sysprocesses WHERE spid=@@spid AND hostprocess='1234'
      </sql:BatchCommands>
    </sql:sqlbatch>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

响应

<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:Body>
    <sql:sqlbatchResponse>
      <sql:sqlbatchResult>
        <sqlresultstream:SqlRowSet xsi:type="sqlsoaptypes:SqlRowSet">
          <diffgr:diffgram xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
            <SqlRowSet1 xmlns="urn:schemas-microsoft-com:sql:SqlRowSet1">
              <row>
                <hostprocess>1234</hostprocess>
              </row>
            </SqlRowSet1>
          </diffgr:diffgram>
        </sqlresultstream:SqlRowSet>
        <sqlresultstream:SqlRowCount xsi:type="sqlrowcount:SqlRowCount">
          <sqlrowcount:Count>1</sqlrowcount:Count>
        </sqlresultstream:SqlRowCount>
      </sql:sqlbatchResult>
    </sql:sqlbatchResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

请参阅

参考