You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Benson Margulies <bi...@gmail.com> on 2009/06/02 03:44:25 UTC

Aegis schema validation design challenge

The way Tatu has woodstox validation set up, it would be desirable to
activate it just before reading the first part-element. The code I've
got so far wants to see the part, and thus get dispatched into the
data binding, and then turn on validation. By which time, it's (for
now) too late.

It occurs to me that perhaps there's enough information to do this the
other way. An endpoint can only have one data binding going, I think,
so some sort of interceptor magic could call the DB and allow it to
set validation on the stream before reading the part elements?

Re: Aegis schema validation design challenge

Posted by Daniel Kulp <dk...@apache.org>.
There are really two ways to handle it:

1) When you set the schema into the wstx StreamReader, then wrapper it with a 
new stream reader delegate that would override the "next" method to catch it 
and map it to a fault.


2) Add an interceptor to the FaultOut chain that would check the class of the 
exception and if it's the wstx validation exception, do whatever mapping is 
needed. 

Dan


On Fri June 5 2009 9:14:53 pm Benson Margulies wrote:
> Next question: Exception mapping. Woodstox throws what it throws, in
> the middle of StaxUtils, when this goes off.
>
> I'm trying to figure out how to turn this into a fault.
>
> SchemaValidationTest [JUnit]
> 	org.eclipse.jdt.internal.junit.runner.RemoteTestRunner at localhost:52320
> 		Thread [main] (Running)
> 		Thread [ReaderThread] (Running)
> 		Thread [Thread-1] (Suspended (exception WstxValidationException))
> 			ValidatingStreamReader(StreamScanner).reportValidationProblem(XMLValidat
>ionProblem) line: 540
> 			NsInputElementStack(InputElementStack).reportProblem(XMLValidationProble
>m) line: 380
> 			GenericMsvValidator.reportError(String, Location) line: 521
> 			GenericMsvValidator.reportError(String) line: 513
> 			GenericMsvValidator.reportError(StringRef) line: 507
> 			GenericMsvValidator.validateElementStart(String, String, String) line:
> 261 NsInputElementStack.resolveAndValidateElement() line: 370
> 			ValidatingStreamReader(BasicStreamReader).handleStartElem(char) line:
> 2926 ValidatingStreamReader(BasicStreamReader).nextFromTree() line: 2786
> ValidatingStreamReader(BasicStreamReader).next() line: 1054
> 			DepthXMLStreamReader.next() line: 220
> 			StaxUtils.toNextElement(DepthXMLStreamReader) line: 302
> 			DocLiteralInInterceptor.getPara(DepthXMLStreamReader,
> DataReader<XMLStreamReader>, MessageContentsList,
> Iterator<MessagePartInfo>, Message) line: 217
> 			DocLiteralInInterceptor.handleMessage(Message) line: 117
> 			PhaseInterceptorChain.doIntercept(Message) line: 236
> 			ChainInitiationObserver.onMessage(Message) line: 89
> 			LocalConduit$1$1.run() line: 132
> 			Thread.run() line: 613
> 	/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/bin/java
> (Jun 5, 2009 9:13:03 PM)

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: Aegis schema validation design challenge

Posted by Benson Margulies <bi...@gmail.com>.
Right. As of WSTX-209 I can get the right exception with no further ado.

