Previous section   Next section
MessageFactory javax.xml.soap

SAAJ 1.1; JWSDP 1.0, J2EE 1.4
public abstract class MessageFactory {
// Public Constructors
    public MessageFactory(  ); 
// Public Class Methods
    public static MessageFactory newInstance(  ) throws SOAPException; 
// Public Instance Methods
    public abstract SOAPMessage createMessage(  ) throws SOAPException; 
    public abstract SOAPMessage createMessage(MimeHeaders headers, 
    java.io.InputStream in) throws java.io.IOExceptionSOAPException; 
}

MessageFactory is an abstract base class that provides the methods used by application code to construct SOAP messages. A SAAJ application obtains an instance of this class by calling the static newInstance( ) method, which looks for a suitable concrete implementation using the following algorithm:

Once you have a MessageFactory, use its zero-argument createMessage( ) method to obtain a basic SOAPMessage object to which you can then add content and attachments. The default MessageFactory provided by the SAAJ reference implementation returns a message that contains the following:

Since the MessageFactory is found using a lookup process, it is possible to plug in a custom factory that will return a SOAPMessage that is partially populated with elements that a particular application or suite of applications might require, without modifying application code.

The other variant of createMessage( ) is intended to be used to deserialize a SOAP message received from an HTTP connection or some other communications mechanism into a SOAPMessage object and therefore is most commonly used by servlets. The in argument provides an InputStream from which the raw XML message can be read, while the headers argument is a MimeHeaders object containing the MIME headers that accompanied the message and therefore accessible from the SOAPPart object within the resulting SOAPMessage. Refer to Chapter 6 for an example that shows how to use this method to handle a SOAP message from within a servlet.

Passed To

javax.xml.messaging.JAXMServlet.setMessageFactory( )

Returned By

javax.xml.messaging.ProviderConnection.createMessageFactory( ), MessageFactory.newInstance( )

Type Of

javax.xml.messaging.JAXMServlet.msgFactory


  Previous section   Next section