用于打印 (WS-Print) 的设备上的 Web 服务

重要

建议使用 Microsoft 的 IPP 收件箱类驱动程序,以及 Print Support Apps (PSA) ,在 Windows 10 和 11 中自定义打印体验,以便进行打印机设备开发。

有关详细信息,请参阅 打印支持应用设计指南

Windows Vista 中引入了用于打印 (WS-Print) 的设备上的 Web 服务,以便为打印和扫描外围设备提供连接协议。

概述

Web 服务技术为描述和共享信息提供了通用框架。 因此,Windows 附带了一组协议,用于在联网设备上使用和控制服务。

有四种 Web 服务规范可用于打印和扫描,以帮助设备制造商充分利用在连接、安装和使用 Windows 设备方面经过改进的客户体验。

WS-Print v1.1

对于 Windows 8, (WSD) 设备上 Web 服务的打印架构已更新到 v1.1。 此版本的架构 (称为 WS-Print v1.1) 已更新,以支持增强的驱动程序配置、更好的墨迹/墨粉颜色表示以及设备型号 ID。

WS-Print v1.2

对于Windows 8.1,WS-Print 包括 WS-Print v1.1 中使用的所有操作和架构元素,但设备上 Web 服务的打印服务定义已更新。 生成的设备上用于打印的新 Web 服务 WS-Print v1.2。

在 WS-Print v1.2 中添加了对新架构元素和新操作的支持。 新架构元素“SupportsWSPrintV12”用于标识对 WS-Print V1.2 的支持。 新操作“SetPrinterElements”使客户端能够在打印机上设置架构元素的值。 例如,客户端可以设置一个名为“InkHeadAlignmentValue”的自定义元素,打印机将使用该元素重新调整喷墨打印头。

为方便起见,此处的下载部分以完整的独立形式提供规范,以及其关联的 Web 服务描述语言 (WSD) 和 XML 架构定义 (XSDs) 。 随附的技术文档许可协议涵盖了这四个基于设备的 Web 服务规范,该协议引用了 Windows 驱动程序开发工具包 (WDK) 。

以下部分提供有关 WS-Print 的各个方面的更多详细信息。

序列图

下面的序列图演示了客户端与打印机之间的交互,以便确定受支持的 WS-Print 命名空间的版本,然后检索扩展的架构元素。

WS-Print v1.1 序列图

下面是支持 WS-Print v1.1 的打印机的交互序列图:

显示有关 ws-print v1.1 支持的客户端打印机交互的序列图,以及打印机说明和配置的后续查询。

如果打印机支持 WS-Print v1.1,则在响应 GetPrinterElements (wprt:PrinterDescription) 客户端查询时,打印机会发送回信息以指示它支持。

打印机确认支持 WS-Print v1.1 后,客户端将发送 GetPrinterElements (wprt11:DriverConfiguration) 查询,打印机将使用请求的驱动程序配置信息进行响应。

WS-Print v1.2 序列图

下面是支持 WS-Print v1.2 的打印机的交互序列图:

显示有关 ws-print v1.2 支持的客户端打印机交互以及打印机说明和配置的后续查询的序列图。

如果打印机支持 WS-Print v1.2,则在响应 GetPrinterElements (wprt:PrinterDescription) 客户端查询时,打印机会发送回信息以指示它支持。

此外,打印机应返回 wprt12:SupportsWSPrintV12,以响应 GetPrinterElements (wprt:PrinterDescription) 调用。 之后,客户端可以调用 SetPrinterElements 操作,以在 WS-Print 设备支持的架构中设置一个或多个数据元素。

打印机确认支持 WS-Print v1.2 后,客户端将发送 GetPrinterElements (wprt12:DriverConfiguration) 查询,打印机将使用请求的驱动程序配置信息进行响应。

命名空间

WS-Print v1.1 命名空间

命名 空间:<https://schemas.microsoft.com/windows/2010/06/wdp/printv11>XML 命名空间定义:xmlns:wprt12="<https://schemas.microsoft.com/windows/2012/10/wdp/printV12>"

