I don't think you can use your WSDL to validate your XML.  However you can
surely validate it with a XML Schema.  I've never done it but look here...
http://xml.apache.org/xerces-j/schema.html
I guess it's possible.

Good luck!

Steeve...




Pete Roth <[EMAIL PROTECTED]> on 02/08/2001 12:07:33 PM

Please respond to [EMAIL PROTECTED]

To:   "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
cc:    (bcc: Steeve Gilbert/G_STGEORGES/CANAM_MANAC)

Subject:  RE: Xerces XML parsing SOAP response problem


Ok, I checked out the tutorial below, which helped a lot, yet it doesn't
deal with schemas, only DTDs.

I am getting blank text nodes in my DOM document since I am not using a DTD
when parsing my XML (listed below).  Since the WSDL file defines the XML
returned from the Service (this is the XML I'm parsing) is there anyway,
using Xerces, that I may use the WSDL file to validate my XML so that the
blank lines (new lines actually) are ignored and not added to the DOM?

Thanks.

Peter Roth
Telemetry Technologies Inc.
p: 404.231.0021 ext. 1290
e: [EMAIL PROTECTED]


-----Original Message-----
From: Steeve Gilbert [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 02, 2001 10:18 AM
To: [EMAIL PROTECTED]
Subject: RE: Xerces XML parsing SOAP response problem




>That code sample didn't print the data I wanted from the
>response XML (I dunno if you even meant it to)

Nope. ;-)  I just tought you would be able to do the rest.

>Maybe that node is just the name and attributes of that XML element?

Not really.  Attributes and name are get with getAttributes() and
getNodeName().  The "phantom" Element you encounter is probably a space or
a linefeed that was in the XML string.  Those element are not ignored by
the parser unless you provide a DTD so the parser can identify the
whitespace that can be discarded.  Without DTD the parser puts everything
in the DOM.  Hope it help, if not check the tutorial...
http://java.sun.com/xml/jaxp-1.1/docs/tutorial/
I did it and it help me a lot.

bye!

Steeve...





Pete Roth <[EMAIL PROTECTED]> on 02/08/2001 09:56:12 AM

Please respond to [EMAIL PROTECTED]

To:   "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
cc:    (bcc: Steeve Gilbert/G_STGEORGES/CANAM_MANAC)

Subject:  RE: Xerces XML parsing SOAP response problem


Thanks Steve!  That code sample didn't print the data I wanted from the
response XML (I dunno if you even meant it to) but it showed me how I could
get the data (15 in the example) out of the "vnoc_doSOAPTestResult" node.
Thank you so much for all your help.

The mistake I made was using by using
"getFirstChild().getFirstChild()...etc".  Yet, the node that contains the
children was always the second node.  So I need to do,
root.getChildNodes.item(1).getChildNodes.item(1)...etc.

I only just discovered this so I'm not even sure what that first node is.
Maybe that node is just the name and attributes of that XML element?  Hmmm,
I'll have to do some more investigation.  I now know what to do though.

Thanks again Steve and everyone who's helped me on this group.

Peter Roth
Telemetry Technologies Inc.
p: 404.231.0021 ext. 1290
e: [EMAIL PROTECTED]


-----Original Message-----
From: Steeve Gilbert [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 02, 2001 8:38 AM
To: [EMAIL PROTECTED]
Subject: Re: Xerces XML parsing SOAP response problem



Using this code I've reach the last node.

Good luck.

Steeve...

    parser = new DOMParser();
    String xmlString = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
               "<soap:Envelope
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"; " +
               "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"; " +
               "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\";>" +
               "<soap:Body><vnoc_doSOAPTestResponse " +
               "xmlns=\"http://telemetrytech.net/VnocngWebService\";>" +
               "<vnoc_doSOAPTestResult>15</vnoc_doSOAPTestResult>" +
               "</vnoc_doSOAPTestResponse></soap:Body></soap:Envelope>";

    try {
      parser.parse(new InputSource(new StringReader(xmlString)));

    } catch (SAXException se) {
        se.printStackTrace();
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }

    Document document = parser.getDocument();

    //Document Info
    System.out.println(document.getChildNodes().getLength());

    //Result Info
    Node result = document.getFirstChild();
    System.out.print((result.getChildNodes().getLength()) + " in ");
    System.out.println(result.getNodeName());

    //Accessing Essaie
    Node essaie = result.getFirstChild();
    System.out.print(essaie.getChildNodes().getLength() + " in ");
    System.out.println(essaie.getNodeName());

    //Accessing Vnoc
    Node vnoc = essaie.getFirstChild();
    System.out.print(vnoc.getChildNodes().getLength() + " in ");
    System.out.println(vnoc.getNodeName());

    //Accessing Vnoc
    Node numb = vnoc.getFirstChild();
    System.out.print(numb.getChildNodes().getLength() + " in ");
    System.out.println(numb.getNodeName());





Pete Roth <[EMAIL PROTECTED]> on 01/08/2001 04:36:23 PM

Please respond to [EMAIL PROTECTED]

To:   "Soap-dev List (E-mail)" <[EMAIL PROTECTED]>, "Soap-user list
      (E-mail)" <[EMAIL PROTECTED]>
cc:    (bcc: Steeve Gilbert/G_STGEORGES/CANAM_MANAC)

Subject:  Xerces XML parsing SOAP response problem


I am using the XML returned from a soap call with a DOMParser to read the
information returned.  I have a SOAP method that returns a lot of data
(hence why I'm doing it this way) but right now I am trying to get it to
work with a simple SOAP method that returns one element of data.  The XML
returned that is passed to the Parser is listed below along with my client
snippet that attempts to navigate the XML tree and print out the result.
For some reason when I try and get the child of the "SOAP:Body" node, I get
a null pointer.  If I call hasChildNodes() on the body node, I get false
returned.  There is, if you look at the XML being parsed below, more data
in
the Body.

Does anyone know why this is happening?  What I could do to fix this?  Any
help would be greatly appreciated.

Thanks.

Pete


*************
XML that I am trying to parse
****************************************************************************



********************
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XM
LSchema">
  <soap:Body>
    <vnoc_doSOAPTestResponse
xmlns="http://telemetrytech.net/VnocngWebService";>
      <vnoc_doSOAPTestResult>15</vnoc_doSOAPTestResult>
    </vnoc_doSOAPTestResponse>
  </soap:Body>
</soap:Envelope>


****************************************************************************



********************


*************
Client Snip
****************************************************************************



********************
//XML data is in the String "xmlString" at this point, if I print it out it
contains the needed
//data.

//Now create the DOM doc from the XML
DOMParser parser = new DOMParser();

parser.setFeature("
http://apache.org/xml/features/validation/schema-full-che
cking",true);
parser.setFeature("http://apache.org/xml/features/validation/schema",true);
parser.setFeature("http://xml.org/sax/features/validation",true);

//parse the XML (xml is in the String "xmlString"
parser.parse(new InputSource(new StringReader(xmlString)));

Document doc = parser.getDocument();
Element root = doc.getDocumentElement();

System.out.print("root="+root.getNodeName()+" ");
System.out.println("xmlns:soap="+
                   root.getAttribute("xmlns:soap") +
                   " hasChildren="+root.hasChildNodes());
System.out.println("
root.getFirstChild().getNodeName()="+root.getFirstChild().getNodeName());
System.out.println("
firstChildHasChildren?="+root.getFirstChild().hasChildNodes());


****************************************************************************



************




Peter Roth
Telemetry Technologies Inc.
p: 404.231.0021 ext. 1290
e: [EMAIL PROTECTED]

















Reply via email to