Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Unable to create envelope from given source because the root element is not named Envelope

Reply
Thread Tools

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

 
 
cxc
Guest
Posts: n/a
 
      05-20-2005
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript code to recursively search for a element given the element's Id Cal Who ASP .Net 13 05-23-2010 03:05 PM
If given 1 element in an array of textboxes... find which element number it is \A_Michigan_User\ Javascript 4 11-16-2007 12:58 PM
problem: create element in create element Iulian Ilea Javascript 4 12-17-2006 12:00 PM
Remove parent element with a child element matching a given rule patrizio.trinchini@googlemail.com XML 4 08-22-2006 11:31 AM
Get next element given a certain element? Kourosh Javascript 1 06-08-2006 02:23 AM



Advertisments