Java 2EE and XML Development

Скачать в pdf «Java 2EE and XML Development»

Restoring a JavaBean from XML

Reading a previously saved JavaBean back into memory is equally simple. Using our SimpleJavaBean example, the bean can be reinstated using the following code:

XMLDecoder d

= new XMLDecoder( new BufferedInputStream(

new FileInputStream(«simple.xml»)));

SimpleJavaBean result = (SimpleJavaBean) d.readObject(); d.close();

The XMLDecoder knows how to reconstitute any bean saved using the XMLEn-coder component. This API can be a quick and painless way to export your beans to XML for use by other tools and applications. And remember, you can always transform the bean’s XML to another format via XSLT to make it more suitable for import into another environment.

2.2.5 JAXM

The Java API for XML Messaging (JAXM) is an enterprise Java API providing a standard access method and transport mechanism for SOAP messaging in Java. It currently includes support for the SOAP 1.1 and SOAP with Attachments specifications. JAXM supports both synchronous and asynchronous messaging.

The JAXM specification defines the various services that must be provided by a JAXM implementation provider. Using any compliant implementation, the developer is shielded from much of the complexity of the messaging system, but has full access to the services it provides. Figure 2.11 depicts the JAXM architecture.

Figure 2.11 JAXM architecture

The two main components of the JAXM architecture are the JAXM Client and Provider. The Client is part of the J2EE Web or EJB container that provides access to JAXM services from within your application. The Provider may be implemented in any number of ways and is responsible for sending and receiving SOAP messages. With the infrastructure in place, sending and receiving SOAP messages can be done exclusively through the JAXM API.

Скачать в pdf «Java 2EE and XML Development»