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






Reply via email to