Package jakarta.xml.messaging

## Class JAXMServlet

- java.lang.Object
- - jakarta.servlet.GenericServlet
  - - jakarta.servlet.http.HttpServlet
    - - jakarta.xml.messaging.JAXMServlet

- All Implemented Interfaces:
    `jakarta.servlet.Servlet`, `jakarta.servlet.ServletConfig`, `java.io.Serializable`

      public abstract class JAXMServlet
      extends jakarta.servlet.http.HttpServlet

  The superclass for components that live in a servlet container that receives JAXM messages. A `JAXMServlet` object is notified of a message's arrival using the HTTP-SOAP binding.

  The `JAXMServlet` class is a support/utility class and is provided purely as a convenience. It is not a mandatory component, and there is no requirement that it be implemented or extended.

  Note that when a component that receives messages extends `JAXMServlet`, it also needs to implement either a `ReqRespListener` object or a `OnewayListener` object, depending on whether the component is written for a request-response style of interaction or for a one-way (asynchronous) style of interaction.

  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected jakarta.xml.soap.MessageFactory` | `msgFactory` | The `MessageFactory` object that will be used internally to create the `SOAPMessage` object to be passed to the method `onMessage`.

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `JAXMServlet()` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `doPost​(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)` | Internalizes the given `HttpServletRequest` object and writes the reply to the given `HttpServletResponse` object.
    `protected static jakarta.xml.soap.MimeHeaders` | `getHeaders​(jakarta.servlet.http.HttpServletRequest req)` | Returns a `MimeHeaders` object that contains the headers in the given `HttpServletRequest` object.
    `void` | `init​(jakarta.servlet.ServletConfig servletConfig)` | Initializes this `JAXMServlet` object using the given `ServletConfig` object and initializing the `msgFactory` field with a default `MessageFactory` object.
    `protected static void` | `putHeaders​(jakarta.xml.soap.MimeHeaders headers, jakarta.servlet.http.HttpServletResponse res)` | Sets the given `HttpServletResponse` object with the headers in the given `MimeHeaders` object.
    `void` | `setMessageFactory​(jakarta.xml.soap.MessageFactory msgFactory)` | Sets this `JAXMServlet` object's `msgFactory` field with the given `MessageFactory` object.

    - ### Methods inherited from class jakarta.servlet.http.HttpServlet

      `doDelete, doGet, doHead, doOptions, doPut, doTrace, getLastModified, service, service`

    - ### Methods inherited from class jakarta.servlet.GenericServlet

      `destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### msgFactory

          protected jakarta.xml.soap.MessageFactory msgFactory

      The `MessageFactory` object that will be used internally to create the `SOAPMessage` object to be passed to the method `onMessage`. This new message will contain the data from the message that was posted to the servlet. Using the `MessageFactory` object that is the value for this field to create the new message ensures that the correct profile is used.

  - ### Constructor Detail

    - #### JAXMServlet

          public JAXMServlet()

  - ### Method Detail

    - #### init

          public void init​(jakarta.servlet.ServletConfig servletConfig)
                    throws jakarta.servlet.ServletException

      Initializes this `JAXMServlet` object using the given `ServletConfig` object and initializing the `msgFactory` field with a default `MessageFactory` object.
      Specified by:
        `init` in interface `jakarta.servlet.Servlet`
      Overrides:
        `init` in class `jakarta.servlet.GenericServlet`
      Parameters:
        `servletConfig` - the `ServletConfig` object to be used in initializing this `JAXMServlet` object
      Throws:
        `jakarta.servlet.ServletException`

    - #### setMessageFactory

          public void setMessageFactory​(jakarta.xml.soap.MessageFactory msgFactory)

      Sets this `JAXMServlet` object's `msgFactory` field with the given `MessageFactory` object. A `MessageFactory` object for a particular profile needs to be set before a message is received in order for the message to be successfully internalized.
      Parameters:
        `msgFactory` - the `MessageFactory` object that will be used to create the `SOAPMessage` object that will be used to internalize the message that was posted to the servlet

    - #### getHeaders

          protected static jakarta.xml.soap.MimeHeaders getHeaders​(jakarta.servlet.http.HttpServletRequest req)

      Returns a `MimeHeaders` object that contains the headers in the given `HttpServletRequest` object.
      Parameters:
        `req` - the `HttpServletRequest` object that a messaging provider sent to the servlet
      Returns:
        a new `MimeHeaders` object containing the headers in the message sent to the servlet

    - #### putHeaders

          protected static void putHeaders​(jakarta.xml.soap.MimeHeaders headers,
                                           jakarta.servlet.http.HttpServletResponse res)

      Sets the given `HttpServletResponse` object with the headers in the given `MimeHeaders` object.
      Parameters:
        `headers` - the `MimeHeaders` object containing the the headers in the message sent to the servlet
        `res` - the `HttpServletResponse` object to which the headers are to be written
      See Also:
        `getHeaders(jakarta.servlet.http.HttpServletRequest)`

    - #### doPost

          public void doPost​(jakarta.servlet.http.HttpServletRequest req,
                             jakarta.servlet.http.HttpServletResponse resp)
                      throws jakarta.servlet.ServletException,
                             java.io.IOException

      Internalizes the given `HttpServletRequest` object and writes the reply to the given `HttpServletResponse` object.

      Note that the value for the `msgFactory` field will be used to internalize the message. This ensures that the message factory for the correct profile is used.

      Overrides:
        `doPost` in class `jakarta.servlet.http.HttpServlet`
      Parameters:
        `req` - the `HttpServletRequest` object containing the message that was sent to the servlet
        `resp` - the `HttpServletResponse` object to which the response to the message will be written
      Throws:
        `jakarta.servlet.ServletException` - if there is a servlet error
        `java.io.IOException` - if there is an input or output error