Re: suppress namespace?
I see. So do these toolkits produce messages with namespaces? If not we're gonna need to add extend aegis to not expect namespaces when reading. This is one of changes I had to in the extensions for SOAP encoded. -dain On Dec 12, 2007, at 6:56 PM, Daniel Kulp wrote: Dain, One of the main use cases for such namespace free responses is for the REST style things where a client does a get on a URL and receives an XML response back.The XML parsers in various toolkits (and browsers) don't always work well with the namespaces that JAXB and Aegis would always spit out. Most likely, you would register a service on two URL's. One that would return a proper XML that is consumable by smarter clients and another that would have the strip interceptor setup.You may be able to do something really smart in the interceptor like look at the user agent or something and only strip for certain agents. Dan On Wednesday 12 December 2007, Dain Sundstrom wrote: On Dec 12, 2007, at 7:55 AM, Daniel Kulp wrote: On Wednesday 12 December 2007, Vespa, Anthony J wrote: I would be interested in this as well for Aegis bindings - it does not make some of the JS libraries out there too happy. That is why doing it at the interceptor level is ideal. It would be completely independent of the databinding. Heck, you would be able to feed it a DOMSource if using a ProviderSource type thing and the namespaces would get stripped out as well. I'm not sure this can be done with an interceptor. I'd guess that, client that expects messages to be namespace free are unlikely to send messages with the proper namespaces in the first place. When aegis sees the xml without namespaces, it isn't going match nested elements in the BeanType class to the xml elements because it matches on qname. From what I have seen of the BeanType code, think that you can make aegis expect namespace free nested elements using a new TypeCreater which creates BeanTypes with no namespace expectations. This is how the StructType works. Now that I think about it, I bet the javascript libraries are expecting soap encoding which doesn't have namespace qualified nested elements. -dain -- J. Daniel Kulp Principal Engineer IONA P: 781-902-8727C: 508-380-7194 [EMAIL PROTECTED] http://www.dankulp.com/blog
Re: suppress namespace?
On Wednesday 12 December 2007, Vespa, Anthony J wrote: I would be interested in this as well for Aegis bindings - it does not make some of the JS libraries out there too happy. That is why doing it at the interceptor level is ideal. It would be completely independent of the databinding. Heck, you would be able to feed it a DOMSource if using a ProviderSource type thing and the namespaces would get stripped out as well. Question - if you have a high traffic site, wouldn't having something in the interceptor chain that did this on every response have a performance impact? Would it be preferable to have it at a differet layer? It could be because I'm thinking of interceptors as analogous to servlet filters and I've seen perf issues with those under load. Servlet filters really suck as you pretty much have to byte[] the response, reparse it, process it, then restream it, etc... That's why there is a huge performance penalty while using them.The interceptor approach would just modify the Stax events before anything is written. There isn't any reparsing, re-traversing the xml, reprocessing, restreaming, etc It's all done inline. Basically, if I was doing it, I'd subclass the StreamWriterDelegate class (found in stax-utils-20060502.jar) and override all the writeStartElement and writeEmptyElement to call the non-namespace versions. For example: public void writeStartElement(String namespaceURI, String localName) throws XMLStreamException { out.writeStartElement(localName); } (There may need some extra code to handle/fake the NamespaceContext stuff. That would require some testing and experimentation.) The interceptor code would just be something like: XMLStreamWriter xmlWriter = message.getContent(XMLStreamWriter.class); message.setContent(XMLStreamWriter.class, new StripNamespaceWriter(xmlWriter); message.setProperty(disable.outputstream.optimization, Boolean.TRUE); Any chance this would get into a build before the end of the year or mid Jan? If someone steps up to do it, sure. Seriously, the above code snipets are a huge starting point. It's mostly just flush it out and test it a bit. Unfortunately, I definitely don't have time right now. Dan -Original Message- From: Daniel Kulp [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 11, 2007 5:29 PM To: cxf-user@incubator.apache.org Subject: Re: suppress namespace? I created a JIRA for this: https://issues.apache.org/jira/browse/CXF-1291 It's a relatively easy thing to write so it's something that someone that's interested getting started with digging into CXF interceptors could pick up. Dan On Wednesday 21 November 2007, mule1 wrote: Is it possible to suppress the namespace in the response elements using jaxb? I have the similar issue where customer don't want the namespace in the response. dkulp wrote: With Aegis, defintely no right now. :-( Aegis always generates qualified schemas so all the elements are namespace qualified. Actually, an interesting approach could be to add an interceptor immediately after the StaxOutInterceptor that would wrapper the XMLStreamWriter with a writer that would discard all namespace related events. Dan On Monday 12 November 2007, BrianP wrote: Is there a way to suppress the namespace in the response? I have just a simple webservice set up which uses aegis. For example, my output is currently this: list ns2:Item xmlns:ns2=http://services.mycompany.com; ns2:desc xmlns=http://services.mycompany.com;item desc/ns2:desc ns2:id xmlns=http://services.mycompany.com;1/ns2:id /ns2:Item ns2:Item xmlns:ns2=http://services.mycompany.com; ns2:desc xmlns=http://services.mycompany.com;item desc 2/ns2:desc ns2:id xmlns=http://services.mycompany.com;22/ns2:id /ns2:Item /list And I want it to be simply this: list Item descitem desc/desc id1/id /Item Item descitem desc2/desc id22/id /Item /list -- J. Daniel Kulp Principal Engineer IONA P: 781-902-8727C: 508-380-7194 [EMAIL PROTECTED] http://www.dankulp.com/blog -- J. Daniel Kulp Principal Engineer IONA P: 781-902-8727C: 508-380-7194 [EMAIL PROTECTED] http://www.dankulp.com/blog
Re: suppress namespace?
On Dec 12, 2007, at 7:55 AM, Daniel Kulp wrote: On Wednesday 12 December 2007, Vespa, Anthony J wrote: I would be interested in this as well for Aegis bindings - it does not make some of the JS libraries out there too happy. That is why doing it at the interceptor level is ideal. It would be completely independent of the databinding. Heck, you would be able to feed it a DOMSource if using a ProviderSource type thing and the namespaces would get stripped out as well. I'm not sure this can be done with an interceptor. I'd guess that, client that expects messages to be namespace free are unlikely to send messages with the proper namespaces in the first place. When aegis sees the xml without namespaces, it isn't going match nested elements in the BeanType class to the xml elements because it matches on qname. From what I have seen of the BeanType code, think that you can make aegis expect namespace free nested elements using a new TypeCreater which creates BeanTypes with no namespace expectations. This is how the StructType works. Now that I think about it, I bet the javascript libraries are expecting soap encoding which doesn't have namespace qualified nested elements. -dain
Re: suppress namespace?
Dain, One of the main use cases for such namespace free responses is for the REST style things where a client does a get on a URL and receives an XML response back.The XML parsers in various toolkits (and browsers) don't always work well with the namespaces that JAXB and Aegis would always spit out. Most likely, you would register a service on two URL's. One that would return a proper XML that is consumable by smarter clients and another that would have the strip interceptor setup.You may be able to do something really smart in the interceptor like look at the user agent or something and only strip for certain agents. Dan On Wednesday 12 December 2007, Dain Sundstrom wrote: On Dec 12, 2007, at 7:55 AM, Daniel Kulp wrote: On Wednesday 12 December 2007, Vespa, Anthony J wrote: I would be interested in this as well for Aegis bindings - it does not make some of the JS libraries out there too happy. That is why doing it at the interceptor level is ideal. It would be completely independent of the databinding. Heck, you would be able to feed it a DOMSource if using a ProviderSource type thing and the namespaces would get stripped out as well. I'm not sure this can be done with an interceptor. I'd guess that, client that expects messages to be namespace free are unlikely to send messages with the proper namespaces in the first place. When aegis sees the xml without namespaces, it isn't going match nested elements in the BeanType class to the xml elements because it matches on qname. From what I have seen of the BeanType code, think that you can make aegis expect namespace free nested elements using a new TypeCreater which creates BeanTypes with no namespace expectations. This is how the StructType works. Now that I think about it, I bet the javascript libraries are expecting soap encoding which doesn't have namespace qualified nested elements. -dain -- J. Daniel Kulp Principal Engineer IONA P: 781-902-8727C: 508-380-7194 [EMAIL PROTECTED] http://www.dankulp.com/blog
Re: suppress namespace?
I created a JIRA for this: https://issues.apache.org/jira/browse/CXF-1291 It's a relatively easy thing to write so it's something that someone that's interested getting started with digging into CXF interceptors could pick up. Dan On Wednesday 21 November 2007, mule1 wrote: Is it possible to suppress the namespace in the response elements using jaxb? I have the similar issue where customer don't want the namespace in the response. dkulp wrote: With Aegis, defintely no right now. :-( Aegis always generates qualified schemas so all the elements are namespace qualified. Actually, an interesting approach could be to add an interceptor immediately after the StaxOutInterceptor that would wrapper the XMLStreamWriter with a writer that would discard all namespace related events. Dan On Monday 12 November 2007, BrianP wrote: Is there a way to suppress the namespace in the response? I have just a simple webservice set up which uses aegis. For example, my output is currently this: list ns2:Item xmlns:ns2=http://services.mycompany.com; ns2:desc xmlns=http://services.mycompany.com;item desc/ns2:desc ns2:id xmlns=http://services.mycompany.com;1/ns2:id /ns2:Item ns2:Item xmlns:ns2=http://services.mycompany.com; ns2:desc xmlns=http://services.mycompany.com;item desc 2/ns2:desc ns2:id xmlns=http://services.mycompany.com;22/ns2:id /ns2:Item /list And I want it to be simply this: list Item descitem desc/desc id1/id /Item Item descitem desc2/desc id22/id /Item /list -- J. Daniel Kulp Principal Engineer IONA P: 781-902-8727C: 508-380-7194 [EMAIL PROTECTED] http://www.dankulp.com/blog -- J. Daniel Kulp Principal Engineer IONA P: 781-902-8727C: 508-380-7194 [EMAIL PROTECTED] http://www.dankulp.com/blog