- Javax.xml.bind classes
- Home
- Binder
- DatatypeConverter
- JAXB
- JAXBContext
- JAXBElement
- JAXBElement.GlobalScope
- JAXBIntrospector
- Marshaller.Listener
- SchemaOutputResolver
- Unmarshaller.Listener
- Javax.xml.bind.util classes
- JAXBResult
- JAXBSource
- ValidationEventCollector
- Javax.xml.parsers classes
- DocumentBuilder
- DocumentBuilderFactory
- SAXParser
- SAXParserFactory
- Javax.xml.soap classes
- AttachmentPart
- MessageFactory
- MimeHeader
- MimeHeaders
- SAAJMetaFactory
- SOAPConnection
- SOAPConnectionFactory
- SOAPFactory
- SOAPMessage
- SOAPPart
- Javax.xml.validation classes
- Schema
- SchemaFactory
- TypeInfoProvider
- Validator
- ValidatorHandler
- Javax.xml.xpath classes
- XPathConstants
- XPathFactory
- Java Useful Resources
- Java - Quick Guide
- Java - Useful Resources
MessageFactory createMessage() Method
Description
The javax.xml.soap.MessageFactory.createMessage() method creates a new SOAPMessage object with the default SOAPPart, SOAPEnvelope, SOAPBody, and SOAPHeader objects.
Declaration
Following is the declaration for javax.xml.soap.MessageFactory.createMessage() method
abstract SOAPMessage createMessage()
Return Value
a new SOAPMessage object
Exception
SOAPException − if a SOAP error occurs.
UnsupportedOperationException − if the protocol of this MessageFactory instance is DYNAMIC_SOAP_PROTOCOL.
Example
The following example shows the usage of javax.xml.soap.MessageFactory.createMessage() method.
package com.tutorialspoint; import javax.xml.soap.MessageFactory; import javax.xml.soap.SOAPMessage; public class MessageFactoryDemo { public static void main(String[] args) { try { // create a new SOAPMessage SOAPMessage message = MessageFactory.newInstance() .createMessage(); //print the SOAPMessage on the console message.writeTo(System.out); } catch (Exception ex) { ex.printStackTrace(); } } }
If we compile the code and execute it, this will produce the following result −
<SOAP-ENV:Envelope xmlns:SOAP-ENV = "http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Header/> <SOAP-ENV:Body/> </SOAP-ENV:Envelope>
javax_xml_soap_messagefactory.htm
Advertisements
To Continue Learning Please Login
Login with Google