共用方式為


ScanAvailableEvent 元素

必要的 ScanAvailableEvent 元素會通知用戶端,用戶端所訂閱的掃描裝置已準備好掃描作業。

使用方式

<wscn:ScanAvailableEvent>
  child elements
</wscn:ScanAvailableEvent>

屬性

沒有屬性。

子元素

元素
ClientContext
ScanIdentifier

父元素

沒有父元素。

備註

WSD 掃描服務會在使用者選取掃描目的地並在掃描裝置上起始掃描時,將 ScanAvailableEvent 元素傳送至已註冊的用戶端。

客戶端必須使用 WSD 掃描服務建立訂用帳戶,才能接收 ScanAvailableEvent 事件。 用戶端會透過 <wse:Subscribe> 要求作業專案,將要求訊息傳送至掃描服務,以建立訂閱。

訂閱要求包含 ScanDestinations 延伸專案中的一或多個目的地。 掃描服務會在每次傳送 ScanAvailableEvent 通知時,使用這些目的地來篩選成單一用戶端。 此篩選可防止掃描服務在使用者按下掃描按鈕時通知每個用戶端。 擴充元素定義於 WSD 掃描服務命名空間中,然後新增至 <wse:Subscribe> 要求本文。

如果 WSD 掃描服務接受用戶端建立訂閱的要求,服務必須以 <wse:SubscribeResponse> 回應作業元素回應。 訂閱回應包含 DestinationResponses 擴充元素中的一或多個目的地回應,可協助將訂用帳戶連線到接受它的掃描裝置。

wse<:Subscribe><wse:SubscribeResponse> 元素會在規格中說明。

範例

下列程式代碼範例示範用戶端如何訂閱從 WSD 掃描服務接收 ScanAvailableEvent 事件。

<soap:Envelope
    xmlns:soap="https://www.w3.org/2003/05/soap-envelope"
    xmlns:wsa="https://schemas.xmlsoap.org/ws/2004/08/addressing"
    xmlns:wse="https://schemas.xmlsoap.org/ws/2004/08/eventing"
    xmlns:wscn="https://schemas.microsoft.com/windows/2006/01/wdp/scan>
    soap:encodingStyle='https://www.w3.org/2002/12/soap-encoding' >
  <soap:Header>
    <wsa:To>AddressofScannerService</wsa:To>
      <wsa:Action>
         https://schemas.xmlsoap.org/ws/2004/08/eventing/Subscribe
      </wsa:Action>
      <wsa:MessageID>uuid:UniqueMsgId</wsa:MessageID>
      <wsa:ReplyTo>
        <wsa:Address>https://www.example.com/MyEventSink</wsa:Address>
      </wsa:ReplyTo>
  </soap:Header>
  <soap:Body>
    <wse:Subscribe>
      <wse:Delivery>
        <wse:NotifyTo>
          <wsa:Address>
            https://www.example.com/MyEventSink/OnScanAvailableForMe
          </wsa:Address>
        </wse:NotifyTo>
      </wse:Delivery>
      <wse:Expires>P0Y0M0DT30H0M0S</wse:Expires>
      <wse:Filter xmlns:wscn="https://schemas.microsoft.com/windows/2006/01/wdp/scan">
        ScanAvailableEvent
      </wse:Filter>
      <wscn:ScanDestinations>
        <wscn:ScanDestination>
          <wscn:ClientDisplayString>Den Computer</wscn:ClientDisplayString>
          <wscn:ClientContext>App1ScanID2345</wscn:ClientContext>
        </wscn:ScanDestination>
      </wscn:ScanDestinations>
    </wse:Subscribe>
    </soap:Body
</soap:Envelope>

下列程式代碼範例顯示 WSD 掃描服務對客戶端訂用帳戶要求的回應。

<soap:Envelope
    xmlns:soap="https://www.w3.org/2003/05/soap-envelope"
    xmlns:wsa="https://schemas.xmlsoap.org/ws/2004/08/addressing"
    xmlns:wse="https://schemas.xmlsoap.org/ws/2004/08/eventing"
    xmlns:wscn="https://schemas.microsoft.com/windows/2006/01/wdp/scan">
    soap:encodingStyle='https://www.w3.org/2002/12/soap-encoding' >
  <soap:Header>
    <wsa:To>https://schemas.xmlsoap.org/ws/2003/03/addressing/role/anonymous</wsa:To>
    <wsa:Action>
      https://schemas.xmlsoap.org/ws/2004/08/eventing/SubscribeResponse
    </wsa:Action>
    <wsa:MessageID>uuid:UniqueMsgId</wsa:MessageID>
    <wsa:RelatesTo>uuid:MsgIdOfTheSubscribe</wsa:RelatesTo>
  </soap:Header>
  <soap:Body>
    <wse:SubscribeResponse>
        <wse:SubscriptionManager>
             <!-- Elements removed for clarity  -->
        </wse:SubscriptionManager>
        <wse:Expires>P0Y0M0DT30H0M0S</wse:Expires>
        <wscn:DestinationResponses>
          <wscn:DestinationResponse>
            <wscn:ClientContext>App1ScanID2345</wscn:ClientContext>
            <wscn:DestinationToken>Client3478</wscn:DestinationToken>
          </wscn:DestinationResponse>
        </wscn:DestinationResponses>
      </wse:SubscribeResponse>
    </soap:Body
</soap:Envelope>

下列程式代碼範例示範 WSD 掃描服務如何將 ScanAvailableEvent 傳送至用戶端。

<soap:Envelope
  xmlns:soap="https://www.w3.org/2003/05/soap-envelope"
  xmlns:wsa="https://schemas.xmlsoap.org/ws/2004/08/addressing"
  xmlns:wse="https://schemas.xmlsoap.org/ws/2004/08/eventing"
  xmlns:wscn="https://schemas.microsoft.com/windows/2006/01/wdp/scan"
  soap:encodingStyle='https://www.w3.org/2002/12/soap-encoding'>

  <soap:Header>
    <wsa:To>AddressofEventSink</wsa:To>
    <wsa:Action>
      https://schemas.microsoft.com/windows/2006/01/wdp/scan/ScanAvailableEvent
    </wsa:Action>
    <wsa:MessageID>uuid:UniqueMsgId</wsa:MessageID>
  </soap:Header>

  <soap:Body>
    <wscn:ScanAvailableEvent>
      <wscn:ClientContext>App1ScanID2345</wscn:ClientContext>
      <wscn:ScanIdentifier>AnyUniqueIdentifierSuchAsAGUID</wscn:ScanIdentifier>
    </wscn:ScanAvailableEvent>
  </soap:Body
</soap:Envelope>

另請參閱

ClientContext

DestinationResponses

ScanDestinations

ScanIdentifier