Home > Articles > Programming > Java

  • Print
  • + Share This
From the author of

What's In a SOAP Message?

SOAP was originally intended as a messaging protocol for XML documents. However, the need to send additional non-XML documents along with the XML has resulted in two kinds of SOAP messages: those with and those without attachments. Attachments are an important part of SOAP because technically only an XML document is permitted in a SOAP body. However, it's often important to communicate non-XML data, such as digital signatures or DTDs, as part of a SOAP message. If such information needs to be sent, it must be done as part of a SOAP attachment.

Figure 1 illustrates SOAP message packets with and without attachments. From within Java, both kinds of messages can be created using the JAXM's SOAPMessage class. There is also a SOAPPart class to represent the SOAP part and a SOAPEnvelope class to represent the SOAP envelope. When a SOAPMessage instance is created, it automatically includes the necessary pieces for a SOAP message—a SOAPPart object that contains a SOAPEnvelope, which may contain an optional SOAPHeader object and a SOAPBody object. In most cases, an application will need a SOAPHeader to include information about routing, security, and transactions; and if there is non-XML data to be transported, an AttachmentPart class instance will be required as part of a SOAP message.

Figure 1Figure 1 Regular SOAP and SOAP with attachments.

  • + Share This
  • 🔖 Save To Your Account