WS-Print v1.2 命名空间

命名 空间:<https://schemas.microsoft.com/windows/2012/10/wdp/printV12>XML 命名空间定义:xmlns:wprt11="<https://schemas.microsoft.com/windows/2010/06/wdp/printv11>"

指定 WS-Print 1.1 支持

支持 WS-Print 1.1 元素的打印机必须更新其 PrinterDescription 以包含 wprt11:SupportsWSPrintv11。 如果未指定 wprt11:SupportsWSPrintv11 并将其设置为 true,则 WSDMon 不会从打印机请求任何 WS-Print 1.1 元素。

支持 WS-Print v1.1 的打印设备必须在其 PrinterDescription 中包含以下内容,以便 Windows 查询该命名空间中的其他任何元素。

<soap:Envelope
...
  xmlns:wprt11="https://schemas.microsoft.com/windows/2010/06/wdp/printv11">"
...
  <wprt11:SupportsWSPrintv11>true</wprt11:SupportsWSPrintv11>
...

以下 XML 代码片段派生自 WSD 打印服务规范 v1.0,它显示了上一部分中内容的正确用法。

<soap:Envelope
        xmlns:soap="https://www.w3.org/2003/05/soap-envelope"
        xmlns:wsa="https://schemas.xmlsoap.org/ws/2004/08/addressing"
        xmlns:wprt="https://schemas.microsoft.com/windows/2006/08/wdp/print"
        xmlns:wprt11="https://schemas.microsoft.com/windows/2010/06/wdp/printv11">"
  <soap:Header>
    <wsa:To>https://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
    <wsa:Action>
      https://schemas.microsoft.com/windows/2006/08/wdp/print/GetPrinterElementsResponse
    </wsa:Action>
    <wsa:MessageID>uuid:UniqueMsgId</wsa:MessageID>
    <wsa:RelatesTo>uuid:MsgIdOfTheGetPrinterElementsRequest</wsa:RelatesTo>
  </soap:Header>
  <soap:Body>
    <wprt:GetPrinterElementsResponse>
      <wprt:PrinterElements>
        <wprt:ElementData Name="wprt:PrinterDescription" Valid="true">
          <wprt:PrinterDescription>
            <wprt:ColorSupported>true</wprt:ColorSupported>
            <wprt:DeviceId>MFG:Acme;MDL:PrintMaster 9020</wprt:DeviceId>
            <wprt:MultipleDocumentJobsSupported>true</wprt:MultipleDocumentJobsSupported>
            <wprt:PagesPerMinute>20</wprt:PagesPerMinute>
            <wprt:PagesPerMinuteColor>8</wprt:PagesPerMinuteColor>
            <wprt:PrinterName xml:lang="en-AU, en-CA, en-GB, en-US">
              Accounting Printer in Copy Room 2
            </wprt:PrinterName>
            <wprt:PrinterInfo xml:lang="en-AU, en-CA, en-GB, en-US">
              Printer for use of Accounting only
            </wprt:PrinterInfo>
            <wprt:PrinterLocation xml:lang="en-AU, en-CA, en-GB, en-US">
              LA Campus – Building 3
            </wprt:PrinterLocation>
            <wprt11:SupportsWSPrintv11>true</wprt11:SupportsWSPrintv11>
          </wprt:PrinterDescription>
        </wprt:ElementData>
      </wprt:PrinterElements>
    </wprt:GetPrinterElementsResponse>
  </soap:Body>
</soap:Envelope>

以下 XML 代码片段显示了支持 WS-Print v1.1 的打印设备的架构。

<xs:schema targetNamespace="https://schemas.microsoft.com/windows/2010/06/wdp/printv11"
           xmlns:wprt11="https://schemas.microsoft.com/windows/2010/06/wdp/printv11"
           xmlns:xs="https://www.w3.org/2001/XMLSchema"
           elementFormDefault="qualified">

