This document is also available in these non-normative formats: http://www.webmethods.com.
Copyright 2004, webMethods, Inc.
| Editorial note | |
| The goal is for this document to be submitted as input to the W3C Internationalization Working Group to provide a basis for work on this issue. | |
WS-I18N describes enhancements to SOAP messaging to provide internationalized and localized operation via locale and international preference negotiation. These mechanisms can be used to accommodate a wide variety of development models for international usage.
WS-I18N also provides a general-purpose mechanism for associating a "locale policy" with messages. It is designed to be extensible (e.g. support multiple international preferences and locale identifier models).
Composable Architecture
By using the SOAP extensibility model, SOAP-based specifications are designed to be composed with each other to provide a rich messaging environment. By itself, WS-I18N does not ensure internationalized operation or that localized operation will occur nor does it provide a complete internationalization solution. WS-I18N is a building block that is used in conjunction with other Web service and application-specific protocols, can accommodate a wide variety of locale and international support models. Implementing WS-I18N does not by iteself enable international functionality in the underlying Web services or providers, but it does provide a framework for globalization that enabled products can leverage, as well as a way for enabled products to interact with systems that are not enabled.
1 Introduction
1.1 Requirements
2 Notation and Terminology
2.1 Notation and Terminology
2.2 Namespace
3 Data Structure for SOAP Documents
3.1 The International Element
3.2 The Locale Element
3.3 The Language Element
3.4 The TZ (Time Zone) Element
3.5 The Preferences Element
4 Data Structure for WSDL Documents
5 Examples
A References (Non-Normative)
Web services technology provides application-to-application communication over the Internet. The W3C's Web Services Glossary [WSGlossary]describes a Web service as:"a software system designed to support interoperable machine-to-machine interaction over a network. It has an interface described in a machine-processable format (specifically WSDL). Other systems interact with the Web service in a manner prescribed by its description using SOAP-messages, typically conveyed using HTTP with an XML serialization in conjunction with other Web-related standards."
Most programming languages and operating environments use an internationalization model that assumes that the user's preferences (generally embodied as something called a 'locale') are maintained by the operating environment. Traditional Web technologies such as .Net or J2EE provide proprietary ways to exploit this international support in Web applications.
Web services aim to be an interoperable means of invoking logic over the Web. Implicit in the definition above is that by using standards for data representation, Web services avoid exposing the underlying implementation.
One way that Web services promote interoperability is by providing for service composition. That is, different features can be applied to the same service without modifying the service itself. For example, a service can reference both the WS-Secuirty and WS-ReliableMessaging standards without the two standards having to consider the ramifications of the other.
While these features make Web services a compelling solution to the problem of composite enterprise app development, they also present a problem for Web service internationalization: Web services are open and standards based. Existing internationalization models are closed and proprietary.
How can Web services have both internationalized behavior and platform neutral interoperability?
The W3C I18N Working Group has recently published a Note [1] that discusses this problem in detail. Requirements based on the findings in this note were used as inputs to a new draft charter for the Internationalization Core Working Group [2].
Creating a non-proprietary internationalization model actually requires very little standardization. The Internationalization Working Group believes that this work includes:
Consider an example of a simple Java method converted to a Web service. For simplicity we'll write a little "internationalization demo" that converts a date to a human-readable string. Here's how such a method might be implemented:
public static String getDateString(Date date) {
if (date == null) date = new Date();
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG,
DateFormat.MEDIUM);
return df.format(date);
}In this example, a Date object is formatted as a String using the default locale of the JVM where the program is executing. The locale setting of this method is not part of the service's signature and wouldn't appear in parameter list necessary for invoking this method.
This method does require some modifications if we wish to use it in a distributed setting, say a J2EE program:
public static String getDateString(Date date) {
if (date == null) date = new Date();
Locale userLocale = request.getLocale();
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG,
DateFormat.MEDIUM, userLocale);
return df.format(date);
}The change to the method's implementation is minimal: the developer must know to get the locale from the HTTPServletRequest object, in this case. Note that a comparison with C# is instructive: there is no need to change code in .NET, since the service provider sets the thread "culture" (the Microsoft equivalent of a locale) from the request.
Now there is something mystical about how both the J2EE and .NET systems got the locale into the method. The Java proprietary Locale object was set in the Request object by processing the user's HTTP Accept-Language header and doing some (proprietary) mapping to Java's representation (the Locale object). The locale can then be accessed by a Java program. The same thing happens in forming the "default thread culture" in .NET.
Both of the examples above produce localized behavior using information maintained by the application's environment. The developer may need to do something in the body of the code to access this capability (as in the second example), but the method signature remains the same.
It is important to recognize that changing the method signature to get localized behavior is a poor implementation choice. It not only exposes the platform's implementation, but it requires the service author to create gallons of unusual code:
public static String getDateString(Date date, String locale) {
if (locale == null) locale = "";
if (date == null) date = new Date();
Locale userLocale;
if (locale.length()==0) {
userLocale = Locale.getDefault();
} else {
// parse string locale and create a Locale object,
// about 20 to 50 lines of code.
}
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG,
DateFormat.MEDIUM, userLocale);
return df.format(date);
}The example method shown above also requires intervention by the developer on several levels. For example, if the developer wants to use IANA language identifiers for the string parameter 'locale', then the WSDL needs to specify the type xsi:language. Furthermore, differences in system capability and identifier standardization may result in unusual results from the service.
This suggests that Web services requires rather more attention to an "internationalization model" than traditional Web content.
The W3C Internationalization Working Group is currently developing a new charter that includes work items to address the basic problem of internationalization in Web services. This work is critical to the future internationalization of Web services. This document aims to provide a framework so that this work can proceed as quickly as possible to implementation.
A "WS-Internationalization" should provide semantics so that identifiers are as clear and platform neutral as possible. There should be the possibility of vendor specific extensions so that vendors can leverage platform extensions. Ideally the identifiers should take the form of URIs. URI's provide a number of useful properties, which include the ability to retrieve resources and to define namespaces.
When a Web service is deployed, there are four basic patterns for how its various aspects may be internationalized:
Each of these patterns may apply to a service or an aspect of the service. By describing the "international policy" separately for a service or sevice aspect, different end-points or bindings of the same service can provide different locale-affected behavior or different localizations. Or the logic might differ in a culturally sensitive manner.
Once one posits services that can be locale-affected and which obey policies in their Web service descriptions, it is a short journey to composing a service's international constraints and capabilities with other features. For example, a service might be provisioned so that specific binding return messages in a specific language. Or the processing rules might differ based on the language requested.
The goal of WS-I18N is to enable applications to gather information about a service's capabilities from the Web Service Description; pass international preferences to Web services that the application invokes via SOAP; and understand the format and language of any messages returned.
This requires the following capabilities in Web service description (WSDL) files:
Indicate the settings that a service will use when invoked. This may include a specific setting or settings. It can also a "policy" that solicits information from the client that invokes the service.
Indicate the data structure that clients may use to activate internationalized and localized features.
Indicate the information or data structure that a client may expect to receive about how a service executed in an optional response.
The following are required in SOAP messages:
Indicate the locale and/or language preference of the client to the Web service and service provider.
Indicate the time zone of the client.
Indicate additional optional information about the client's international preferences.
Provide an extensible mechanism for adding other related information to the request.
This section specifies the terminology used throughout.
The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC2119.
The XML namespace URI that MUST be used by implementations of this specification is:
http://www.w3.org/International/ws/i18n
The prefix used in this document for this URI is "ws-i18n".
The Locale Data Markup Language (LDML) is defined by the Unicode Consortium and Unicode Technical Report #35:
http://www.unicode.org/reports/tr35
The XML namespace URIs for LDML are:
http://www.unicode.org/cldr/dtd/1.2/ldml.dtd http://www.unicode.org/cldr/dtd/1.2/ldmlSupplemental.dtd
The prefix used in this document for this URI is "ldml".
SOAP documents that need to send international preferences may reference the SOAP Feature described by this document and include the <international> block in an additional header. When sent from the requester to a provider, the header represents the preferences of the requester or its client application. When sent in a response message from the provider, the header represents the settings that the service used to process the request.
The <international> header block provides a mechanism for attaching international preferences and contextual information to a SOAP document targetted at a specific receiver (SOAP actor). The block can, therefore, be repeated multiple times in a SOAP message.
A message MAY have multiple <international> header blocks if they are targeted for separate receivers. However, only one <international> header block can omit the S:actor attribute and no two <international> header blocks can have the same value for S:actor. International preference information targeted for different receivers MUST appear in different <international> header blocks. The <international> header block without a specified S:actor can be consumed by anyone, but MUST NOT be removed prior to the final destination as determined by WS-Routing.
Sub-elements of <international> can appear in any order.
<ws-i18n:international S:mustUnderstand="..." S:actor:"..."> ... </ws-i18n:international>
The <locale> element MUST appear exactly one time per <international> block and represents the requested user locale or culture. The element MUST contain either (a) an item of type xs:anyURI that points to a valid LDML XML file defining a locale or (b) a 'value' attribute contaning a valid [RFC3066bis] language tag or the policy strings neutral or default
For example:
<locale>http://www.example.org/locale/common/main/de_CH.xml</locale> <locale value="de-CH" /> <locale value="neutral" />
The <tz> element MAY appear at most one time per <international> block and represents the local time zone of the Requester or Provider. The contents of the element must be either RFC 822-formatted zone offset[RFC822] or an Olson ID from the 'tzinfo' database. Note that RFC 822 zone offsets are not complete time zone identifiers and Olson identifiers should be preferred.
For example:
<tz>GMT-0300</tz> <tz>America/Los_Angeles</tz>
The <preferences> element MAY appear at most one time per <international> block. The <preferences> block represents a way to construct specific international preferences and overrides. It does this either by starting with a predefined locale structure and modifying only the data associated with it that is of interest to the end user, or by communicating specific value information. For example, the user might wish to have a slightly different date format or use a different measuring system.
The <preferences> block may contain any number of elements using the LDML markup language.
Examples:
<ws-i18n:preferences> <ldml:measurementSystem type="metric" /> </ws-i18n:preferences>
<ws-i18n:preferences>
<ldml:date>
<ldml:calendar type="gregorian">
<ldml:dateFormats>
<default type="medium" />
</ldml:dateFormat>
</ldml:calendar>
</ldml:date>
</ws-i18n:preferences>The preferences block should be treated as if the <locale> element is an LDML <alias> element. That is, the two following blocks represent equivalent preferences:
<ws-i18n:international> <ws-i18n:locale value="en-US /> </ws-i18n:international>
<ws-i18n:international>
<ws-i18n:preferences>
<ldml:alias source="en_US" />
</ws-i18n:preferences>
</ws-i18n:international>Note that the <alias> element within the preferences block does NOT override the <locale> element. This prevents the preferences block from being used to "spoof" a different locale behavior from the one that the user generally expects. For the example, the <alias> element in the following example essentially does nothing, since no specific preferences are identified.
<ws-i18n:international>
<ws-i18n:locale value="en-US />
<ws-i18n:preferences>
<ldml:alias source="de_DE" />
</ws-i18n:preferences>
</ws-i18n:international><special> element.WSDL documents describe the capabilities and configuration of a service. In order to facilitate international operation, the Web service description may need to include information about how the service is deployed, allow separate bindings with different behavior, and describe the fields used by a service to activate international functionality.
WSDL introduces an additional concept to those included in the SOAP Feature, that of a service "policy". A service policy may be a concrete value ("this service executes in the French-for-France locale"), or it may be one of these:
$neutral: This service or service attribute is locale neutral in its execution. Specific settings in a received WS-I18N header will generally be ignored by the service, although the Provider may use them (for example in the generation of fault messages).
$user: This service or service attribute will attempt to use preferences included in a received WS-I18N header. If possible the actual value(s) used by the service will be returned in Out messages in a WS-I18N header.
$default: This service or service attribute will use the default locale,language, or settings where it is deployed, which may be unknown at the time that the WSDL is generated (or which may vary depending on the endpoint and binding selected). The service may ignore any specific settings in a received WS-I18N header, although the Provider may use them (for example in the generation of fault messages). If possible the runtime value(s) used will be returned in Out messages in a WS-I18N header.
The WSDL file MAY specify the use of WS-I18N in a transaction as a WSDL Feature. A WSDL Feature merely indicates that the Providers will recieve and process a WS-I18N header and doesn't imply anything about the specific operation of the service.
The policy that governs the operation of a particular service is implemented as a WSDL Property:
<definitions targetNamespace="http://example.com/example"
xmlns:ns1="http://example.com/example">
<interface name="ns1:Thing">
<!-- All implementations of this interface must be locale-aware -->
<feature uri="http://www.w3.org/International/ws/i18n"
required="true"/>
<operation name="someOperation">
<!-- This operation uses the $user policy -->
<property uri="http://www.w3.org/International/ws/i18n"
required="true">
<constraint xmlns:locale="http://www.w3.org/International/ws/i18n">
locale:$user
</constraint>
</property>
...
</operation>
...
<operation name="anotherOperation">
<!-- This operation uses a specific locale -->
<property uri="http://www.w3.org/International/ws/i18n"
required="true">
<value>http://example.com/myLocale#fr-FR</value>
</property>
...
</operation>
</interface>[WSUS] "Web Services Internationalization Usage Scenarios", W3C Working Group Note, Bannerjee, Dürst, McKenna, et al., July 30, 2004
[IUC26] "Why Web Services Are Not Internationalized (Yet)", Internationalization and Unicode Conference #26 paper, Addison Phillips
[DRAFT] "Proposed Draft Charter, W3C I18N Core WG", no official standing, Addison Phillips, Martin Dürst