Interface MessageFormatter

All Known Implementing Classes:
ApplicationXMLFormatter, MultipartFormDataFormatter, SOAPMessageFormatter, XFormURLEncodedFormatter

public interface MessageFormatter

MessageFormatter implementations are used by Axis2 to support serialization of messages to different message formats. (Eg: JSON). Users can register MessageFormatter implementations against a message type using the axis2.xml. Message type for a message can be specified by setting the "messageType" property in the MessageContext. This can also be given as a parameter in the service.xml/axis2.xml for a per service based/engine wide configuration.

  • Method Summary

    Modifier and Type
    Method
    Description
    formatSOAPAction(MessageContext messageContext, org.apache.axiom.om.OMOutputFormat format, String soapAction)
     
    getContentType(MessageContext messageContext, org.apache.axiom.om.OMOutputFormat format, String soapAction)
    Different message formats can set their own content types Eg: JSONFormatter can set the content type as application/json
    default jakarta.activation.DataSource
    getDataSource(MessageContext messageContext, org.apache.axiom.om.OMOutputFormat format, String soapAction)
    Get the formatted message as a DataSource object.
    getTargetAddress(MessageContext messageContext, org.apache.axiom.om.OMOutputFormat format, URL targetURL)
    Some message formats may want to alter the target url.
    void
    writeTo(MessageContext messageContext, org.apache.axiom.om.OMOutputFormat format, OutputStream outputStream, boolean preserve)
    To support deffered writing transports as in http chunking..
  • Method Details

    • writeTo

      void writeTo(MessageContext messageContext, org.apache.axiom.om.OMOutputFormat format, OutputStream outputStream, boolean preserve) throws AxisFault
      To support deffered writing transports as in http chunking.. Axis2 was doing this for some time..

      Preserve flag can be used to preserve the envelope for later use. This is usefull when implementing authentication machnisms like NTLM.

      Parameters:
      outputStream -
      preserve - : do not consume the OM when this is set..
      Throws:
      AxisFault
    • getContentType

      String getContentType(MessageContext messageContext, org.apache.axiom.om.OMOutputFormat format, String soapAction)
      Different message formats can set their own content types Eg: JSONFormatter can set the content type as application/json
      Parameters:
      messageContext -
      format -
      soapAction -
    • getTargetAddress

      URL getTargetAddress(MessageContext messageContext, org.apache.axiom.om.OMOutputFormat format, URL targetURL) throws AxisFault
      Some message formats may want to alter the target url.
      Returns:
      the target URL
      Throws:
      AxisFault
    • formatSOAPAction

      String formatSOAPAction(MessageContext messageContext, org.apache.axiom.om.OMOutputFormat format, String soapAction)
      Returns:
      this only if you want set a transport header for SOAP Action
    • getDataSource

      default jakarta.activation.DataSource getDataSource(MessageContext messageContext, org.apache.axiom.om.OMOutputFormat format, String soapAction) throws AxisFault
      Get the formatted message as a DataSource object.
      Parameters:
      messageContext -
      format -
      soapAction -
      Returns:
      Throws:
      AxisFault