sqloptions:clientNetworkID 標頭元素
未來的 Microsoft SQL Server 版本將移除這項功能。請避免在新的開發工作中使用這項功能,並規劃修改目前使用這項功能的應用程式。
sqloptions:clientNetworkID 登入選項可讓用戶端指定用於登入的用戶端網路識別碼,例如:
<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 編碼的二進位值。這提供了針對登入所設定的用戶端網路識別碼。這會出現在 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>
範例
下列是使用 sqloptions:clientNetworkID 標頭來搭配 SOAP 要求與回應訊息的範例。
要求
<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>