Skip to main content

Software  > Globalization > 

Globalize your On Demand Business

Usage of G11N Policy

2.4.1 Scenario Description
A Hawaiian hotel provides hotel reservations using Web Services both in English and in French on the Internet. For customers using English, the Web Service accepts USD currency only; but for customers using French, the Web Services accepts EUR as well as USD currency.

2.4.2 G11N Policy example
The following policy file describes the g11n capability of the Hawaii hotel reservation Web Services:

01 <wsp:Policy xmlns:wsp="…" xmlns:wsgp="…">

02 <wsp:ExactlyOne>

03 <wsp:All>

04 <wsp:Language wsp:Usage="wsp:Required" Language="en_US" />

05 <wsgp:Currency wsp:Usage="wsp:Required" Currency="wsgp:USD" />

06 <wsgp:Linear wsp:Usage="wsp:Required" Linear="wsgp:MILE" />

07 </wsp:All>

08 <wsp:All>

09 <wsp:Language wsp:Usage="wsp:Required" Language="fr_FR" />

10 <wsp:ExactlyOne>

11 <wsgp:Currency wsp:Usage="wsp:Required" wsp:Preference="9" Currency="wsgp:USD" />

12 <wsgp:Currency wsp:Usage="wsp:Required" wsp:Preference="8" Currency="wsgp:EUR" />

13 </wsp:ExactlyOne>

14 <wsgp:Linear wsp:Usage="wsp:Required" Linear="wsgp:MILE" />

15 </wsp:All>

16 <wsp:ExactlyOne>

17 </wsp:Policy>

Line 02~16: two policy assertion sets are included between <wsp:ExactlyOne> policy operator and only one assertion should be used at one time. To deliver the Web Services successfully, The SOAP message received by the provider must be in conformity to policy defined either in line 03~07 or in line 08~15.
Line 03~07: represent the <wsp:All> policy operator. In this block, we define English as content language, mile as linear measurement unit and USD as the currency unit.
Line 08~15: represent the <wsp:All> policy operator. In this block, we define French as the content language, mile as linear measurement unit and both EUR and USD as the currency unit, and the Web Services prefers USD as the currency unit.

2.4.3 SOAP message examples
For example, the hotel reservation Web Services have a “getHotelInfo” function that returns the hotel description, distance to airline and the price of single room. According to "WS I18N Usage scenarios: Web Services Internationalization Usage Scenarios", there are two ways to generate SOAP message compliance with the policy defined above.

2.4.3.1 If we use the default attributes in SOAP header, the SOAP message is:

<?xml version='1.0' ?>

<env:Envelope xmlns:env="http://www.w3.org/2002/06/soap-envelope" >

<env:Header>

<wsgp:Wsinternationalization xmlns:wsgp="http://example.org/2002/11/21/g11next"

xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy">

<wsp:Language>en_US</wsp:Language>

<wsgp:Currency>wsgp:USD</wsgp:Currency>

<wsgp:Linear>wsgp:MILE</wsgp:Linear>

</wsgp:WSinternationalization>

</env:Header>

<env:Body>

<c:getHotelInfoResponse>

<c:hoteldesc>The Sky Hotel is one of the best five star hotels.</c:hoteldesc>

<c:distance2airport>13.4</c:distance2airport>

<c:singleroomprice>128.00</c:singleroomprice>

</c:getHotelInfoResponse>

</env:Body>

</env:Envelope>

According to the <WSinternationalization> block defined in message header, we can know for sure that the hotel description is written in English, the hotel is 13.4 miles away from the airport, and the price of a single room is 128 US dollars.

2.4.3.2 If we use the locale-neutral formatted data with additional attributes, the SOAP message is:

<?xml version='1.0' ?>

<env:Envelope xmlns:env="http://www.w3.org/2002/06/soap-envelope"

xmlns:wsgp="http://example.org/2002/11/21/g11next"

xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy">

<env:Header>

</env:Header>

<env:Body>

<c:getHotelInfoResponse>

<c:hoteldesc c:Language="en_US">The Sky Hotel is one of the best five star hotels.</c:hoteldesc>

<c:distance2airport c:Linear="wsgp:MILE">13.4</c:distance2airport>

<c:singleroomprice c:Currency="wsgp:USD">128.00</c:singleroomprice>

</c:getHotelInfoResponse>

</env:Body>

</env:Envelope>

The G11N attributes are assigned to each parameter, so that we can know for sure that the hotel description is written in English, the hotel is 13.4 miles away from the airport, and the price of a single room is 128 US dollars.


gray line

Continue to Considerations of G11N Web Services


E-mail us
Easy ways to get the answers you need.
E-mail us