Question: I am trying to add a XML Declaration for ex: `<?xml version="1.0" encoding="utf-8"?>` to the top of this soap message. Can anyone assist me on how this can be done? 

```
 try {
            // Create SOAP Connection
            SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
            SOAPConnection soapConnection = soapConnectionFactory.createConnection();

            // Send SOAP Message to SOAP Server
            String url = "http://ws.cdyne.com/emailverify/Emailvernotestemail.asmx";
            SOAPMessage soapResponse = soapConnection.call(createSOAPRequest(), url);

            // Process the SOAP Response
            printSOAPResponse(soapResponse);

            soapConnection.close();
        } catch (Exception e) {
            System.err.println("Error occurred while sending SOAP Request to Server");
            e.printStackTrace();
        }
    }

    private static SOAPMessage createSOAPRequest() throws Exception {
        MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage soapMessage = messageFactory.createMessage();
        SOAPPart soapPart = soapMessage.getSOAPPart();
        SOAPHeader header = soapMessage.getSOAPHeader();

```

Answer: 
You need to set a property to the SOAP message.

```
soapMessage.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true")

```

The above code should do that.

Here is the [link](http://docs.oracle.com/javaee/5/api/javax/xml/soap/SOAPMessage.html#setProperty%28java.lang.String,%20java.lang.Object%29) to `setProperty(String property, Object value)` documentation.
```
soapMessage.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, "UTF-8");
soapMessage.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true");

```