You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Joel Grenon <jg...@covistra.com> on 2002/12/01 22:07:21 UTC

RE: first Document Style client

Just an advise, start with the WSDL2Java tool and try to understand
what's going on. You'll find most of your anwers. I think this is the
best learning approach. 

Joel

-----Original Message-----
From: Dan [mailto:dan@mcenter.com] 
Sent: Monday, January 13, 2003 4:04 PM
To: axis-user@xml.apache.org
Subject: first Document Style client


I'm just getting started with XML, SOAP, and Axis.  I'm in the early
"figuring it out" stages.  For experience, I'd like to try writing a
bare bones client to get the service at:

	http://www.webservicex.net/uszip.asmx

using the GetInfoByZipCode function.  I've written an RPC client that
can communicate with the service, but I don't know how to handle the
<NewDataSet> and child elements, since this is a document type service.

I get a 

    [ERROR] Call - -Exception: <org.xml.sax.SAXException:
SimpleDeserializer 
    encountered a child element, which is NOT expected, in something it 
    was trying to deserialize.>

because I'm expecting a string return type but get a NewDataSet with
children elements.


I'm aware of the WSDL2Java tool, but since I'm learning I prefer to
"write it myself" so I can get a better understanding of what's going
on.  I'm guessing that the "NewDataSet" element is defined somewhere on
the site and I'd use this to parse the XML portion of the return.

If someone could give a little insight as to what the steps would be to
do this, I'd be thankful.  Is the "XML-portion" (<NewDataSet>) of the
return available in my Call object (or someway to get it)?  Once I get
the result XML, what do I use to parse the XML elements "automatically"
using the <NewDataSet> definition?



The service returns this XML:

<?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>
  <GetInfoByZIPResponse xmlns="http://www.webserviceX.NET">
    <GetInfoByZIPResult>
      <NewDataSet xmlns="">
        <Table>
          <CITY>Forest Park</CITY>
          <STATE>GA</STATE>
          <ZIP>30297</ZIP>
          <AREA_CODE>404</AREA_CODE>
          <TIME_ZONE>E</TIME_ZONE>
        </Table>
      </NewDataSet>
    </GetInfoByZIPResult>
  </GetInfoByZIPResponse>
</soap:Body></soap:Envelope>