Unable to create envelope from given source because the root element is not named Envelope

C

cxc

Hi

I am trying to submit to UK's Gov Talk SOAP System using SAAJ. The
error message occurs when I try and check the SOAP body to verify all
the tags. I have been having a lot of trouble with loading the XML
because of the non standard tag. Could someone please advise the
correct way to send this XML?

The envelopes employ the following root tag:

<?xml version="1.0" encoding="UTF-8"?>
<GovTalkMessage xmlns="http://www.govtalk.gov.uk/CM/envelope">
....

20-May-2005 22:30:42 com.sun.xml.messaging.saaj.soap.SOAPPartImpl
lookForEnvelope
SEVERE: SAAJ0514: Unable to create envelope from given source because
the root element is not named Envelope
20-May-2005 22:30:42 com.sun.xml.messaging.saaj.soap.EnvelopeFactory
createEnvelope
SEVERE: SAAJ0511: Unable to create envelope from given source



SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance();
SOAPConnection connection = factory.createConnection();

MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage message = messageFactory.createMessage();



SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();
SOAPBody body = envelope.getBody();

//Populate the Message
StreamSource preppedMsgSrc = new StreamSource( new
FileInputStream("core-v2-0.xml"));
soapPart.setContent(preppedMsgSrc);

//Save the message
message.saveChanges();

// Allow HTTPS
System.setProperty("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

// Get the SOAP body and check the output to verify the XML is correct
SOAPBody soapBody = message.getSOAPBody();

// Get the SOAP body and check the output to verify the XML is correct
SOAPBody soapBody = message.getSOAPBody();
java.util.Iterator iterator = soapBody.getChildElements();
while (iterator.hasNext()) {
SOAPBodyElement bodyElement = (SOAPBodyElement)iterator.next();
String localName = bodyElement.getLocalName();
System.out.println(localName);


TIA

Nick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Call web service in java 0
SOAP/SAAJ error 1
Constructing SOAP Message 3
SAAJ's DOM error 2
SOAP via SSL 2

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top