sqloptions:initialLanguage 标头元素

后续版本的 Microsoft SQL Server 将删除该功能。 请避免在新的开发工作中使用该功能,并着手修改当前还在使用该功能的应用程序。

sqloptions:initialLanguage SOAP 标头使客户端可以指定要设置的初始语言,例如:

<SOAP-ENV:Header
  xmlns:SOAP-ENV="https://schemas.xmlsoap.org/soap/envelope/"
  xmlns:sqloptions="https://schemas.microsoft.com/sqlserver/2004/SOAP/Options">
    <sqloptions:initialLanguage          SOAP-ENV:mustUnderstand="1"          value="name of initial language to use"           optional="true" | "false" />

</SOAP-ENV:Header>

sqloptions:initialLanguage 选项就是一个 SOAP 标头。该标头由一个名为 sqloptions:initialLanguage 的元素组成。该元素具有一个必需的属性 value。这是一个字符串值。value 属性指定要设置的初始语言的名称。解释该字符串的方式与解释 SET LANGUAGE Transact-SQL 语句的方式相同。此元素有一个可选属性 optional。这是一个布尔值(默认值为 false)。可选属性指定无法连接到数据库时登录是否会失败:false 表示登录应失败,true 表示登录可以继续。

一个请求中只能出现 sqloptions:initialLanguage 选项的一个实例。该选项无法在响应中出现。多个选项实例将会生成错误。

如果使用 SOAP 会话,则此选项必须出现在与 sqloptions:sqlsession initiate 属性相同的请求中。如果在任何带有 sqloptions:sqlSession 标头但不包含 initiate 属性的请求中出现此选项,则将生成错误。

下面是 sqloptions:initialLanguage 选项的架构片段:

<xs:element name="initialLanguage" form="qualified">
    <xs:annotation>
        <xs:documentation>
            Set initial language to set.
        </xs:documentation>
    </xs:annotation>
    <xs:complexType>
        <xs:attribute use="required" name="value" type="xs:string" form="unqualified">
            <xs:annotation>
                <xs:documentation>
                    The name of the initial language to set.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute
          name="optional"
          default="false"
          type="xs:boolean"
          form="unqualified">
            <xs:annotation>
                <xs:documentation>
                    Whether the initial language is optional or not.
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>
</xs:element>

示例

以下是在 SOAP 请求和响应消息中使用 sqloptions:initialLanguage 标头的示例。

请求

<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:initialLanguage SOAP-ENV:mustUnderstand="1" value="us_english" optional="true"/>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <sql:sqlbatch>
      <sql:BatchCommands>
        SELECT @@language AS lang
      </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>
                <lang>us_english</lang>
              </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>

请参阅

参考