共用方式為


sqloptions:notificationRequest 標頭元素

未來的 Microsoft SQL Server 版本將移除這項功能。請避免在新的開發工作中使用這項功能,並規劃修改目前使用這項功能的應用程式。

sqloptions:notificationRequest 選項可讓用戶端指定要為要求觸發的查詢通知,例如:

<SOAP-ENV:Header
  xmlns:SOAP-ENV="https://schemas.xmlsoap.org/soap/envelope/"
  xmlns:sqloptions="https://schemas.microsoft.com/sqlserver/2004/SOAP/Options">
    <sqloptions:notificationRequest           SOAP-ENV:mustUnderstand="1"          timeout="timeout value in seconds"           deliveryService="name of delivery service" />

</SOAP-ENV:Header>

sqloptions:notificationRequest 選項會以 SOAP 標頭出現。標頭是由一個名為 sqloptions:notificationRequest 的元素所組成。此元素具有兩個強制的屬性,即 notificationId 與 deliveryService,,以及一個選擇性屬性 timeout。notificationId 與 deliveryService 兩個都是文字值,而 timeout 則是 xsd:integer 值。如需如何使用 sqloptions:notificationRequest 選項來查詢通知的詳細資訊,請參閱<使用 SOAP 標頭訂閱查詢通知>。

sqloptions:notificationRequest 選項只能有一個執行個體可以出現在要求中。此選項無法出現在回應中。該選項若有多個執行個體將會產生錯誤。

下列是 sqloptions:notificationRequest 選項的結構描述片段:

<xs:element name="notificationRequest" form="qualified">
    <xs:annotation>
        <xs:documentation>
            Requests query notifications for the request.
        </xs:documentation>
    </xs:annotation>
    <xs:complexType>
        <xs:attribute
          use="required"
          name="notificationId"
          type="xs:string"
          form="unqualified">
            <xs:annotation>
                <xs:documentation>
                    The notification identifier.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute
          use="required"
          name="deliveryService"
          type="xs:string"
          form="unqualified">
            <xs:annotation>
                <xs:documentation>
                    The deliveryService.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="timeout" type="xs:integer" form="unqualified">
            <xs:annotation>
                <xs:documentation>
                    The timeout value.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>
</xs:element>

在指定標頭時,將會要求查詢通知的訂閱。如需詳細資訊,請參閱<使用查詢通知>。

範例

下列是使用 sqloptions:notificationRequest 標頭來搭配 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:notificationRequest notificationId="notification"
                                    timeout="1"
                                    deliveryService="deliveryService" >
    </sqloptions:notificationRequest>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <sql:sqlbatch>
      <sql:BatchCommands></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>
      </sql:sqlbatchResult>
    </sql:sqlbatchResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

請參閱

參考