On Mon, Jun 8, 2009 at 7:25 PM, Tatu Saloranta<ts...@gmail.com> wrote:
> Just to make sure: is this what you fixed with [WSTX-209] (such that
> validation problem handle now gets properly invoked, and prevents
> exception)?
>
> On Fri, Jun 5, 2009 at 6:14 PM, Benson Margulies<bi...@gmail.com> wrote:
>> Next question: Exception mapping. Woodstox throws what it throws, in
>> the middle of StaxUtils, when this goes off.
>>
>> I'm trying to figure out how to turn this into a fault.
>>
>> SchemaValidationTest [JUnit]
>>        org.eclipse.jdt.internal.junit.runner.RemoteTestRunner at localhost:52320
>>                Thread [main] (Running)
>>                Thread [ReaderThread] (Running)
>>                Thread [Thread-1] (Suspended (exception WstxValidationException))
>>                        ValidatingStreamReader(StreamScanner).reportValidationProblem(XMLValidationProblem)
>> line: 540
>>                        NsInputElementStack(InputElementStack).reportProblem(XMLValidationProblem)
>> line: 380
>>                        GenericMsvValidator.reportError(String, Location) line: 521
>>                        GenericMsvValidator.reportError(String) line: 513
>>                        GenericMsvValidator.reportError(StringRef) line: 507
>>                        GenericMsvValidator.validateElementStart(String, String, String) line: 261
>>                        NsInputElementStack.resolveAndValidateElement() line: 370
>>                        ValidatingStreamReader(BasicStreamReader).handleStartElem(char) line: 2926
>>                        ValidatingStreamReader(BasicStreamReader).nextFromTree() line: 2786
>>                        ValidatingStreamReader(BasicStreamReader).next() line: 1054
>>                        DepthXMLStreamReader.next() line: 220
>>                        StaxUtils.toNextElement(DepthXMLStreamReader) line: 302
>>                        DocLiteralInInterceptor.getPara(DepthXMLStreamReader,
>> DataReader<XMLStreamReader>, MessageContentsList,
>> Iterator<MessagePartInfo>, Message) line: 217
>>                        DocLiteralInInterceptor.handleMessage(Message) line: 117
>>                        PhaseInterceptorChain.doIntercept(Message) line: 236
>>                        ChainInitiationObserver.onMessage(Message) line: 89
>>                        LocalConduit$1$1.run() line: 132
>>                        Thread.run() line: 613
>>        /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/bin/java
>> (Jun 5, 2009 9:13:03 PM)
>>
>

Re: Aegis schema validation design challenge

Posted by Tatu Saloranta <ts...@gmail.com>.
Just to make sure: is this what you fixed with [WSTX-209] (such that
validation problem handle now gets properly invoked, and prevents
exception)?

On Fri, Jun 5, 2009 at 6:14 PM, Benson Margulies<bi...@gmail.com> wrote:
> Next question: Exception mapping. Woodstox throws what it throws, in
> the middle of StaxUtils, when this goes off.
>
> I'm trying to figure out how to turn this into a fault.
>
> SchemaValidationTest [JUnit]
>        org.eclipse.jdt.internal.junit.runner.RemoteTestRunner at localhost:52320
>                Thread [main] (Running)
>                Thread [ReaderThread] (Running)
>                Thread [Thread-1] (Suspended (exception WstxValidationException))
>                        ValidatingStreamReader(StreamScanner).reportValidationProblem(XMLValidationProblem)
> line: 540
>                        NsInputElementStack(InputElementStack).reportProblem(XMLValidationProblem)
> line: 380
>                        GenericMsvValidator.reportError(String, Location) line: 521
>                        GenericMsvValidator.reportError(String) line: 513
>                        GenericMsvValidator.reportError(StringRef) line: 507
>                        GenericMsvValidator.validateElementStart(String, String, String) line: 261
>                        NsInputElementStack.resolveAndValidateElement() line: 370
>                        ValidatingStreamReader(BasicStreamReader).handleStartElem(char) line: 2926
>                        ValidatingStreamReader(BasicStreamReader).nextFromTree() line: 2786
>                        ValidatingStreamReader(BasicStreamReader).next() line: 1054
>                        DepthXMLStreamReader.next() line: 220
>                        StaxUtils.toNextElement(DepthXMLStreamReader) line: 302
>                        DocLiteralInInterceptor.getPara(DepthXMLStreamReader,
> DataReader<XMLStreamReader>, MessageContentsList,
> Iterator<MessagePartInfo>, Message) line: 217
>                        DocLiteralInInterceptor.handleMessage(Message) line: 117
>                        PhaseInterceptorChain.doIntercept(Message) line: 236
>                        ChainInitiationObserver.onMessage(Message) line: 89
>                        LocalConduit$1$1.run() line: 132
>                        Thread.run() line: 613
>        /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/bin/java
> (Jun 5, 2009 9:13:03 PM)
>

Re: Aegis schema validation design challenge

Posted by Benson Margulies <bi...@gmail.com>.
Next question: Exception mapping. Woodstox throws what it throws, in
the middle of StaxUtils, when this goes off.

I'm trying to figure out how to turn this into a fault.

