Eric, One problem here is that I'm not very good at JAX-RS.
If you set a breakpoint in here, is it called? It is possible that what we have here is a bug. I guess at this point I'd vote for a JIRA, and I'll try to start from the JIRA and discover what's going on. --benson On Mon, Oct 4, 2010 at 3:40 PM, Kampf, Eric <[email protected]> wrote: > Benson, > > Could you be more specific about what it means to "explicitly create the > AegisContext and pass it into the AegisDatabinding"? Here's what I tried: > > > I have a custom ElementProvider class. I tried overriding the > "getAegisContext" method like this: > > protected AegisContext getAegisContext(Class<?> type, Type genericType) { > AegisContext ctx = super.getAegisContext(type, genericType); > TypeCreationOptions tco = ctx.getTypeCreationOptions(); > tco.setQualifyAttributes(false); > tco.setQualifyElements(false); > return ctx; > } > And the end result was no change in behavior (i.e. I still saw namespaces) > > Next I tried to create my own context like this: > protected AegisContext getAegisContext(Class<?> type, Type genericType) { > AegisContext ctx = ctx = new AegisContext(); > TypeCreationOptions tco = new TypeCreationOptions(); > tco.setQualifyAttributes(false); > tco.setQualifyElements(false); > ctx.setTypeCreationOptions(tco); > return ctx; > } > And this failed entirely. The failure was not logged, but no XML was > generated at all. > > > So I am probably approaching this the wrong way. I am not familiar with the > inner workings of Aegis, and could really some more details. > > Thanks. > > -Eric > > -----Original Message----- > From: Benson Margulies [mailto:[email protected]] > Sent: Saturday, October 02, 2010 2:04 PM > To: [email protected] > Subject: Re: Aegis Binding without namespaces > > BeanTypeInfo has a list of element qnames. You want all of these to > have a null namespace, since it's elements, not types, that concern > you. (Keep in mind that Aegis in some cases uses xsi:type, and that's > a whole other subject I'll end with). > > Note that BeanTypeInfo has a boolean 'qualifyElements', defaulted to true. > > This is set based on the value in the TypeCreationOptions. > > So, if you explicitly create the AegisContext and pass it into the > AegisDatabinding, you can specify the type creation options, and turn > off qualified elements. > > If you also need to squash the namespaces assigned to schema types > (which would break the use of plain old xs:string) your port of call > is: > > org.apache.cxf.aegis.type.AbstractTypeCreator.createQName(Class) > > On Sat, Oct 2, 2010 at 9:09 AM, Benson Margulies <[email protected]> > wrote: >> Eric, >> >> I think that there is a more maintainable solution here. >> >> What you want is to customize the mapping of FQCNs to URIs. I'm about >> to walk out of the house, but when I get back I will re-excavate the >> question of whether there is a class you could subclass and stuff into >> a setter (irish or otherwise) to take control of this process. >> >> >> >> On Fri, Oct 1, 2010 at 9:57 PM, Kampf, Eric <[email protected]> wrote: >>> Hmmm. If I understand this correctly (and I may not), this would work but >>> it might not be maintainable. Here's why: From what I've seen of Aegis, >>> the namespace mappings are specified on a per-object basis. The objects I >>> am dealing with a fairly complex (i.e. many layers of nested objects) and >>> they are maintained by other developers. The first object change that did >>> not have a corresponding Aegis config change might break the service. >>> >>> In any case I'll still give this a try. Hopefully I will find a magic >>> switch in Aegis that simplifies the overriding of namespaces. >>> >>> I'll let you know how it goes. >>> >>> Thanks. >>> >>> -Eric >>> >>> From: Sergey Beryozkin [mailto:[email protected]] >>> Sent: Friday, October 01, 2010 4:20 PM >>> To: [email protected] >>> Cc: Kampf, Eric >>> Subject: Re: Aegis Binding without namespaces >>> >>> Yes, this should work, override a createReader method in the provider and >>> return a custom reader, here's a basic example : >>> >>> http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/CustomXmlStreamReader.java >>> >>> cheers, Sergey >>> >>> On Fri, Oct 1, 2010 at 8:52 PM, Daniel Kulp >>> <[email protected]<mailto:[email protected]>> wrote: >>> On Friday 01 October 2010 2:28:34 pm Kampf, Eric wrote: >>>> Sergey, >>>> >>>> I implemented your suggestion and it worked for outgoing data. >>>> Unfortunately incoming data is an issue. Aegis still requires the >>>> namespace information to be able to unmarshal the XML. >>>> >>>> So what I am really looking for is a way to entirely disable namespace >>>> mapping in the binding. I realize it is not directly supported, but >>>> perhaps there is some way to "trick" the binding? Any suggestions? >>> Is it possible to do the reverse on the way in? Wrapper the XMLStreamReader >>> with one that always returns a preconfigured namespace for all the calls the >>> pull a namespace? >>> >>> Dan >>> >>> >>>> >>>> Thanks again for all your help to this point. >>>> >>>> -Eric >>>> >>>> -----Original Message----- >>>> From: Sergey Beryozkin >>>> [mailto:[email protected]<mailto:[email protected]>] >>>> Sent: Wednesday, September 29, 2010 5:45 AM >>>> To: [email protected]<mailto:[email protected]> >>>> Subject: Re: Aegis Binding without namespaces >>>> >>>> Hi Eric >>>> >>>> the way you can do it is as follows. >>>> >>>> Extend AegisElementProvider [1] and override its createStreamWriter method >>>> and create a custom writer, see [2] for an example, just pass to it the >>>> writer instance AegisElementProvider creates. >>>> >>>> You just probably need to override writeNamespace(...) with a no-op >>>> implementation and writeStartElement and block the namespaces. >>>> >>>> I believe you work with DOSGI. In that case, do not use >>>> org.apache.cxf.rs.databindng property but rather an >>>> "org.apache.cxf.rs.providers" and list the full name of your custom >>>> provider. >>>> >>>> hope it helps, Sergey >>>> >>>> [1] >>>> http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/java/o >>>> rg/apache/cxf/jaxrs/provider/AegisElementProvider.java [2] >>>> http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/ >>>> apache/cxf/systest/jaxrs/CustomXmlStreamWriter.java >>>> >>>> On Wed, Sep 29, 2010 at 2:15 AM, Kampf, Eric >>>> <[email protected]<mailto:[email protected]>> wrote: >>>> > Yes the reason for this is that our primary clients are mobile devices, >>>> > some of which have very limited XML parsing capabilities. REST seems to >>>> > emphasize simplicity and namespace handling is not always simple. SOAP >>>> > is a little too 2009 for my taste. :-) >>>> > >>>> > -----Original Message----- >>>> > From: Benson Margulies >>>> > [mailto:[email protected]<mailto:[email protected]>] >>>> > Sent: Tuesday, September 28, 2010 9:09 PM >>>> > To: [email protected]<mailto:[email protected]> >>>> > Subject: Re: Aegis Binding without namespaces >>>> > >>>> > It's a big problem. The mapping of packages to namespaces avoids >>>> > collisions. If you don't want namespaces, then you have to find >>>> > another solution. >>>> > >>>> > I personally find no-namespace XML to be entirely too 1999 for my >>>> > taste, but I imagine that you have a good reason for it. >>>> > >>>> > On Tue, Sep 28, 2010 at 4:49 PM, Daniel Kulp >>>> > <[email protected]<mailto:[email protected]>> wrote: >>>> > > I honestly don't think anyone has looked at this at all. If it's >>>> > >>>> > something >>>> > >>>> > > you need, you'll likely have to work on it and submit patches. >>>> > > >>>> > > Dan >>>> > > >>>> > > On Tuesday 28 September 2010 4:26:35 pm Kampf, Eric wrote: >>>> > >> Hello, >>>> > >> >>>> > >> I would like to use CXF's Aegis data binding for a REST service (I >>>> > >> have multiple reasons for preferring Aegis over JAXB...). The >>>> > >> biggest impediment I face however is the presence of namespaces on >>>> > >> all elements. This will be a hardship for most of our clients. >>>> > >> >>>> > >> I see that this topic came up a couple of years ago on this list: >>>> > >> http://www.mail-archive.com/[email protected]/msg04683.htm >>>> > >> l >>>> > >>>> > . >>>> > >>>> > >> It even resulted in the creation of a JIRA issue which is still listed >>>> > >>>> > as >>>> > >>>> > >> open: >>>> > https://issues.apache.org/jira/browse/CXF-1291?page=com.atlassian.jira.pl >>>> > u >>>> > >>>> > >> gin.system.issuetabpanels:comment-tabpanel. >>>> > >> >>>> > >> Does anyone know if there is a solution for this? Our clients are >>>> > >>>> > simply >>>> > >>>> > >> not going to be able to use namespaces. Is there any hope of >>>> > >>>> > configuring >>>> > >>>> > >> Aegis to function without namespaces? >>>> > >> >>>> > >> Thanks. >>>> > >> >>>> > >> -Eric >>>> > > >>>> > > -- >>>> > > Daniel Kulp >>>> > > [email protected]<mailto:[email protected]> >>>> > > http://dankulp.com/blog >>> -- >>> Daniel Kulp >>> [email protected]<mailto:[email protected]> >>> http://dankulp.com/blog >>> >>> >> >