<xs:annotation>
    <xs:documentation>
        WS-Print Extensions for Driver Configuration and Consumable Definition
        Copyright 2010 Microsoft Corp. All rights reserved
    </xs:documentation>
</xs:annotation>

<xs:annotation>
    <xs:documentation> A Boolean element that denotes support for WS-Print V11 extensions
    </xs:documentation>
</xs:annotation>

<xs:element name="SupportsWSPrintv11" type="xs:boolean"/>

指定 WS-Print 1.2 支持

支持 WS-Print 1.2 元素的打印机必须更新其 PrinterDescription 以包含 wprtV12:SupportsWSPrintV12。 如果未指定 wprtV12:SupportsWSPrintV12 并将其设置为 true,则 WSDMon 不会从打印机请求任何 WS-Print 1.2 元素。

支持 WS-Print v1.2 的打印设备必须在其 PrinterDescription 中包含以下内容,以便 Windows 查询该命名空间中的其他任何元素。

<soap:Envelope
…
    xmlns:wprtV12="https://schemas.microsoft.com/windows/2012/10/wdp/printV12">
…
    <wprtV12:SupportsWSPrintV12>true</wprtV12:SupportsWSPrintV12>
…
</soap:Envelope>

以下 XML 代码片段派生自 WSD 打印服务规范 v1.2,它显示了上一部分中内容的正确用法。

<soap:Envelope
     xmlns:soap="https://www.w3.org/2003/05/soap-envelope"
     xmlns:wsa="https://schemas.xmlsoap.org/ws/2004/08/addressing"
     xmlns:wprt="https://schemas.microsoft.com/windows/2006/08/wdp/print"
     xmlns:wprtV12="https://schemas.microsoft.com/windows/2012/10/wdp/printV12">
     <soap:Header>
          <wsa:To>https://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
          <wsa:Action>
               https://schemas.microsoft.com/windows/2006/08/wdp/print/GetPrinterElementsResponse
          </wsa:Action>
          <wsa:MessageID>uuid:UniqueMsgId</wsa:MessageID>
          <wsa:RelatesTo>uuid:MsgIdOfTheGetPrinterElementsRequest</wsa:RelatesTo>
     </soap:Header>
     <soap:Body>
         <wprt:GetPrinterElementsResponse>
            <wprt:PrinterElements>
             <wprt:ElementData Name="wprt:PrinterDescription" Valid="true">
                <wprt:PrinterDescription>
                     <wprt:ColorSupported>true</wprt:ColorSupported>
                         <wprt:DeviceId>MFG:Acme;MDL:PrintMaster 9020</wprt:DeviceId>
                         <wprt:MultipleDocumentJobsSupported>true</wprt:MultipleDocumentJobsSupported>
                     <wprt:PagesPerMinute>20</wprt:PagesPerMinute>
                     <wprt:PagesPerMinuteColor>8</wprt:PagesPerMinuteColor>
                     <wprt:PrinterName xml:lang="en-AU, en-CA, en-GB, en-US">
                             Accounting Printer in Copy Room 2</wprt:PrinterName>
                         <wprt:PrinterInfo xml:lang="en-AU, en-CA, en-GB, en-US">
                             Printer for use of Accounting only</wprt:PrinterInfo>
                         <wprt:PrinterLocation xml:lang="en-AU, en-CA, en-GB, en-US">
                             LA Campus – Building 3</wprt:PrinterLocation>
                         <wprtV12:SupportsWSPrintV12>true</wprtV12:SupportsWSPrintV12>
                    </wprt:PrinterDescription>
             </wprt:ElementData>
            </wprt:PrinterElements>
         </wprt:GetPrinterElementsResponse>
      </soap:Body>
</soap:Envelope>

以下三个部分中的架构示例演示如何使用 WS-Print V1.1 中引入的一些新元素。 有关随 WS-Print V1.1 命名空间引入的所有元素的详细信息,请参阅下面的 下载 部分中列出的 WS-Print v1.0 – v1.2 的支持文件。

