sqloptions:clientNetworkID 标头元素
后续版本的 Microsoft SQL Server 将删除该功能。 请避免在新的开发工作中使用该功能,并着手修改当前还在使用该功能的应用程序。
sqloptions:clientNetworkID 登录选项允许客户端指定用于登录的客户端网络 ID,例如:
<SOAP-ENV:Header
xmlns:SOAP-ENV="https://schemas.xmlsoap.org/soap/envelope/"
xmlns:sqloptions="https://schemas.microsoft.com/sqlserver/2004/SOAP/Options">
<sqloptions:clientNetworkID SOAP-ENV:mustUnderstand="1" value="networkID" />
</SOAP-ENV:Header>
sqloptions:clientNetworkID 登录选项显示为 SOAP 标头。它由一个名为 sqloptions:clientNetworkID 的元素组成。该元素有一个属性 (value),它是一个 base64 编码的二进制值。它提供了可为登录设置的客户端网络 ID。它显示在 sys.sysprocesses 兼容视图的 net_address 列中。
一个请求中只能出现 sqloptions:clientNetworkID 选项的一个实例。此标头不能出现在响应中。多个选项实例将会生成错误。
服务器可能限制 sqloptions:clientNetworkID 值的可识别值的范围。如果客户端提交的值超出了允许的范围,则服务器将自行截断该值,截断方式不定。
如果使用 SOAP 会话,则必须在与 sqloptions:sqlsession initiate 属性相同的请求中显示此选项。如果在任何带有 sqloptions:sqlSession 标头但不包含 initiate 属性的请求中显示此选项,则将生成错误。
下面是 sqloptions:clientNetworkID 选项的架构片断:
<xs:element name="clientNetworkID" form="qualified">
<xs:annotation>
<xs:documentation>
Set the client network ID for the login.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute
use="required"
name="value"
type="xs:base64Binary"
form="unqualified">
<xs:annotation>
<xs:documentation>
The client network ID to set for the login.
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
示例
以下是在 SOAP 请求和响应消息中使用 sqloptions:clientNetworkID 标头的示例。
请求
<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:clientNetworkID SOAP-ENV:mustUnderstand="1" value="AAAAADreaLE=" />
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<sql:sqlbatch>
<sql:BatchCommands>
SELECT TOP 1 net_address FROM sysprocesses WHERE spid=@@spid
</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>
<net_address>value specified in the request</net_address>
</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>