From: Bill B. <bb...@re...> - 2009-04-25 17:22:45
|
Can you show me: 1) What the signature of your JAX-RS method looks like? 2) Can you show me example output? (the javascript) 3) Can you show me an example URI? Thanks Jeff S wrote: > Would it be as simple as extending AbstractJAXBProvider (recalling class > name from memory) and overriding the writeTo method to append with the > callback name in the output stream, marshal with the super's marshaller, > and then append the closing paren after the marshaller returns? Not > sure if the callback info is available inside the marshaller there but I > could probably work around that. > > I appreciate you looking into it. I'm so busy here at work I don't have > much time for research, but I certainly don't want to have the work done > for me. A nudge in the right direction would help speed things up! > > Thanks again! > > - Jeff > > > > ------------------------------------------------------------------------ > Date: Fri, 24 Apr 2009 17:59:54 -0400 > Subject: Re: [Resteasy-developers] Marshalling to JSON for cross-domain > javascript apps? > From: sd...@gm... > To: jt...@ho... > CC: res...@li... > > I'll try to take a look at this over the weekend... Ping me again if I > don't get back to you. > > -Solomon > > On Fri, Apr 24, 2009 at 5:49 PM, Jeff S <jt...@ho... > <mailto:jt...@ho...>> wrote: > > So far I am pretty much at a loss at how to wrap the JSON provider > in RESTEasy so that I can take the provider's output and wrap it > with the callback. The searching I've done looks like people are > using CXF's JAX-RS implementation, and they're talking about > creating filters to achieve the wrapping. I already have a filter > that can do it, but it seems to mess up RESTEasy. > > Is there any more light you can shed on using the current JSON > provider to do the actual marshalling, then I can just wrap it with > the callback? Even some psuedocode would help me navigate through > the RESTEasy code... > > - Jeff > > > > ------------------------------------------------------------------------ > Date: Tue, 21 Apr 2009 14:57:05 -0400 > Subject: Re: [Resteasy-developers] Marshalling to JSON for > cross-domain javascript apps? > From: sd...@gm... <mailto:sd...@gm...> > To: jt...@ho... <mailto:jt...@ho...> > CC: res...@li... > <mailto:res...@li...> > > > You have quite a bit going on here. Let me start with the following: > > 1) http://www.jboss.org/community/wiki/JAXRSExtensionMappings - you > can use extensions (/foo.xml, /foo.json) to set the Content-Type > > 2) About the callbacks - search for: "jax-rs callback json." You'll > get a whole bunch of json callback implementations for other jax-rs > implementations. I'll try to get something similar up and running > for RESTEasy, but those other implementations should give you a good > idea on how to implement your own json callback "@Provider" for > RESTEasy. > > -Solomon > > On Tue, Apr 21, 2009 at 12:37 PM, Jeff S <jt...@ho... > <mailto:jt...@ho...>> wrote: > > Has anyone already written a provider to "wrap" JSON in an > executable javascript statement for cross-domain requests? > > Read below if you want some background on the problem I'm having: > > I have a JS GUI that is making cross-domain requests to my rest > service. I am using EXT-JS's ScriptTagProxy to get around the > problem of doing AJAX requests across domains. The main problem > with that is that I can't set the Accept header to > "application/json" or "text/javascript" with ScriptTagProxy. To > get around it, I'm passing it in as a URL parameter and using a > servlet filter to add it as a header. > > In order to get the JSON to be read correctly by the JS gui, the > rest service has to return a executable javascript statement, so > returning plain JSON doesn't work. EXT-JS's ScriptTagProxy > makes the request and automatically puts adds a URL parameter > "callback" and sets it equal to whatever you want, or defaults > to a value if you don't supply anything. What EXT-JS expects to > see returned from the service is something like > "someCallbackName({some JSON});". > > I was using the filter that added the accept header based on > what was passed in as the accept URL parameter, and also writing > whatever was in the callback parameter to the response stream > before passing the request and response along the filter chain, > then adding the closing parenthesis and semicolon after the > chain returned. This works but sometimes I get an error from > RESTeasy when the filter isn't attempting to modify the response > stream (ie. the request is from my JSF gui, and doesn't specify > a callback param, so the filter will just add teh accept param > as a header): > > Could not find a message body reader for type: interface > javax.ws.rs.core.SecurityContext of content type: application/xml > > My rest service methods use the @Context annotation to inject > the security context and somehow RESTEasy is thinking it has to > unmarshall it? I'm guessing that the filter is screwing up the > streams and in turn RESTEasy is getting confused. I don't know > how it's happening, since the filter is pretty simple, but I'm > using other filters (like Spring Security). If I had time to > look into it further I could probably pinpoint it, but someone > here might know much more quickly the exact problem. > > It might be a coincidence, but when I comment out the filter and > just use my JSF gui (which doesn't suffer from the cross-domain > problems, since the communication is server to server and I'm > using the RESTEasy client framework for the REST calls) I don't > get the error. Other times, the code works fine with the filter... > > ------------------------------------------------------------------------ > Rediscover Hotmail®: Get quick friend updates right in your > inbox. Check it out. > <http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Updates2_042009> > > ------------------------------------------------------------------------------ > Stay on top of everything new and different, both inside and > around Java (TM) technology - register by April 22, and save > $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco. > 300 plus technical and hands-on sessions. Register today. > Use priority code J9JMT32. http://p.sf.net/sfu/p > _______________________________________________ > Resteasy-developers mailing list > Res...@li... > <mailto:Res...@li...> > https://lists.sourceforge.net/lists/listinfo/resteasy-developers > > > > ------------------------------------------------------------------------ > Rediscover Hotmail®: Get quick friend updates right in your inbox. > Check it out. > <http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Updates2_042009> > > > > ------------------------------------------------------------------------ > Rediscover Hotmail®: Get e-mail storage that grows with you. Check it > out. > <http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Storage2_042009> > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > Crystal Reports - New Free Runtime and 30 Day Trial > Check out the new simplified licensign option that enables unlimited > royalty-free distribution of the report engine for externally facing > server and web deployment. > http://p.sf.net/sfu/businessobjects > > > ------------------------------------------------------------------------ > > _______________________________________________ > Resteasy-developers mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/resteasy-developers -- Bill Burke JBoss, a division of Red Hat http://bill.burkecentral.com |