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

Discussion in 'Java' started by cxc, May 20, 2005.

  1. cxc

    cxc Guest

    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
     
    cxc, May 20, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    29
    Views:
    1,736
    Harry George
    Apr 10, 2006
  2. Replies:
    4
    Views:
    2,577
  3. Cal Who
    Replies:
    13
    Views:
    1,713
    Registered User
    May 23, 2010
  4. Kourosh
    Replies:
    1
    Views:
    130
    Kourosh
    Jun 8, 2006
  5. \A_Michigan_User\
    Replies:
    4
    Views:
    162
    Thomas 'PointedEars' Lahn
    Nov 16, 2007
Loading...

Share This Page