Using DOM to parse SOAP fault doesn't work properly

why, when I run the following:
import java.io.IOException;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class ParseFaultDom {
public void operation(String uri) {
System.out.println("Parsing XML File: " + uri + "\n\n");
String faultCode = "";
String faultString = "";
try {
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(uri);
// should only be one apiece here
NodeList faultCodes = document.getElementsByTagName("faultcode");
NodeList faultStrings=document.getElementsByTagName("faultstring");
Node codeNode = faultCodes.item(0);
Node stringsNode = faultStrings.item(0);
faultCode = codeNode.getNodeValue();
faultString = stringsNode.getNodeValue();
System.out.println("code: " + faultCode);
System.out.println("string: " + faultString);
} catch(ParserConfigurationException e) {
System.out.println("Error creating parser: " + e.getMessage( ));
} catch(IOException e) {
System.out.println("Error reading URI: " + e.getMessage( ));
} catch (SAXException e) {
System.out.println("Error in parsing: " + e.getMessage( ));
public static void main(String[] args) {
if (args.length != 1) {
System.out.println("Usage: java ParseFault [XML URI]");
System.exit(0);
String uri = args[0];
ParseFaultDom pfd = new ParseFaultDom();
pfd.operation(uri);
giving it the following xml file as input:
<?xml version='1.0' encoding='UTF-8'?>
<s:Envelope xmlns:s="http://www.w3.org/2001/06/soap-envelope/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<s:Body>
<s:Fault>
<faultcode xsi:type="xsd:string">Client</faultcode>
<faultstring xsi:type="xsd:string">
Invalid value given for identifier field: "-1".
</faultstring>
<details>
<a>a</a>
<b>b</b>
<c>c</c>
</details>
</s:Fault>
</s:Body>
</s:Envelope>
do I get the following output:
Parsing XML File: fault.xml
code: null
string: null
In other words, it finds the tags I'm looking for, but it isn't getting the tag value, apparently.... I can add more instances of each tag, or delete them altogether, and the program raises the appropriate errors.... so it's is finding the tags inside the file, it just apparently doesn't pick up the value for some reason....
thanks anyone who can help... this should be simple, but it doesn't want to work for me... bad karma?

First of all, thanks a million for posting replies to my first two posts on these forums, you don't realize how much you have helped me. I feel bad for not assigning duke dollars so you could get them, so I owe you a few :)
Anyway, I see what was going on now, my thinking was at first that a Node consisted of a tag and it's value, and now I see that those are each a distinct Node element. So now I see that the enclosed text is itself a separate Node object, so I needed to get the child node of codeNode and then call getNodeValue on it to get the text I was looking for... ah, the life of a programmer...
anyway, thanks again!!!

Similar Messages

  • How to ignore empty text element while using DOM to parse xml??

    hi everyone,
    i am using DOM to parse an xml file. But i dont know how to cinfig the DocumentBuilderFactory to ignore empty text elements.
    For example, i have an xml file like this:
    <?xml version="1.0" encoding="UTF-8" ?>
    <root>
        <child>Tom</child>
        <child>Jerry</child>
    </root>I used the following codes to parse:
    String fname = "Tom-and-Jerry.xml";
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setIgnoringElementContentWhitespace(true);
    factory.setIgnoringComments(true);
    DocumentBuilder builder = domFactory.newDocumentBuilder();
    // Generate a DOM tree from the DOM builder.
    org.w3c.dom.Document dom = builder.parse(new File(fname));
    org.w3c.dom.NodeList list = dom.getChildNodes();
    for (int i=0; i<list.getLength(); i++) {
        System.out.println("Child No."+i);
        System.out.println("NodeName="+list.item(i).getNodeName());
        System.out.println("NodeType="+getType(list.item(i).getNodeType()));
        System.out.println("NodeValue="+list.item(i).getNodeValue());
        System.out.println();
    }The result is not exactly what i want ---- there are 5 children in list!! The 1st, 3rd and 5th are #text and their values are all empty. Only the 2nd and the 4th are the child that i expect.
    It is really troublesome to get all these silly empty texts as sub elements. I tried to get rid of them, but i failed. I just dont understand why factory.setIgnoringElementContentWhitespace(true) did not work.
    Anyone can help me? thanks.
    Heavy ZHENG

    I just dont understand why factory.setIgnoringElementContentWhitespace(true) did not work.That only does something if the XML has a DTD that enables it to know what whitespace can be ignored and what is significant. The API documentation for the method refers you to this document:
    http://www.w3.org/TR/REC-xml#sec-white-space

  • A65-S159 - I can't use the CD Recovery because my CD/DVD doesn't work properly

    Hi, I need help to reinstall the system and drives. It's a Satellite A65-S159. The CD/DVD doesn't work properly. Rarely, the CD/DVD can read a DVD. So I can't use the CD Recovery. What may I do?
    Thank you,
    Cabula, Brazil

    There are two ways to run the recovery DVD, one is from Windows.  Instead power ont he computer with the disk in the drive.  And imediatly after powering on start pressing the F12 key.  After a few seconds you should see a boot device menu that you can select the CD/DVD drive to boot from.  Try that and let us know if you got the boot menu, and if the disk worked.
    This signature left intentionally blank.

  • After las update some menus doesn't work properly. Ther is non possibility to use mouse. Why?

    After las update (9.2.1) some menus doesn't work properly. Ther is non possibility to use mouse. Why?

    Operating System?

  • I m using apple mac pc, when we start windows 7 , apple mouse doesn't work properly it take to much time to gain signals from the pc and many times it not work but when we use mac it moves fastly and works properly. please suggest me. thanks ravi

    i m using apple mac pc, when we start windows 7 , apple mouse doesn't work properly it take to much time to gain signals from the pc and many times it not work but when we use mac it moves fastly and works properly. please suggest me.
    thanks
    ravi
    <Email removed by Host>                                                                                                                                                                                                                                       

    sounds more like Bluetooth rather than moue, but w/o knowing w/o posting mac model type/year we... will... not... know... what you have
    All computers are personal computers, a PC though is also "non-Apple" in common usage.
    Mac also is platform and OS.
    Very confused reading what you are trying to tell us.

  • I have purchased the new apple earpods a while ago (few months). And I was wondering if I can use my warranty cause one earpod doesn't work anymore

    I have purchased the new apple earpods a while ago (few months). And I was wondering if I can use my warranty cause one earpod doesn't work anymore.
    So please help!

    See this:  Using iPad or iPod with multiple computers, http://support.apple.com/kb/HT1202

  • Satellite P500-127: microphone or sound doesn't work properly using skype

    Hi Toshiba team,
    Recently bought a new notebook.
    However the microphone or sound driver (connexant pebble high definition ) doesn't work properly when using skype. Also read about this matter in various forums such as the skype forum.
    People encountered similar problems such as:
    We can usually talk for a bit longer than 20 seconds, however the call will drop at a random time between 1 and 15 minutes. The strange part is that sometimes the quality of the call is good, but more than often my friend can only hear *half of what I am saying* while I usually do not have a problem hearing what has been said. The video will work so my friend can see me talking but can simply not really hear what I am saying.
    Before the drop the call will usually freeze for a couple of seconds and then skype sometimes crashes. We have tried talking together without the video, however the problem remains.
    I also found a suggestion by the toshiba service, just to simply increase the volume under control panel etc, but it doesn't work either..
    Can you please help me on this one?
    Cannot use skype at all as it just to annoying for everyone I talk to.. Quality is just to poor!!
    Many many thanks
    +Message was edited: link has been removed - not allowed+

    Hi
    Every day I use Skype with the internal webcam, microphone and speakers but I didnt have any problems as yet.
    In your case I would try updating the drivers. Therefore download the latest sound and webcam driver (microphone is a part of webcam). Both you can get here:
    http://eu.computers.toshiba-europe.com > Support & Downloads > Download Drivers
    If your friend cant hear you, check also the settings for internal microphone. I have activated microphone boost in Windows sound settings so I could improve the microphone quality.
    By the way: Do you use the latest version of Skype? With older Skype version I had also some problems on Windows 7. As far as I know only newest version is fully Windows 7 compatible.

  • My MacBook adaptor stopped working so I used my roommates. Now hers doesn't work after just one day. What happened?

    My MacBook adaptor stopped working so I used my roommates. Now hers doesn't work after just one day. What happened?

    Hello, cherilyn.  
    Thank you for visiting Apple Support Communities.  
    I understand that a couple MagSafe adapters will no longer charger a couple MacBooks.  Here are the best troubleshooting steps to go through when experiencing this issue.  
    Apple Portables: Troubleshooting MagSafe adapters
    Cheers, 
    Jason H.  

  • My palm m105's touch screen doesn't work properly after a sync.

    I dug out my old m105, put new batteries in and start it. On first launch it auto runs the alignment tool, and after touching all the points it goes to the main screen and works fine. No problem till here.
    Now, I plug it into my old computer which still has the palm software with my apps, and I run the sync operation (from the palm device sync manager, cause I lost my cradle and I'm connected via the serial cable), and it syncs fine BUT, here comes the problem, when it finishes the sync (successfully) the touch screen is all misaligned. I can't go back to the home screen or do anything useful.
    My palm m105's touch screen doesn't work properly after a sync.
    I dug out my old m105, put new batteries in and start it. On first launch it auto runs the alignment tool, and after touching all the points it goes to the main screen and works fine. No problem till here.
    Now, I plug it into my old computer which still has the palm software with my apps, and I run the sync operation (from the palm device sync manager, cause I lost my cradle and I'm connected via the serial cable), and it syncs fine BUT, here comes the problem, when it finishes the sync (successfully) the touch screen is all misaligned. I can't go back to the home screen or do anything useful.
    Thanks in advance!
    Post relates to: Palm m105
    Post relates to: Palm m105

        Maldoman578,
    Let's help solve this mystery together! Is your screen freezing after every reboot? Is there any physical/liquid damage on the device? When did this issue begin? Did you notice this after a recent update or application download?
    EfrainM_VZW
    Follow us on Twitter @VZWSupport

  • Quick Look doesn't work properly

    I can get folders to show in Quick Look by highlighting them and pressing the space bar or eye icon but then...a new window with a large icon of the folder appears and the only controls at the bottom are to open in full screen or close the window.
    Have looked in Preferences and trashed the Quick Look daemon file but no change.
    I've not tried to use Quick Look before (been running Leopard for a couple of months now) and am trying it now as a result of reading an item about it in the Mac Tips column so I don't know if it's a new problem or if it has always been dysfunctional.
    Any suggestions for solving this would be gratefully received as, on reading what it can do, it looks like a very useful tool.
    Thanks
    Gordon

    Quick Look doesn't work that way, unfortunately, there is a third party solution available that produces the behaviour you want. The basic functionality of Quick Look is to enable fast access to files and not folders...

  • What can I do if my CD or DVD drive doesn't work properly in Windows 8?

    QuestionWhat can I do when if my laptop CD or DVD drive doesn't work properly in Windows 8?
    AnswerNote: For help with this issue in Windows 7, please see this article.
    To get your CD or DVD drive working correctly, try these suggestions in the order listed.
    Reinstall the Driver
    Hold the Windows key and press the 'x' key to open a menu in the lower-left. In this menu, select "Device Manager." Expand "DVD/CD-ROM drives." Right-click the entry for the CD/DVD drive nested under "DVD/CD-ROM drives," then select "Uninstall." Finally, restart the computer. The computer will reinstall the drivers for the drive.
    Power Cycle
    Even when your laptop is off and unplugged, residual power can still be held in some components. While this is normal, clearing it can help with some hardware problems. Perform these steps to complete what’s called a power cycle.
    Ensure the laptop is turned off.
    Unplug the laptop's AC power cable.
    Unplug all wires and peripherals. This includes CDs, DVDs, USB sticks, mice, printers, and any other accessories.
    Remove the battery (if the model has a removable battery). If the model does not have a removable battery, check your user's guide to determine if you have a pinhole reset on the bottom. If you do, press this.
    Hold down the power button for thirty seconds.
    Reattach the battery if removed.
    Connect the AC adaptor to the power socket that was confirmed to be working in the first step.
    Connect the other end of the AC adaptor to your computer.
    Start the computer and test the drive
    Microsoft Fix-it
    Your computer may exhibit one or more of the following symptoms:
    Your CD or DVD drive no longer appears in Windows
    Your CD or DVD drive does not read or write and is shown as disabled
    The media in your CD or DVD drive cannot be read
    The media cannot be written to a CD or DVD inserted into the drive
    You receive an error message about your CD or DVD drive
    If any of these symptoms apply to your computer, use Microsoft Fix-it troubleshooter available here.
    System Restore
    Try using System Restore to restore to the most restore point from before the problem arose.
    How To: Understanding System Restore, Refresh, Reset, and, Recovery options in Windows 8 + Video
    System Recovery
    If the System Restore doesn't solve the issue, you could try a System Reset. Resetting your laptop to its original, out-of-the-box state is a great way to eliminate software as a possible cause of the problem. Note that doing a system reset will return the laptop to its default conditions, completely wiping your data. Information on how to perform a system recovery can be found in your user's guide.
    For more information on performing a recovery, see the following article:
    How To: Understanding System Restore, Refresh, Reset, and, Recovery options in Windows 8 + Video
    Contact Customer Support
    If the drive doesn't work after performing a recovery, it may be due to hardware failure. Please call customer support or seek servicing.

    See this Microsoft article - http://support.microsoft.com/kb/314060/en-us  For ways to fix manually
    and/or use the proper microsoft fixit 8.1 and 8 or the other one for Windows 7, Vista, and XP listed below.
    (these are from the Microsoft article)
    Resolution 2: Use the CD/DVD Fix it troubleshooter
    To automatically fix common issues with CD or DVD drives, click Run now, and then follow the on-screen instructions. Windows 8.1 and Windows 8   
    The Automatically diagnose and fix common problems with CD or DVD drives troubleshooter may automatically fix the problem described in this article.
                                    This troubleshooter fixes many problems. learn more
    Run now
    Windows 7, Windows Vista and Windows XP
    The Automatically diagnose and fix common problems with CD or DVD drives troubleshooter may automatically fix the problem described in this article.
                                    This troubleshooter fixes many problems. learn more
    Run now
    If your problem is not solved, try the next
    S70-ABT2N22 Windows 7 Pro & 8.1Pro, C55-A5180 Windows 8.1****Click on White “Kudos” STAR to say thanks!****

  • Satellite Pro L20 doesn't work properly with USB Fast Track audio i.f.

    Hello!
    I have used my Fast Track USB on new Toshiba Satellite L40 and I never had problems with it. I could set low latency and I did few songs with it.
    Yesterday I bought another notebook, thinking of home recording studio. It's used Toshiba Satellite Pro L20. It doesn't work properly with my interface. When I listen music on Winamp or do anything on Fruity Loops I hear loud clicks, pops, noises. They introduce samples, or they appear during playback or after a sample is stopped.
    I noticed, drivers for Satellite Pro L20 are a problem. Its not supported by Toshiba anymore?! The only drivers for chipset are very old and you can download em only from Toshiba website. The chipset is ATI Xpress 200M. Its drivers are with graphic card. Recently I noticed you can download "ATI Catalyst Legacy Display Driver for Windows XP - Motherboard/IGP Drivers 9.11" and CRACK IT to make it possible to install on mobile unit such as L20. Yep its funny but its impossible to do otherwise!
    things I have tried and they still not help:
    # drivers replacement, original were released in 2004. I installed recent version.
    # driver settings, low latency, high latency
    # asio and different settings
    # pluging the interface to another usb socket.
    # trying what happens when I use battery and when I use adapter
    # updated bios
    # turned off onboard units such as wifi card, sound card
    # checked IRQ list
    pops still appear.
    my config:
    Toshiba Satellite Pro L20
    Win XP Home SP3
    Celeron M 1,5GHz
    896Mb ram
    M-Audio Fast Track USB, drivers: 6.0.2
    Kind regards

    Thanks for answer. I still have L40 but I try to run my homerecording on L20. The L40 is now used by whole my family. It's possible to swap them but there's a problem - L20 has Norway keyboard and I'm the only person at home who doesn't often look down while typing. In Poland, we use standard ms keyboard. I'd buy special stickers, it's about only to make special chars get back to their places.
    I installed Windows on this computer end set it to best performance possible.
    Since I created this thread, guys from M-Audio support tried to solve my problem - nothing helped. I think potential solutions are exhausted.
    Message was edited by: lidia.pochron

  • The cable doesn't work properly when connected as data cable.

    Hi,
    I have recently encountered problem of the cable. The thing is that if i use it just for charging with the plug, it works fine. But when i wanna use it with computer (i.e., accessing itunes, etc) or with my car, it doesn't work properly, it keeps switching between charging and discharging very fast. I will appreciate your quick support!
    Regards,
    Farhan

    Just for all the people to know, I found out the solution. You have to mark the correct side of the charging cable which connects at inlet of the phone. Because this point acts as a chip when used as data cable or auxiliary use (car,etc). That's why it charges with the plug on any side. I don't know what's the frequency of it happening to iphone 5s users, because I bought it recently (iOS 7.1.1) Hope it helps to others in future.

  • Key Command for "Go to Next Marker" doesn't work properly

    Hi there!
    While using Logic Pro 9.1.8 with Mountain Lion (10.8.2), it seems that the Key Command for "Go to Next/Previous Marker" doesn't work properly.
    The only effect is, that a grey rectangle moves in the top of the Arrange Area while ignoring the Markers itself.
    Any suggestions to solve it or is it me that is misbehaving?
    Cheers, GJ

    Hi
    The commands work correctly here on the same OS etc: Cycle Locators jump to the next/prev marker and the Playhead jumps to the Start of the Marker.
    Default KC are Control Command +Arrow Left/right
    Step 1: check you are using the correct key command :-)
    CCT

  • Site doesn't work properly

    Hi all, I'm PHP programmer, and i have some questions in my area. I have 3 Apple computers (MacBook Air, MacBook and MacBook Pro). There is one site, made by our group, that doesn't work properly on my MacBook Pro and MacBook Air, while other sites work excellent on that 2 computers. And what is more interesting, site, that doesn't work on my MacBook Pro and Air, WORKS on my windows computer, and WORKS on my MacBook. I tried to use this site from different internet provider, but problem was steel actual. I asked 2 of my friends to try this site on their MacBooks Pro - the same (it doesn't work properly, links don't open), but any other computer (under windows, or iPad, or my Macbook) can work with this site excellent. Can anybody help with this? Are there any specifications in program code to MacBook Air work with that site also excellent?

    It's working, after using Cyberduck to FTP.

Maybe you are looking for

  • Create Control Cycle(LPK1)

    Hello Experts, Can anybody let me know Is there an Standard SAP Program to load 'Control Cycles(LPK1) into SAP? Thanks for the help.

  • Rubber Band Brush Mode?

    I have searched the helpfile and I don't think this is possible but just thought I'd check to make sure. I have another paint app where it will do a brush mode that is a rubber-band mode.  So if there is a brush that's 25 pixels wide and you go and c

  • Getting rid of my old G4 Power Mac

    I have an old G4 Power Mac (bought around 7 years ago) I want to transfer what is on it onto my new computer before I donate it. What is the best way to hook the 2 together to do this?

  • How do I import movie event to iMovie 9.0.9 from external hard drive back up copy

    I was using an external hard drive as my primary location for iMovie events and projects when that hard drive crashed.  I was able to recover the data and save it to a new hard drive, but now iMovie 9.0.9 does not recognize the iMovie Events that wer

  • How to make interface work ?

    Hello SDNers, I have written the below snippet. Can any one explain now to call the method of the following 2 classes which are implemented within the interdace intf_counter.. REPORT  ZNRD_CLASS_INTERFACE1. interface intf_counter.   methods : set_cou