SchemaValidationTest [JUnit]	
	org.eclipse.jdt.internal.junit.runner.RemoteTestRunner at localhost:52320	
		Thread [main] (Running)	
		Thread [ReaderThread] (Running)	
		Thread [Thread-1] (Suspended (exception WstxValidationException))	
			ValidatingStreamReader(StreamScanner).reportValidationProblem(XMLValidationProblem)
line: 540
			NsInputElementStack(InputElementStack).reportProblem(XMLValidationProblem)
line: 380
			GenericMsvValidator.reportError(String, Location) line: 521	
			GenericMsvValidator.reportError(String) line: 513	
			GenericMsvValidator.reportError(StringRef) line: 507	
			GenericMsvValidator.validateElementStart(String, String, String) line: 261	
			NsInputElementStack.resolveAndValidateElement() line: 370	
			ValidatingStreamReader(BasicStreamReader).handleStartElem(char) line: 2926	
			ValidatingStreamReader(BasicStreamReader).nextFromTree() line: 2786	
			ValidatingStreamReader(BasicStreamReader).next() line: 1054	
			DepthXMLStreamReader.next() line: 220	
			StaxUtils.toNextElement(DepthXMLStreamReader) line: 302	
			DocLiteralInInterceptor.getPara(DepthXMLStreamReader,
DataReader<XMLStreamReader>, MessageContentsList,
Iterator<MessagePartInfo>, Message) line: 217
			DocLiteralInInterceptor.handleMessage(Message) line: 117	
			PhaseInterceptorChain.doIntercept(Message) line: 236	
			ChainInitiationObserver.onMessage(Message) line: 89	
			LocalConduit$1$1.run() line: 132	
			Thread.run() line: 613	
	/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/bin/java
(Jun 5, 2009 9:13:03 PM)

Re: Aegis schema validation design challenge

Posted by Benson Margulies <bi...@gmail.com>.
So we end up with an entire interceptor just to move to the first
token of the body? OK.

On Thu, Jun 4, 2009 at 9:05 PM, Daniel Kulp <dk...@apache.org> wrote:
> On Thu June 4 2009 8:46:08 pm Benson Margulies wrote:
>> I'm feeling a bit 'phased'. I already did my first effort here in
>> AbstractInDatabindingInterceptor, and it seems that this is too late.
>> Just where do I have to be to be after reading the body element?
>
> Hmm....  The ReadHeadersInterceptor might need to be spit into two
> interceptors.   If you see the bottom of it's handleMessage, you see it
> advances to the first token inside the soap:body.  If the first token was
> whitespace, you probably would be OK.   However, that's not normal.   I think
> you would need to set your schema right in there someplace.  Thus, that loop
> might need to be put into a separate interceptor so that you could inject a
> new interceptor between the ReadHeadersInterceptor and that new interceptor.
>
> Dan
>
>
>>
>> On Tue, Jun 2, 2009 at 12:41 PM, Daniel Kulp <dk...@apache.org> wrote:
>> > On Mon June 1 2009 9:44:25 pm Benson Margulies wrote:
>> >> The way Tatu has woodstox validation set up, it would be desirable to
>> >> activate it just before reading the first part-element. The code I've
>> >> got so far wants to see the part, and thus get dispatched into the
>> >> data binding, and then turn on validation. By which time, it's (for
>> >> now) too late.
>> >>
>> >> It occurs to me that perhaps there's enough information to do this the
>> >> other way. An endpoint can only have one data binding going, I think,
>> >> so some sort of interceptor magic could call the DB and allow it to
>> >> set validation on the stream before reading the part elements?
>> >
>> > Yea.   That makes complete sense.   An interceptor that runs after the
>> > reading of the soap:body element that would set this up would definitely
>> > be the preferred route for doc/lit endpoints.   For RPC/Lit, I think the
>> > current setup is correct (as you don't validate the element name, just
>> > the type), but those are rare (and don't work with JAXB validation
>> > either).
>> >
>> > In the AegisDataBinding init method, you should be able to add an
>> > interceptor to the Service object.   I believe that would work.
>> >
>> > --
>> > Daniel Kulp
>> > dkulp@apache.org
>> > http://www.dankulp.com/blog
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>

Re: Aegis schema validation design challenge

Posted by Daniel Kulp <dk...@apache.org>.
On Thu June 4 2009 8:46:08 pm Benson Margulies wrote:
> I'm feeling a bit 'phased'. I already did my first effort here in
> AbstractInDatabindingInterceptor, and it seems that this is too late.
> Just where do I have to be to be after reading the body element?

