Need to Parse XML Message from my Message Driven Bean

Hi
I am using Message Driven Beans for listening to a Queue .
I am getting a Big XML file from my Queue in form of a TextMessage .
Now my task is to read / parse the XML Message .
Please tell me what is the appropiate parsing technique i need to use (Should i use SAX or DOM )
Please share your ideas .
Thank you .

Generally you want to use SAX if the file is so big that loading it all in memory (as DOM does) will create memory problems.
Read about these methods on the wiki page for [JAXP.|http://en.wikipedia.org/wiki/Java_API_for_XML_Processing]

Similar Messages

  • How to extract the actual XML document from soap message?

    My problem is " how to extract the actual XML document from soap message? "
    i just want to extract the attachment i.e. (pure XML document without any soap header or envolope).
    i could be ver thank full if u could solve my problem.
    [email protected]

    Hi,
    This is some skeleton code for extracting an attachment from a SOAPMessage.
    import javax.activation.DataHandler.;
    import javax.xml.soap.*;
    import javax.xml.message.*;
    Iterator allAttachments = message.getAttachments();
    AttachmentPart ap1 = null;
    while(allAttachments.hasNext()){
    ap1 = (AttachmentPart)allAttachments.next();
    //Check that the attachment is correct one. By looking at its mime headers
    //Convert the attachment part into its DOM representation:
    if(ap1.getContentType() == "text/xml"){
    //Use the activation dataHandler class to extract the content, then create a StreamSource from
    //the content.
    DataHandler attachmentContent = ap1.getDataHandler();
    StreamSource attachmentStream = new StreamSource(attachmentContent.getInputStream());
    DOMResult domAttachment = getDOMResult(attachmentStream);
    domAttachment holds an xml representation of the attachment.
    Hope this helps.

  • Error parsing XML file from a HttpServletRequest using JAXP

    Hi,
    I am trying to generate an XML file from an HttpServletRequest. I am actually using file uploading method in JSP to send the XML file. I think the parser isnt able to correctly identify the XML file from the message body and hence it is giving some strange error messages. Has anyone of u managed to solve this problem ?
    Code snippet:
    //now build an XML document from the requested input stream
    InputStream in = myRequest.getInputStream();
    try {
    myDocRequest = myParser.parse(in);
    } catch (Throwable t) {
    throw new Exception("Could not build document",t);
    Error message is:
    [Fatal Error] :1:1: Content is not allowed in prolog.
    java.lang.Exception: Could not build document
    at XMLUtil.<init>(XMLUtil.java:91)
    at WCS.doPost(WCS.java:44)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Thread.java:534)
    Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.
    at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
    at XMLUtil.<init>(XMLUtil.java:89)
    ... 20 more
    Actually if i just print out the message, it gives something like this:
    -----------------------------7d63dc71b06b2
    Content-Disposition: form-data; name="W"; filename="C:\work_projects\Capas.xml"
    Content-Type: text/xml
    <?xml version="1.0" encoding="UTF-8"?>
    <GetCapabilities version="1.0.0" service="wcs">
    <section>/WCS_Capabilities/Capability</section>
    </GetCapabilities>
    -----------------------------7d63dc71b06b2--
    Cheers.

    The ServletInput stream contains this:
    -----------------------------7d63dc71b06b2
    Content-Disposition: form-data; name="W"; filename="C:\work_projects\Capas.xml"
    Content-Type: text/xml
    <?xml version="1.0" encoding="UTF-8"?>
    i.e., its the HTTP File Upload MIME stuff, followed by the XML. You need to wrap around the input stream something that can decode the HTTP MIME stuff and let you get at the XML itself, i.e., something like: com.orielly.servlet.multipart.MultipartParser (Apache has a similar 'file upload servlet).
    Jeremy

  • How to parse XML files from normal FTP Servers?

    I want to parse xml files from a normal FTP Servers , NOT the sap application severs itself. How can i do that?
    I know how to use the SAPFTP getting and putting files ,but I don't want to download and then parse it.
    Who knows how to parse it directly? I Just need to read the contents into a database.
    Thanks.

    I want to parse xml files from a normal FTP Servers , NOT the sap application severs itself. How can i do that?
    I know how to use the SAPFTP getting and putting files ,but I don't want to download and then parse it.
    Who knows how to parse it directly? I Just need to read the contents into a database.
    Thanks.

  • Resend Message from Seeburger message monitoring

    Hi friends,
    I want to know that is there any possiblity of resending the message from Seeburger message monitoring tool.
    One of the messages failed due to a problem in sender ID.
    I want to resend this message. is it possible ?
    Note: Message send out successfully from communcation channel to AS2 adapter.
    Thanks
    Sunil.

    Hi Sunil,
       Please let me know what error you can see in Seeburger Workbench.
    In My view you can see the below type of error with State u201CError on send, will be retriedu201D
    If Any Message failed in AS2 Adapter may be due to any reason
    1. Wrong Sender/ Receiver ID
    2. Wrong URL
    3. Firewall rules are not in place
    4. Partner Production site is down and you are unable to connect to him
    Messages with above errors will appear with Success Flag in SXMB_MONI. But they will be caught by Seeburger Adapter and will be in the Error Status in SEEBURGER WORK BENCH
    The only way to find/restart those messages is go to Runtime Work Bench Messages Monitoring --> Messages form Component (Adapter Engine) ---> System Error Status.
    Any Message which failed in Seeburger Level can be seen only in Runtime Workbench.
    Regards,
    Rama.

  • How to parse XML content in JMS Message...

    Hi everybody,
    I am currently developing a Message-Driven Bean and has some problem parsing the XML data that contains in the JMS body.
    The XML data is contained in TextMessage (JMS message type) and in order to parse the data, I need to use the DOM builder, which is expecting to read from a file (e.g. abc.xml).
    My question is how can I use TextMessage (can be output to a String) as the input source instead of a file.
    Thanks in advance.

    Hi Boon,
    "Boon Keong" <[email protected]> wrote in message
    news:3dd46800$[email protected]..
    I am currently developing a Message-Driven Bean and has some problemparsing the XML data that contains in the JMS body.
    >
    The XML data is contained in TextMessage (JMS message type) and in orderto parse the data, I need to use the DOM builder, which is expecting to read
    from a file (e.g. abc.xml).
    >
    My question is how can I use TextMessage (can be output to a String) asthe input source instead of a file.
    What about this:
    DocumentBuilder db = ...
    Document doc = db.parse(new InputSource(new
    StringReader(textMessage.toString()));
    or
    Document doc = db.parse(new
    ByteArrayInputStream(textMessage.toString().getBytes()));
    Regards,
    Slava Imeshev

  • Parsing XML files from application server

    I need to read  an XML file from the application server. This can be done using OPEN DATASET in BINARY MODE and reading into internal table of type binary data.
    But inorder to parse the document using the iXML library, i need to pass the filesize of the XML file that is read into internal table.
    Please let me know how to calculate this filesize ?

    Hi ,
    Check the FM : /SAPDMC/LSM_F4_SERVER_FILE.
    Inside this FM , subroutine below exists.The main program for routine is /SAPDMC/LLSMW_AUX_020F02.
    Call this routine from your program. You will get the length in bytes from the field len of table pt_file.
    data:
      begin of gs_file,
        directory(75) type c,              " name of directory.
                                           " (possibly truncated.)
        name(75)    type c,                " name of entry.
                                           " (possibly truncated.)
        type(10)    type c,                " type of entry: directory, file
        *len(8)      type p,                " length in bytes*
        owner(8)    type c,                " owner of the entry
        mtime(6)    type p,                " last modification date,
                                           " seconds since 1970
        mode(9)     type c,                " like "rwx-r-x--x":
                                           " protection mode
        errno(3)    type c,
        errmsg(40)  type c,
        mod_date    type d,
        mod_time(8) type c,                " hh:mm:ss
        subrc like sy-subrc,
    end of gs_file.
    DATA : pt_file LIKE TABLE OF gs_file.
    DATa : p_ok.
      PERFORM /sapdmc/llsmw_aux_020f02(directory_contents_get)
      TABLES   pt_file
                                USING    '/TMP' ""!!! Here is your filepath
                                CHANGING p_ok

  • Outlook 2010 not deleting messages from Deleted Messages

    I have Outlook 2010 standalone on a 64-bit Win Pro system.  I have settings to empty Deleted Messages at exit and to delete messages from the server when downloaded by this instance of Outlook (POP3).
    BUT ... when I exit Outlook, I get the dialogue about ok to delete messages, I accept deletion, and when I restart Outlook, not only are the messages back in the Deleted Messages folder, but the messages I deleted in the last session are back in the Inbox
    and Junk Email folders!  Manually emptying the Deleted Messages folder does not solve the problem.
    And yes, I have checked that I have my POP3 settings in Outlook correctly set.

    Could you just check this?
    In Outlook 2010 Click the File tab, Click Account Settings, Click on account settings again, Hightlight existing email account, click change, click more settings..., click Advanced tab, in Delivery section uncheck box "Leave a copy of message on the server.",
    click OK, click next, after test email has been sent click close, click finish
    BR
    Mads 
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • What can I do my iPhone 5 can not recieve picture messages from text messaging or send messages  . only time I can send picture messages or recieve picture messages through iMessage . What do I do ?

    My iphone 5 that I just got on March 14,2015 will not send or recieve  picture messages through text messaging I can only recieve and send picture messages from  iMessage

    Hi, cymoneW. 
    Thank you for visiting Apple Support Communities. 
    I understand that you are unable to send or receive picture messages via the cellular data network.  I would check to make sure that MMS is enable in settings.  This setting is located in Settings > Messages and MMS Messaging.  If the issue persists, try the troubleshooting steps in the article below. 
    If you can't send or receive messages on your iPhone, iPad, or iPod touch
    -Jason H. 

  • Mail:Cannot erase messages from Deleted Messages folder located on my mac

    Hi,
    I recently ran a script to discover that I have hundreds of thousands of messages sitting in the Deleted Messages folder located on my mac. I tried to erase them but no luck, no error messages of any kind but the messages are still there. Can anyone help with me with this as these unwanted messages are taking up a lot of space. I have run a disk verify just to check permissions etc and all is ok.
    Many thanks

    Hi,
    Many thanks for you reply. Yes it looked like the deleted messages from an old exchange account I had had were sitting in a folder on my mac and this was visible in the sidebar. However it was not simply called deleted messages it was named deleted messages (xxx xxx) where xxx xxxx was the name of the old mailbox. So when I went to mailbox to erase deleted messages this folder was not picked up. So I moved everything in the folder to the trash folder (took a long time) and then selected the option to erase trash on quitting. It took hours and hours when I quit mail but I left it running overnight and now the folder is empty and mail is functioning ok. Thanks again for your help

  • OpenESB: read message from Normalized Message Router

    Good morning,
    I have to build a simple Business Monitor System.
    I use NetBeans 6.5, Glassfish v2 with OpenESB.
    My Question is:
    there is a way to read messages exchanged between two different application (for example my CASA application and Salesforce CRM wsdl)?
    Obviously all application are attached to the ESB.
    I know that all SOAP messages are transformed to Normalized Message (by Normalized Message Router) and then sent over the ESB, so I think there is a way to read all messages (but I didn't find it).
    Thanks
    Matteo

    Thank you Mark,
    I modified the test Observer a bit just to dump the message exchange. Actually it seems to work, except for a weird thing: The message count is always 0 for any message exchange I log, like there are no Normalized Messages in the MessageExchangeImpl. Am I missing something obvious? I'm just calling the toString() of the MessageExchage in the run() method of the ObserverLifeCycle class, I'd expect to see some messages sometime.
    ExchangeId: 3389965929356-12104-134580929097830184
    Pattern: http://www.w3.org/2004/08/wsdl/in-out
    Role: CONSUMER
    Consumer: Null
    Provider: Null
    Index: 1 SynchState: NONE
    EndpointLink: caMainSample,casaService1,casaPort1
    Status: ACTIVE Location: LOCAL Transaction: None
    Service: null
    Endpoint: http://enterprise.netbeans.org/bpel/MainSample/MainProcess,MainPL,servicePortTypeRole_myRole
    Operation: {http://j2ee.netbeans.org/wsdl/SubSample/service}serviceOperation
    Interface: null
    Properties Count: 0
    DeltaProperties Count: 4
    Name: com.sun.jbi.messaging.messageid
    Value: 1
    Name: com.sun.jbi.observer.receiver
    Value: sun-bpel-engine
    Name: com.sun.jbi.messaging.groupid
    Value: b0ea5c93-151c-4559-877f-e49bd6bdac35
    Name: com.sun.jbi.observer.sender
    Value: sun-http-binding
    Message Count:   0
    Thank you & regards
    M.

  • Parse xml response from PL/SQL

    Can anyone please help me parse the xml below?
    DECLARE
       l_response     CLOB;
       g_system_id    VARCHAR2 (255);
       g_session_id   VARCHAR2 (255);
       g_user_id      VARCHAR2 (255);
    BEGIN
       l_response :=
          '--uuid:18cb22a2-11cc-43f4-bfea-c213da179d30+id=156
    Content-ID: <http://tempuri.org/0>
    Content-Transfer-Encoding: 8bit
    Content-Type: application/xop+xml;charset=utf-8;type="application/soap+xml"
    <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header><a:Action s:mustUnderstand="1">http://tempuri.org/ILoginService/LoginByUserNameResponse</a:Action><a:RelatesTo>urn:uuid:cf410a05-23d4-4b92-a22c-329cbc19fbe7</a:RelatesTo></s:Header><s:Body><LoginByUserNameResponse xmlns="http://tempuri.org/"><LoginByUserNameResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema"><XObject.m_element i:type="x:string" xmlns="">&lt;OnlineContext SystemId="{19E0DDB4-5FA5-41EE-B624-AEA762865A6C}" SessionId="{F23D32A4-B325-4BFA-9E90-39CA253E843C}" UserId="{2C6ABE4C-D356-46F0-B4BE-9C4F0A36A522}" /&gt;</XObject.m_element></LoginByUserNameResult></LoginByUserNameResponse></s:Body></s:Envelope>
    --uuid:18cb22a2-11cc-43f4-bfea-c213da179d30+id=156--';
          SELECT systemid, sessionid, userid
            INTO g_session_id, g_system_id, g_user_id
            FROM XMLTABLE (
                    xmlnamespaces ('http://www.w3.org/2003/05/soap-envelope' AS "data"),
                    'data:LoginByUserNameResponse/LoginByUserNameResult/XObject.m_element/OnlineContext'
                    PASSING xmltype (l_response)
                    COLUMNS systemid VARCHAR2 (50) PATH '@OnlineContext',
                            sessionid VARCHAR2 (50) PATH '@OnlineContext',
                            userid VARCHAR2 (50) PATH '@OnlineContext') xt;
       DBMS_OUTPUT.put_line (
             'Session id '
          || g_session_id
          || ' System id '
          || g_system_id
          || ' User id '
          || g_user_id);
    END;
    Thanks.

    This gets you a little bit closer
    declare 
    -- Local variables here
    l_response     CLOB;
    g_system_id    VARCHAR2 (255);
    g_session_id   VARCHAR2 (255);
    g_user_id      VARCHAR2 (255);
    begin
    -- Test statements here
    l_response := '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"> 
    <s:Header>
        <a:Action s:mustUnderstand="1">http://tempuri.org/ILoginService/LoginByUserNameResponse</a:Action> 
        <a:RelatesTo>urn:uuid:cf410a05-23d4-4b92-a22c-329cbc19fbe7</a:RelatesTo>
    </s:Header>
    <s:Body>
        <LoginByUserNameResponse xmlns="http://tempuri.org/"> 
           <LoginByUserNameResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:x="http://www.w3.org/2001/XMLSchema"> 
              <XObject.m_element i:type="x:string" xmlns=""><OnlineContext SystemId="{19E0DDB4-5FA5-41EE-B624-AEA762865A6C}" SessionId="{F23D32A4-B325-4BFA-9E90-39CA253E843C}" UserId="{2C6ABE4C-D356-46F0-B4BE-9C4F0A36A522}" /></XObject.m_element>
              </LoginByUserNameResult>
          </LoginByUserNameResponse>
      </s:Body>
    </s:Envelope>';
        SELECT systemid, sessionid, userid
          INTO g_session_id, g_system_id, g_user_id
          FROM XMLTABLE (
                  xmlnamespaces ('http://www.w3.org/2003/05/soap-envelope' AS "s", 
                                 'http://tempuri.org/' as "data"), 
                  's:Envelope/s:Body/data:LoginByUserNameResponse/data:LoginByUserNameResult/XObject.m_element/OnlineContext'
                  PASSING xmltype (l_response)
                  COLUMNS systemid VARCHAR2 (50) PATH '@SystemId',
                          sessionid VARCHAR2 (50) PATH '@SessionId',
                          userid VARCHAR2 (50) PATH '@UserId') xt;
    DBMS_OUTPUT.put_line (
           'Session id '
        || g_session_id
        || ' System id '
        || g_system_id
        || ' User id '
        || g_user_id);
    end;    
    You will need to manually parse that CLOB and pull out the XML string itself from the response.  That can be done via SUBSTR and INSTR looking for the first < and last > in what you showed at least.  Updated from previous version to work properly with the xmlns="", which resets the default namespace back to the default value.  The XPath was corrected to reflect proper prefix usage.

  • Need to parse xml or json file but am not a programmer

    My VPN provider has an api I can use to download the current servers in xml or in json format. I want to parse it and have it show me the top 3 servers based on the current load but after googling linux xml parser tutorial I found the format of the xml file I have is very different than what is expected. Here is a sample.
    <?xml version='1.0' standalone='yes'?>
    <status result="ok">
    <servers>
    <servers public_name="Acamar" country_name="United States" country_code="us" location="Miami" continent="America" bw="47" bw_max="1000" users="57" currentload="4" />
    <servers public_name="Acrux" country_name="Netherlands" country_code="nl" location="Amsterdam" continent="Europe" bw="25" bw_max="1000" users="20" currentload="2" />
    <servers public_name="Acubens" country_name="Sweden" country_code="se" location="Uppsala" continent="Europe" bw="121" bw_max="1000" users="64" currentload="12" />
    <servers public_name="Alhena" country_name="Canada" country_code="ca" location="Toronto, Ontario" continent="America" bw="269" bw_max="1000" users="84" currentload="26" />
    <servers public_name="Alkaid" country_name="United States" country_code="us" location="Chicago, Illinois" continent="America" bw="210" bw_max="1000" users="88" currentload="21" />
    </servers>
    </status>
    The tutorials I found expect these things like "public_name" and "bw" to be inside their own entries like <public_name>Acamar</public_name>. Can someone recommend a good tool that doesn't need me to know perl or python I can use to: pull out all servers in Canada with bw_max of 1000 for example?
    Last edited by maggie (2015-05-30 11:49:45)

    @maggie: That is easily done with XPath expressions, for example:
    xmlstarlet sel -t -m '//servers[@country_code="us"]' -c '.' -n vpn.xml
    xmlstarlet sel -T -t -m '//servers[@country_code="us"]' -v @public_name -o " " -v @bw -n vpn.xml
    xmlstarlet sel -t -m '//servers[@country_code="us"]' -v '@public_name' -o ": " -v '@currentload' -n vpn.xml
    xmlstarlet sel -t -m '//servers[@country_code="us" and @currentload<15]' -v '@public_name' -o ": " -v '@currentload' -n vpn.xml
    xmlstarlet sel -t -m '//servers[@currentload<15]' -v '@public_name' -o ": " -v '@currentload' -n vpn.xml
    http://www.w3schools.com/xpath/default.asp
    Edit: If you use json and jshon, then you'll have to do the sorting and filtering in the shell
    jshon -e servers -a -e country_code -u -p -e public_name -u -p -e bw -u <vpn.json | {
    # filter country_code
    while read -r country_code && read -r public_name && read -r bw; do
    [ x"$country_code" = x"ca" ] && echo "$public_name $bw";
    done
    } | sort -k2,2nr -k1,1d # sort second field (bw) numeric reverse, if equal use dictionary sort on first (name)
    Last edited by progandy (2015-05-31 05:47:50)

  • How do I suppress ARP movement messages from the message logs?

    In FreeBSD, one is able to remove ARP movement notices such as the below:
    arp: 10.10.10.170 moved from 00:30:48:23:8d:5d to 00:30:48:23:8d:5e on en0
    by doing a `sysctl net.link.ether.inet.logarpmovements=0`.
    Apparently I can't do this here, and these messages are flooding my logs. What can I do to suppress these?
    G5 Mac OS X (10.4.5)

    Exactly the same problem as above but "hpzexe"

  • Why can't I send a text message from my message browser to an iPhone?

    How do I send a text from my ipad2 to an IPhone?  I type the message and it will not send.

    Have you tried a hard reset (holding the sleep/wake button and home button at the same time until the screen goes black and the apple logo appears)? If so, and if you're still having issues, have you tried to restore through iTunes as a backup? If so, and if you're still having problems, have you tried restoring through iTunes as a new device?

Maybe you are looking for