Re: LogicalHandlerInInterceptor examples
hment, which based on other >>> posts >>> >> I >>> >> saw, may cause some problems with the different processing phases. >>> >> >>> >> Net effect is how do I just get the Soap payload part of the message? >>> If >>> >> I >>> >> don't need to use a Logical Handler, great. If I do, great too. Does >>> not >>> >> matter to me. >>> > >>> > OK. There are a couple of options that you could pursue for this. >>> > >>> > 1) You COULD write an interceptor that lives just before the >>> > DocLiteralInInterceptor that takes the XMLStreamReader and wrappers it >>> > with a >>> > new XMLStreamReader that would "correct" the namespace issue. >>> (override >>> > the >>> > getNamespace calls and such to return the correct value). If you do >>> > that, >>> > you could just turn on the CXF built in schema validation stuff. >>> See: >>> > http://cxf.apache.org/faq.html >>> > That option would have the best performance as the built in jaxb >>> > validation >>> > doesn't need to load the whole message while unmarshalling. >>> > >>> > 2) Next easiest is to configure in the SAAJInInterceptor (or have your >>> > interceptor call it) and work with the SAAJ model directly. Your >>> > interceptor >>> > would just look something like: >>> > >>> > >>> > public MyInterceptor() { >>> > super(Phase.PRE_PROTOCOL); >>> > getAfter().add(SAAJInInterceptor.class.getName()); >>> > } >>> > public void handleMessage(SoapMessage msg) throws Fault { >>> > SOAPMessage doc = msg.getContent(SOAPMessage.class); >>> > if (doc == null) { >>> > saajIn.handleMessage(msg); >>> > doc = msg.getContent(SOAPMessage.class); >>> > } >>> >//process doc here >>> > } >>> > >>> > Not quite as good as it loads the whole message into memory, but >>> > certainly easy to work with. >>> > >>> > 3) Register a jaxws LogicalHandler with the endpoint. The >>> > LogicalMessageContext that is passed in has a >>> > getLogicalMessage().getPayload() >>> > method that returns a Source.(I think a DOMSource is what we >>> return) >>> > Advantage here is that it would be portable to other jaxws >>> > implementations. >>> > Disadvantage is that performance is way worse than option 2. Also, >>> > JAX-WS >>> > handlers have to be registered per-endpoint whereas an interceptor can >>> be >>> > configured on the Bus and thus be more "global". >>> > >>> > Hope that helps! >>> >> >> -- >> Daniel Kulp >> dk...@apache.org >> http://www.dankulp.com/blog >> >> > > -- View this message in context: http://www.nabble.com/LogicalHandlerInInterceptor-examples-tp26012831p26025204.html Sent from the cxf-user mailing list archive at Nabble.com.
Re: LogicalHandlerInInterceptor examples
as the built in jaxb >> > validation >> > doesn't need to load the whole message while unmarshalling. >> > >> > 2) Next easiest is to configure in the SAAJInInterceptor (or have your >> > interceptor call it) and work with the SAAJ model directly. Your >> > interceptor >> > would just look something like: >> > >> > >> > public MyInterceptor() { >> > super(Phase.PRE_PROTOCOL); >> > getAfter().add(SAAJInInterceptor.class.getName()); >> > } >> > public void handleMessage(SoapMessage msg) throws Fault { >> > SOAPMessage doc = msg.getContent(SOAPMessage.class); >> > if (doc == null) { >> > saajIn.handleMessage(msg); >> > doc = msg.getContent(SOAPMessage.class); >> > } >> >//process doc here >> > } >> > >> > Not quite as good as it loads the whole message into memory, but >> > certainly easy to work with. >> > >> > 3) Register a jaxws LogicalHandler with the endpoint. The >> > LogicalMessageContext that is passed in has a >> > getLogicalMessage().getPayload() >> > method that returns a Source.(I think a DOMSource is what we >> return) >> > Advantage here is that it would be portable to other jaxws >> > implementations. >> > Disadvantage is that performance is way worse than option 2. Also, >> > JAX-WS >> > handlers have to be registered per-endpoint whereas an interceptor can >> be >> > configured on the Bus and thus be more "global". >> > >> > Hope that helps! >> > > -- > Daniel Kulp > dk...@apache.org > http://www.dankulp.com/blog > > -- View this message in context: http://www.nabble.com/LogicalHandlerInInterceptor-examples-tp26012831p26017805.html Sent from the cxf-user mailing list archive at Nabble.com.
Re: LogicalHandlerInInterceptor examples
On Thu October 22 2009 5:08:26 pm Brenda Coulson wrote: > Dan > > This does help enormously. I need to process my options to figure out which > works best. Our system already runs like a dog so performance is a real > issue. Just a quick question - since the Soap message I am receiving is > technically wrong, is there any way to get the validator/parser to choke at > that point - ie if my soap body is not namespace-qualified? That seems like > the easiest thing to do and something that a web service processor should > automatically have in place? If using JAXB databinding (default) or XMLBeans, just turn on schema validation. http://apache.org/hello_world_soap_http}SoapPort"; wsdlLocation="wsdl/hello_world.wsdl" ..> That should automatically catch and schema related issues and send an exception back. If using Aegis, not much can be done until CXF 2.3. :-( For Provider based endpoints, there in the latest SNAPSHOTS that turn on validation with the above flag as well. Not available in a release yet though. Dan > > brenda > > dkulp wrote: > > On Thu October 22 2009 4:31:21 pm Brenda Coulson wrote: > >> That is great to know! I am so confused between the difference between > >> Interceptors and Handlers and when to use them. Ok so I have a Soap > >> message > >> that I am trying to ultimately validate. However, there are times when I > >> may receive a message that does not specify the namespace for the soap > >> payload. Example as follows: > >> > >> >> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";> > >> > >> > >> > >> 80640 > >> > >> > >> > > > > Oi.. Ick.. Technically, that's an invalid soap message as, according to > > spec, direct child elements of soap:Body must be namespace qualified. > > But > > let's ignore that issue for a second. :-) > > > >> Technically the XML inside the payload is well-formed so the validator > >> does > >> not complain. However, there is a required element, referenceId, > >> missing. So as I am validating, I would like to just get to the Soap > >> payload, aka > >> > >> > >> 80640 > >> > >> > >> And validate it against my schema, regardless of whether or no the > >> namespace is specified. I need to do this for all methods on my web > >> service, one of which has a Soap attachment, which based on other posts > >> I > >> saw, may cause some problems with the different processing phases. > >> > >> Net effect is how do I just get the Soap payload part of the message? If > >> I > >> don't need to use a Logical Handler, great. If I do, great too. Does not > >> matter to me. > > > > OK. There are a couple of options that you could pursue for this. > > > > 1) You COULD write an interceptor that lives just before the > > DocLiteralInInterceptor that takes the XMLStreamReader and wrappers it > > with a > > new XMLStreamReader that would "correct" the namespace issue. (override > > the > > getNamespace calls and such to return the correct value). If you do > > that, > > you could just turn on the CXF built in schema validation stuff.See: > > http://cxf.apache.org/faq.html > > That option would have the best performance as the built in jaxb > > validation > > doesn't need to load the whole message while unmarshalling. > > > > 2) Next easiest is to configure in the SAAJInInterceptor (or have your > > interceptor call it) and work with the SAAJ model directly. Your > > interceptor > > would just look something like: > > > > > > public MyInterceptor() { > > super(Phase.PRE_PROTOCOL); > > getAfter().add(SAAJInInterceptor.class.getName()); > > } > > public void handleMessage(SoapMessage msg) throws Fault { > > SOAPMessage doc = msg.getContent(SOAPMessage.class); > > if (doc == null) { > > saajIn.handleMessage(msg); > > doc = msg.getContent(SOAPMessage.class); > > } > >//process doc here > > } > > > > Not quite as good as it loads the whole message into memory, but > > certainly easy to work with. > > > > 3) Register a jaxws LogicalHandler with the endpoint. The > > LogicalMessageContext that is passed in has a > > getLogicalMessage().getPayload() > > method that returns a Source.(I think a DOMSource is what we return) > > Advantage here is that it would be portable to other jaxws > > implementations. > > Disadvantage is that performance is way worse than option 2. Also, > > JAX-WS > > handlers have to be registered per-endpoint whereas an interceptor can be > > configured on the Bus and thus be more "global". > > > > Hope that helps! > -- Daniel Kulp dk...@apache.org http://www.dankulp.com/blog
Re: LogicalHandlerInInterceptor examples
Dan This does help enormously. I need to process my options to figure out which works best. Our system already runs like a dog so performance is a real issue. Just a quick question - since the Soap message I am receiving is technically wrong, is there any way to get the validator/parser to choke at that point - ie if my soap body is not namespace-qualified? That seems like the easiest thing to do and something that a web service processor should automatically have in place? brenda dkulp wrote: > > On Thu October 22 2009 4:31:21 pm Brenda Coulson wrote: >> That is great to know! I am so confused between the difference between >> Interceptors and Handlers and when to use them. Ok so I have a Soap >> message >> that I am trying to ultimately validate. However, there are times when I >> may receive a message that does not specify the namespace for the soap >> payload. Example as follows: >> >> > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";> >> >> >> >> 80640 >> >> >> > > Oi.. Ick.. Technically, that's an invalid soap message as, according to > spec, direct child elements of soap:Body must be namespace qualified. > But > let's ignore that issue for a second. :-) > >> Technically the XML inside the payload is well-formed so the validator >> does >> not complain. However, there is a required element, referenceId, missing. >> So as I am validating, I would like to just get to the Soap payload, aka >> >> >> 80640 >> >> >> And validate it against my schema, regardless of whether or no the >> namespace is specified. I need to do this for all methods on my web >> service, one of which has a Soap attachment, which based on other posts >> I >> saw, may cause some problems with the different processing phases. >> >> Net effect is how do I just get the Soap payload part of the message? If >> I >> don't need to use a Logical Handler, great. If I do, great too. Does not >> matter to me. > > OK. There are a couple of options that you could pursue for this. > > 1) You COULD write an interceptor that lives just before the > DocLiteralInInterceptor that takes the XMLStreamReader and wrappers it > with a > new XMLStreamReader that would "correct" the namespace issue. (override > the > getNamespace calls and such to return the correct value). If you do > that, > you could just turn on the CXF built in schema validation stuff.See: > http://cxf.apache.org/faq.html > That option would have the best performance as the built in jaxb > validation > doesn't need to load the whole message while unmarshalling. > > 2) Next easiest is to configure in the SAAJInInterceptor (or have your > interceptor call it) and work with the SAAJ model directly. Your > interceptor > would just look something like: > > > public MyInterceptor() { > super(Phase.PRE_PROTOCOL); > getAfter().add(SAAJInInterceptor.class.getName()); > } > public void handleMessage(SoapMessage msg) throws Fault { > SOAPMessage doc = msg.getContent(SOAPMessage.class); > if (doc == null) { > saajIn.handleMessage(msg); > doc = msg.getContent(SOAPMessage.class); > } >//process doc here > } > > Not quite as good as it loads the whole message into memory, but certainly > easy to work with. > > 3) Register a jaxws LogicalHandler with the endpoint. The > LogicalMessageContext that is passed in has a > getLogicalMessage().getPayload() > method that returns a Source.(I think a DOMSource is what we return) > Advantage here is that it would be portable to other jaxws > implementations. > Disadvantage is that performance is way worse than option 2. Also, > JAX-WS > handlers have to be registered per-endpoint whereas an interceptor can be > configured on the Bus and thus be more "global". > > Hope that helps! > > -- > Daniel Kulp > dk...@apache.org > http://www.dankulp.com/blog > > -- View this message in context: http://www.nabble.com/LogicalHandlerInInterceptor-examples-tp26012831p26017261.html Sent from the cxf-user mailing list archive at Nabble.com.
Re: LogicalHandlerInInterceptor examples
On Thu October 22 2009 4:31:21 pm Brenda Coulson wrote: > That is great to know! I am so confused between the difference between > Interceptors and Handlers and when to use them. Ok so I have a Soap message > that I am trying to ultimately validate. However, there are times when I > may receive a message that does not specify the namespace for the soap > payload. Example as follows: > > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";> > > > > 80640 > > > Oi.. Ick.. Technically, that's an invalid soap message as, according to spec, direct child elements of soap:Body must be namespace qualified. But let's ignore that issue for a second. :-) > Technically the XML inside the payload is well-formed so the validator does > not complain. However, there is a required element, referenceId, missing. > So as I am validating, I would like to just get to the Soap payload, aka > > > 80640 > > > And validate it against my schema, regardless of whether or no the > namespace is specified. I need to do this for all methods on my web > service, one of which has a Soap attachment, which based on other posts I > saw, may cause some problems with the different processing phases. > > Net effect is how do I just get the Soap payload part of the message? If I > don't need to use a Logical Handler, great. If I do, great too. Does not > matter to me. OK. There are a couple of options that you could pursue for this. 1) You COULD write an interceptor that lives just before the DocLiteralInInterceptor that takes the XMLStreamReader and wrappers it with a new XMLStreamReader that would "correct" the namespace issue. (override the getNamespace calls and such to return the correct value). If you do that, you could just turn on the CXF built in schema validation stuff.See: http://cxf.apache.org/faq.html That option would have the best performance as the built in jaxb validation doesn't need to load the whole message while unmarshalling. 2) Next easiest is to configure in the SAAJInInterceptor (or have your interceptor call it) and work with the SAAJ model directly. Your interceptor would just look something like: public MyInterceptor() { super(Phase.PRE_PROTOCOL); getAfter().add(SAAJInInterceptor.class.getName()); } public void handleMessage(SoapMessage msg) throws Fault { SOAPMessage doc = msg.getContent(SOAPMessage.class); if (doc == null) { saajIn.handleMessage(msg); doc = msg.getContent(SOAPMessage.class); } //process doc here } Not quite as good as it loads the whole message into memory, but certainly easy to work with. 3) Register a jaxws LogicalHandler with the endpoint. The LogicalMessageContext that is passed in has a getLogicalMessage().getPayload() method that returns a Source.(I think a DOMSource is what we return) Advantage here is that it would be portable to other jaxws implementations. Disadvantage is that performance is way worse than option 2. Also, JAX-WS handlers have to be registered per-endpoint whereas an interceptor can be configured on the Bus and thus be more "global". Hope that helps! -- Daniel Kulp dk...@apache.org http://www.dankulp.com/blog
Re: LogicalHandlerInInterceptor examples
That is great to know! I am so confused between the difference between Interceptors and Handlers and when to use them. Ok so I have a Soap message that I am trying to ultimately validate. However, there are times when I may receive a message that does not specify the namespace for the soap payload. Example as follows: http://schemas.xmlsoap.org/soap/envelope/";> 80640 Technically the XML inside the payload is well-formed so the validator does not complain. However, there is a required element, referenceId, missing. So as I am validating, I would like to just get to the Soap payload, aka 80640 And validate it against my schema, regardless of whether or no the namespace is specified. I need to do this for all methods on my web service, one of which has a Soap attachment, which based on other posts I saw, may cause some problems with the different processing phases. Net effect is how do I just get the Soap payload part of the message? If I don't need to use a Logical Handler, great. If I do, great too. Does not matter to me. Thank you! Brenda dkulp wrote: > > > Umm what are you trying to use LogicalHandlerInInterceptor for? It's > pretty much just used by the JAXWS runtime to invoke the jaxws > LogicalHandlers. It's not really something that anyone would normally be > invoking themselves. > > Basically, what are you trying to accomplish? Knowing that may help steer > you > down the correct path. > > Dan > > > On Thu October 22 2009 12:12:21 pm Brenda Coulson wrote: >> All >> >> Has anyone had any success using LogicalHandlerInInterceptor? I can not >> find examples of it in the sample code or any way to use it from the >> documentation. Any and all help/pointers would be greatly appreciated!! >> >> Thanks in advance >> brenda >> > > -- > Daniel Kulp > dk...@apache.org > http://www.dankulp.com/blog > > -- View this message in context: http://www.nabble.com/LogicalHandlerInInterceptor-examples-tp26012831p26016703.html Sent from the cxf-user mailing list archive at Nabble.com.
Re: LogicalHandlerInInterceptor examples
Umm what are you trying to use LogicalHandlerInInterceptor for? It's pretty much just used by the JAXWS runtime to invoke the jaxws LogicalHandlers. It's not really something that anyone would normally be invoking themselves. Basically, what are you trying to accomplish? Knowing that may help steer you down the correct path. Dan On Thu October 22 2009 12:12:21 pm Brenda Coulson wrote: > All > > Has anyone had any success using LogicalHandlerInInterceptor? I can not > find examples of it in the sample code or any way to use it from the > documentation. Any and all help/pointers would be greatly appreciated!! > > Thanks in advance > brenda > -- Daniel Kulp dk...@apache.org http://www.dankulp.com/blog
Re: LogicalHandlerInInterceptor examples
I think in principal it will be similar to this demo /samples/jaxws_handlers/src/demo/handlers/common/LoggingHandler.java but instead of a SOAPMessageContext, you would be handling a MessageContext as in the testcase. /Dave On Thu, Oct 22, 2009 at 12:21 PM, Brenda Coulson wrote: > > Dave > > thanks - that does help to see how it is invoked, however it is being > invoked from Spring for me. I actually need help writing an interceptor that > derives from this interceptor. > > brenda > > Dave Stanley wrote: >> >> There's a test here: >> >> http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptorTest.java?view=markup >> >> Hope that helps >> /Dave >> >> >> On Thu, Oct 22, 2009 at 12:12 PM, Brenda Coulson >> wrote: >>> >>> All >>> >>> Has anyone had any success using LogicalHandlerInInterceptor? I can not >>> find >>> examples of it in the sample code or any way to use it from the >>> documentation. Any and all help/pointers would be greatly appreciated!! >>> >>> Thanks in advance >>> brenda >>> -- >>> View this message in context: >>> http://www.nabble.com/LogicalHandlerInInterceptor-examples-tp26012831p26012831.html >>> Sent from the cxf-user mailing list archive at Nabble.com. >>> >>> >> >> > > -- > View this message in context: > http://www.nabble.com/LogicalHandlerInInterceptor-examples-tp26012831p26012961.html > Sent from the cxf-user mailing list archive at Nabble.com. > >
Re: LogicalHandlerInInterceptor examples
Dave thanks - that does help to see how it is invoked, however it is being invoked from Spring for me. I actually need help writing an interceptor that derives from this interceptor. brenda Dave Stanley wrote: > > There's a test here: > > http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptorTest.java?view=markup > > Hope that helps > /Dave > > > On Thu, Oct 22, 2009 at 12:12 PM, Brenda Coulson > wrote: >> >> All >> >> Has anyone had any success using LogicalHandlerInInterceptor? I can not >> find >> examples of it in the sample code or any way to use it from the >> documentation. Any and all help/pointers would be greatly appreciated!! >> >> Thanks in advance >> brenda >> -- >> View this message in context: >> http://www.nabble.com/LogicalHandlerInInterceptor-examples-tp26012831p26012831.html >> Sent from the cxf-user mailing list archive at Nabble.com. >> >> > > -- View this message in context: http://www.nabble.com/LogicalHandlerInInterceptor-examples-tp26012831p26012961.html Sent from the cxf-user mailing list archive at Nabble.com.
Re: LogicalHandlerInInterceptor examples
There's a test here: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/handler/LogicalHandlerInterceptorTest.java?view=markup Hope that helps /Dave On Thu, Oct 22, 2009 at 12:12 PM, Brenda Coulson wrote: > > All > > Has anyone had any success using LogicalHandlerInInterceptor? I can not find > examples of it in the sample code or any way to use it from the > documentation. Any and all help/pointers would be greatly appreciated!! > > Thanks in advance > brenda > -- > View this message in context: > http://www.nabble.com/LogicalHandlerInInterceptor-examples-tp26012831p26012831.html > Sent from the cxf-user mailing list archive at Nabble.com. > >
LogicalHandlerInInterceptor examples
All Has anyone had any success using LogicalHandlerInInterceptor? I can not find examples of it in the sample code or any way to use it from the documentation. Any and all help/pointers would be greatly appreciated!! Thanks in advance brenda -- View this message in context: http://www.nabble.com/LogicalHandlerInInterceptor-examples-tp26012831p26012831.html Sent from the cxf-user mailing list archive at Nabble.com.