If you use toString on the soap body, you have to make sure that all the
namespaces, including the namespace of the soap body element, are specified
via xmlns:... attributes somewhere in the resulting document, or it will be
invalid.  Normally, some are specified in the soap envelope enclosing the
body, and toString may or may not be smart enough to correctly pull them
down into the root of what it serializes (probably not smart enough!).

I vaguely remember reading that XSLT may actually do the namespaces right.

I think that the Xerces SAX parser may be able to validate.  Also, Xerces
currently has some DOM level 3 validation interfaces which might make it
possible to validate a DOM in place.  Unfortunately, IIRC, these interfaces
may be deprecated and may disappear from a future release of Xerces.  Check
out the docs before you buy.

Jeff
----- Original Message -----
From: "Irving, Dave" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, January 15, 2003 1:55 PM
Subject: FW: Validating content sent to style="message" services


> David,
>
> Thanks very much for your help.... Now, all I need to do is get my JAXP
> parser doing schema validation and there :o)
>
> Cheers,
>
> Dave
>
> -----Original Message-----
> From: David Peterson [mailto:[EMAIL PROTECTED]]
> Sent: 15 January 2003 20:27
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: Validating content sent to style="message" services
>
>
>
> Hi Dave,
>
> If your current method of calling toString() on the SOAP body is giving
> you the XML that you wish to validate (and, I assume, the XML is
> well-formed, not mal-formed), then I see no problem with using that
> approach. {Others may have a comment to add?}
>
> I'm not quite sure why you'd use a "Transformer". This usually refers to
> XSLT (eXensible StyLesheet Transformations) - in which you construct a
> "Transformer" from an XSL stylesheet (really an output formatting
> template), and pump your XML source data through the Transformer to
> produce your (also XML) output file - according to the XSL
> transformation rules. Now, that said, I can't see how and where you'd
> use this to *obtain* your SOAP body XML, except for possibly
> constructing an "identity" transform (this is done by creating a new
> Transformer from an "empty" XSL transform (sometimes called the identity
> transform: a bit like the I in matrix theory - X*I = X) ), which may
> allow you to use the transformer technique to obtain a copy of the SOAP
> body XML. But to me, this seems like the long way around ... I think
> that your toString() method is winning on the basis of simplicity!
>
> Once you have the XML body (via any technique) you push it into a
> validating parser. I believe this means you must use DOM parsing rather
> than SAX parsing, as from what I understand SAX parsers do not support
> validation. You should be able to use the JAXP (Java API for XML
> Processing) API (for parser independence). This will find a concrete
> parser implementation (such as Xerces.jar) and use it. Or, you could
> write code which uses Xerces directly (less advisable as then you have
> made your s/w dependent on a particular parser). A third option is to
> look at dom4j or JDOM if you think these libraries will make your
> parsing easier. Again, using these you add a dependency to your system.
>
> HTH.
>
> Dave
>
>
>
>
>
> Irving, Dave wrote:
>
> >Thanks for your help Dave,
> >
> >Using a handler would be a pretty nice way of doing this - I'll look
> further
> >in to it.
> >Im a complete newbie to AXIS though, so Im a bit confused as to how I get
> >'back' to an XML source to parse again.
> >It is a contained SOAPBody which I wish to validate, and I believe JAXP
> says
> >I should use a Transformer to do this.... However, I notice that if I get
> >hold of the body, a 'toString()' provides me with the original XML
content
> >of the body!!
> >Is this an ok feature to use, or should I stick with a Transformer?
> >
> >Many thanks,
> >
> >Dave
> >
> >-----Original Message-----
> >From: David Peterson [mailto:[EMAIL PROTECTED]]
> >Sent: 15 January 2003 19:58
> >To: [EMAIL PROTECTED]
> >Subject: Re: Validating content sent to style="message" services
> >
> >
> >
> >Hi Dave,
> >
> >Since no-one else seems to have had a crack at your question, I will.
> >
> >I believe you can achieve what you are looking for by using"SOAP
> >handlers", which as I understand them are akin to "servlet filters"
> >except for the SOAP/web-services rather than Java servlets. Basically my
> >idea would be to create a SOAP handler that is invoked before the JAXM
> >message is processed by the web service, and pass the message XML to a
> >validating (DOM) XML parser. Obviously the parser would also need to be
> >able to fetch the DOM that matches the message in order to perform the
> >validation.
> >
> >Hope this helps. Comments from others welcome.
> >
> >David Peterson
> >
> >
> >Irving, Dave wrote:
> >
> >
> >
> >>Hi,
> >>
> >>My service will be using the "message" style rather than the RPC style
> (not
> >>by choice..., but there we go..).
> >>One thing Im really interested in doing is having the XML body validated
> >>before it is received by my service.
> >>Is there any configuration option of Axis which can be used to have this
> >>handled automatically, or do I need to manually validate the content in
> the
> >>service or handler?
> >>
> >>Many thanks,
> >>
> >>Dave Irving
> >>
> >>
> >>
> >>
>
>
> This e-mail and any attachment is for authorised use by the intended
recipient(s) only.  It may contain proprietary material, confidential
information and/or be subject to legal privilege.  It should not be copied,
disclosed to, retained or used by, any other party.  If you are not an
intended recipient then please promptly delete this e-mail and any
attachment and all copies and inform the sender.  Thank you.
>

Reply via email to