Internationalization and Character Sets

The default character sets installed with WebLogic, and its default handling, are sufficient in most cases. If a client interacts with a web service specifying its preferred character set, WebLogic will respond using that character set requested by the client. This section looks at how you can take more control over which character set should be used for a web service.

19.10.1 Configuring Web Services

You can explicitly configure the character set to be used by a web service. In effect, this determines the value of the HTTP Content-Type header embedded in the responses sent back to clients of the web service. You can specify the character set in two ways:

  • Modify the web-services.xml descriptor file by adding a charset attribute. Once deployed, the web service will be forced to always use the specified character set:

    charset="Shift_JIS">
    
    
  • Set the -Dweblogic.webservice.i18n.charset system property in WebLogic's startup script. However, this character set then will apply to all web services deployed to the server, and you must set this property on each server that hosts the web service.

The character set used for any web service is determined by the following precedence rules. If the charset attribute is set for a web service, it is used. Otherwise, if the client explicitly requests a character set, it is used instead. If neither of these values is set, the weblogic.webservice.i18n.charset system property is used (if it is set). If none of these conditions holds, WebLogic use the default character set for the JVM. If the JVM property user.language is set to en, the US-ASCII character set it used. If the property is set to anything else, UTF-8 is used instead.

Thus, if the Content-Type HTTP header of the SOAP request has been set, WebLogic will use the specified character set. If the Accept-Charset HTTP header has been set instead, WebLogic will use this preferred character set, provided you've not configured a charset attribute for the web service. SOAP 1.2 requests may have an encoding attribute in their XML declaration, such as . The character set specified by this attribute is used, provided there is no Content-Type header in the SOAP request. For SOAP 1.1 requests, the encoding attribute is ignored.

19.10.2 Configuring Client Applications

Clients can use the weblogic.webservice.binding.BindingInfo class to set the Content-Type or Accept-Charset HTTP headers. As we just learned, these headers don't guarantee that the same character set will be used for the response. Here is how to specify the preferred character set:

BindingInfo info =
 (BindingInfo)stub._getProperty("weblogic.webservice.bindinginfo" );
info.setCharset("UTF-8" ); // This sets the Content-Type
info.setAcceptCharset("UTF-8"); // This sets the Accept-Charset
port.makeUpper("Lang maande lê die reënboog in 'n miershoopgat gekrul");

Introduction

Web Applications

Managing the Web Server

Using JNDI and RMI

JDBC

Transactions

J2EE Connectors

JMS

JavaMail

Using EJBs

Using CMP and EJB QL

Packaging and Deployment

Managing Domains

Clustering

Performance, Monitoring, and Tuning

SSL

Security

XML

Web Services

JMX

Logging and Internationalization

SNMP



WebLogic. The Definitive Guide
WebLogic: The Definitive Guide
ISBN: 059600432X
EAN: 2147483647
Year: 2003
Pages: 187

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net