James,
Please send your questions to the whole list -- not just to me.
The schema goes in the <types> section of the WSDL file:
<wsdl:types>
<xsd:schema ...
</xsd:schema>
</wsdl:types>
You can bypass the Axis serialization process and use a third party
mapping framework such as JAXB, Castor, or JiBX, but it's a lot more
work than just using Axis serialization. And anyway, I don't think any
of these mapping frameworks are as effective as a true schema
validation done as a handler.
But give it a try, by all means. There's a bit more documentation
available regarding Castor than there is using JAXB. You can search
through the archives of the mailing list and find a bunch of stuff,
plus there's at least one tutorial on DeveloperWorks.
I would design the response message to contain an array of available
flights with minOccurs="0". It's not an "error" to produce no matching
flights, is it? The client should be smart enough to realize that if
the array is empty, there are no matching flights.
You could design the response message as a choice between an array of
flights or a string saying "no matching flights" but a lot of SOAP
implementations don't support <choice>, so I'd avoid it.
Another option is to return a sequence structure that contains an int
containing the cardinalilty and the array of flights:
<xsd:element name="searchForFlightsReturn">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="numberOfAvailableFlights" type="xsd:integer"/>
<xsd:element name="flight" type="ns:flight"
minOcurrs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
Anne
On 6/4/05, James Taylor <[EMAIL PROTECTED]> wrote:
> Hi anne,
> when you say plug your schema into the wsdl what exactly do you mean?
> and would it be worthwhile to look at JAXB to do the validating and xml class
> mapping. Also I'd like the return document to be a list of available flights
> or
> a message that none were available - like maybe throw an error to indicate it
> found none.
> James.
>
> Quoting Anne Thomas Manes <[EMAIL PROTECTED]>:
>
> > I don't think the Call interface really buys you very much except more work.
> >
> > My recommendation is that you define a schema for your input and
> > output XML structures, plug that schema into your WSDL, and let Axis
> > do the work for you.
> >
> > Axis will automatically validate the XML type information as it's
> > parsing the message, although if you have complex patterns or value
> > restrictions, Axis won't do that level of validation. If that level of
> > validation is necessary, you should use a handler. Regardless of
> > whether you are using the stub interface or the call interface, you
> > want to do the validation before Axis starts manipulating the Body,
> > and that must be done in a handler.
> >
> > Anne
> >
> > On 6/4/05, James Taylor <[EMAIL PROTECTED]> wrote:
> > > Hi,
> > > I want to develope an application that takes a xml request to book
> > > flights
> > > for a passenger. I need to map this to java objects and access a database
> > > backend - which will also have to be mapped to the java objects so luckily
> > they
> > > are nearly the same. As I was new to axis an web services I just took in a
> > xml
> > > string and parsed it to a xml representation using SAX and worked with the
> > > beans from there.
> > > But now I've gained a little understanding of web services I want
> > > to
> > be
> > > able to do it more efficiently. I think Its silly to do it my way as the
> > info
> > > is in xml anyways. Guess my approach was pretty insular but I got it to
> > work
> > > and learned a little on the way... well now would like to able to do this
> > using
> > > document style approach but am not to sure on how to validate the shema
> > > and
> > pull
> > > the xml I want out of the soap message. Also I want to add a little more
> > > functionality to the xml mapped beans to accommodate for the
> > > database/persistance mapping.
> > > I think the axis wsdl2java will map the objects to xml and take care
> > of the
> > > serialization but will it validate it first to see if its ok before
> > > sending
> > the
> > > message?
> > > See I think I might have more control if I use the call interface
> > instead
> > > of the wsdl2java to get at the xml but I'd have to map the xml to java
> > beans
> > > right??!!
> > > Just want to see what the people who use this think.
> > > Regards,
> > > James.
> > > --
> > > Between the question and the answer lies free will
> > >
> >
>
>
> --
> Between the question and the answer lies free will
>