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