增强的驱动程序配置

此架构为此设备提供特定于设备的 GPD 或 PPD 配置文件。

   <xs:annotation>
        <xs:documentation>Driver Configuration File definition</xs:documentation>
    </xs:annotation>
    <xs:element name="DriverConfiguration" type="wprt11:DriverConfigurationType"/>
    <xs:complexType name="DriverConfigurationType">
        <xs:sequence>
            <xs:element name="GPDConfigFile" type="xs:string" minOccurs="0" />
            <xs:element name="PPDConfigFile" type="xs:string" minOccurs="0" />
            <xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:anyAttribute namespace="##other" processContents="lax" />
    </xs:complexType>

设备型号 ID

以下架构描述了设备的 ModelID,用于设备元数据检索。 有关 ModelID 的详细信息,请参阅 ModelID 元素

    <xs:annotation>
        <xs:documentation> Print Device Model Id value for device differentiation</xs:documentation>
        <xs:documentation> Always represented as a GUID</xs:documentation>
    </xs:annotation>
    <xs:element name="DeviceModelId" type="wprt11:DeviceModelIdGuidType"/>
    <xs:simpleType name="DeviceModelIdGuidType">
        <xs:restriction base="xs:string">
            <xs:length value="36"/>
        </xs:restriction>
    </xs:simpleType>

墨迹/碳粉颜色表示值

以下架构检索表示特定墨迹或碳粉类型的颜色的 RGB 三元。 应为任何墨迹或墨粉易耗品指定此值,以便更好地在应用 UI 中显示颜色。

    <xs:annotation>
        <xs:documentation>
            Ink/Toner Color Representation definition
            A 6-digit hex representation of the RGB color value this Consumable entry represents.
            Examples of these values are:
                Black – 000000
                Red – FF0000
                White – FFFFFF
                Magenta – FF00FF
                Cyan – 00FFFF
                Yellow – FFFF00
                Blue – 0000FF
        </xs:documentation>    </xs:annotation>
    <xs:element name="ColorRepresentation" type="wprt11:ColorRepType"/>
    <xs:simpleType name="ColorRepType">
        <xs:restriction base="xs:string">
            <xs:length value="6"/>
        </xs:restriction>
    </xs:simpleType>

如本主题前面所述,在 WS-Print v1.2 部分中,已对 WS-Print V1.2 命名空间引入了以下新操作。

SetPrinterElements

SetPrinterElements 操作是新的,使客户端能够在打印机上设置架构元素的值。 SetPrinterElements 操作具有 8 个请求元素和 4 个响应元素。 请求和响应元素使客户端可以精细控制与 WS-Print 设备架构相关的数据插入和检索。

例如,ElementPath 数据元素 (SetPrinterElements 操作) 的一部分,是一个 XPath 字符串,表示要设置的数据元素的 Printer 架构中的位置。

有关 SetPrinterElements 操作的更多详细信息,请参阅以下 下载 部分中列出的 WS-Print v1.0 – v1.2 的支持文件。

下载

WS-Print v1.0 – v1.2 的规范和支持文件

文件:打印设备上 Web 服务的设备定义 V1.0说明:包含 Microsoft Word 文档和支持文件的 2.64 MB zip 文件;2013 年 9 月 16 日

规范和支持文件

文件:打印设备上 Web 服务的设备定义 V1.0说明:包含 Microsoft Word 文档和支持文件的 76 KB 自解压文件;2007 年 1 月 29 日

文件:设备上的 Web 服务的扫描服务定义 V1.0说明: (包含 Microsoft Word 文档和支持文件的 1.5 MB zip 文件;2012 年 2 月 9 日)

文件:扫描设备上 Web 服务的设备定义 V1.0说明: (包含 Microsoft Word 文档和支持文件的 76 KB 自解压文件;2007 年 1 月 29 日)

V4 打印机驱动程序连接