Hmm....  The ReadHeadersInterceptor might need to be spit into two 
interceptors.   If you see the bottom of it's handleMessage, you see it 
advances to the first token inside the soap:body.  If the first token was 
whitespace, you probably would be OK.   However, that's not normal.   I think 
you would need to set your schema right in there someplace.  Thus, that loop 
might need to be put into a separate interceptor so that you could inject a 
new interceptor between the ReadHeadersInterceptor and that new interceptor.  

Dan


>
> On Tue, Jun 2, 2009 at 12:41 PM, Daniel Kulp <dk...@apache.org> wrote:
> > On Mon June 1 2009 9:44:25 pm Benson Margulies wrote:
> >> The way Tatu has woodstox validation set up, it would be desirable to
> >> activate it just before reading the first part-element. The code I've
> >> got so far wants to see the part, and thus get dispatched into the
> >> data binding, and then turn on validation. By which time, it's (for
> >> now) too late.
> >>
> >> It occurs to me that perhaps there's enough information to do this the
> >> other way. An endpoint can only have one data binding going, I think,
> >> so some sort of interceptor magic could call the DB and allow it to
> >> set validation on the stream before reading the part elements?
> >
> > Yea.   That makes complete sense.   An interceptor that runs after the
> > reading of the soap:body element that would set this up would definitely
> > be the preferred route for doc/lit endpoints.   For RPC/Lit, I think the
> > current setup is correct (as you don't validate the element name, just
> > the type), but those are rare (and don't work with JAXB validation
> > either).
> >
> > In the AegisDataBinding init method, you should be able to add an
> > interceptor to the Service object.   I believe that would work.
> >
> > --
> > Daniel Kulp
> > dkulp@apache.org
> > http://www.dankulp.com/blog

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: Aegis schema validation design challenge

Posted by Benson Margulies <bi...@gmail.com>.
I'm feeling a bit 'phased'. I already did my first effort here in
AbstractInDatabindingInterceptor, and it seems that this is too late.
Just where do I have to be to be after reading the body element?

On Tue, Jun 2, 2009 at 12:41 PM, Daniel Kulp <dk...@apache.org> wrote:
> On Mon June 1 2009 9:44:25 pm Benson Margulies wrote:
>> The way Tatu has woodstox validation set up, it would be desirable to
>> activate it just before reading the first part-element. The code I've
>> got so far wants to see the part, and thus get dispatched into the
>> data binding, and then turn on validation. By which time, it's (for
>> now) too late.
>>
>> It occurs to me that perhaps there's enough information to do this the
>> other way. An endpoint can only have one data binding going, I think,
>> so some sort of interceptor magic could call the DB and allow it to
>> set validation on the stream before reading the part elements?
>
> Yea.   That makes complete sense.   An interceptor that runs after the reading
> of the soap:body element that would set this up would definitely be the
> preferred route for doc/lit endpoints.   For RPC/Lit, I think the current
> setup is correct (as you don't validate the element name, just the type), but
> those are rare (and don't work with JAXB validation either).
>
> In the AegisDataBinding init method, you should be able to add an interceptor
> to the Service object.   I believe that would work.
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog
>

Re: Aegis schema validation design challenge

Posted by Daniel Kulp <dk...@apache.org>.
On Mon June 1 2009 9:44:25 pm Benson Margulies wrote:
> The way Tatu has woodstox validation set up, it would be desirable to
> activate it just before reading the first part-element. The code I've
> got so far wants to see the part, and thus get dispatched into the
> data binding, and then turn on validation. By which time, it's (for
> now) too late.
>
> It occurs to me that perhaps there's enough information to do this the
> other way. An endpoint can only have one data binding going, I think,
> so some sort of interceptor magic could call the DB and allow it to
> set validation on the stream before reading the part elements?

Yea.   That makes complete sense.   An interceptor that runs after the reading 
of the soap:body element that would set this up would definitely be the 
preferred route for doc/lit endpoints.   For RPC/Lit, I think the current 
setup is correct (as you don't validate the element name, just the type), but 
those are rare (and don't work with JAXB validation either).

In the AegisDataBinding init method, you should be able to add an interceptor 
to the Service object.   I believe that would work.

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog