Re: Restlet ClientResource Post Chunked Encoding - WCF Unsuported
Hello Luiz, Restlet post my xml with Transfer-Encoding: chunked, and my WCF service, can't to interpret posted content That sounds quite strange, because this is a quite basic feature of HTTP. What do you mean by my WCF service can't interpret the posted content? Do you receive an error status? Does the WCF service receive an incomplete XML file? best regards, Thierry Boileau Hello All, I'm developing a product that will use extensively of Restlet for consume WCF Rest Services. I had created a method to post a XML of a class containing 2 attributes. Restlet post my xml with Transfer-Encoding: chunked, and my WCF service, can't to interpret posted content, unfortunately WCF continues can't to deserialize my class parameters. I had tryed use the solution described here: http://osdir.com/ml/java.restlet/2007-05/msg00097.html, but won't worked for me. My restlet client continues to post my request content using Transfer-Encoding: chunked. =( Anybody had a problem like this? Can anybody help-me??? Thanks all and sorry by bad bad english =) Luiz Alberto luiz...@gmail.com mailto:luiz...@gmail.com -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2427754
Gzip on netty
hi, I just setup a rest app that use Netty as front end. however, it seem like is not g-zip enabled by default. how can i configure it and test it out ? kiwi happy hacking ! -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2427753
Re: JAXRS - methodNotAllowed vs resourceMethodNotFound?
Hi Anthony, it's a long time ago, but if I remember right, your usecase is not planned in JAX-RS, so it is not implemented. I have the code not on the hand, and, I will not have time to look this week. The ExceptionHandler is a class of Restlet, and not implementing a JAX-RS interface, right? Than you could modify the JaxRsRestlet, so that you could give a subclass of ExceptionHandler (or change ExceptionHandler to an interface and use the logic as default implementation with the possibility to extend it.). Perhaps you need to extend the signature of method ExceptionHandler#methodNotAllowed() by addings the methods name. If you change it, it would be cool, if you could give the changes back to the community, see http://www.restlet.org/community and especially http://www.restlet.org/community/contribute. If I remember right, the only sense of this class was to redude the number lines of code in the class JaxRsRestlet, and this was a meaningful own part of the logic. best regards Stephan webp...@tigris.org schrieb: Hi, I have a resource say, GetOnlyResource which only supports the get GET method. When my client calls the GetOnlyResource with PUT method there's no hooks for me to handle this Exception. I was under the impression that the above situation would be resourceMethodNotFound and would subsequently calls ExceptionHandler#resourceMethodNotFound() which then invoke the noResMethodHandler hook. But my test reveals the above situation would end up calling ExceptionHandler#methodNotAllowed() and there's no hook to handle this exception. My assumption is, when the client tries to call a PUT method on the GetOnlyResource but the PUT method is not found on the GetOnlyResource therefore its resourceMethodNotFound. Could anyone please clarify my understanding. If my understanding was wrong what is the alternative to hook into the methodNotAllowed(). My use case is when a client calls on any Unsupported method on any resource (my example above) then I need to log it in our audit system. Currently we've implemented this use case by; GetOnlyResource #handleGet() - do real work #handlePut() - audit log the Unsupported method #handleDel() - audit log the Unsupported #handlePost() - audit log the Unsupported We have a number of resource like the one above and I'm seeking an elegant solution like using the noResMethodHandler. Thanks, Anthony Xiao -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2427803
RE: Re: Restlet ClientResource Post Chunked Encoding - WCF Unsuported
Hello Thierry, Restlet post my xml with Transfer-Encoding: chunked, and my WCF service, can't to interpret posted content That sounds quite strange, because this is a quite basic feature of HTTP. I had read about WCF not support chunked request, but not in officialy source. I tried to found something about this in MSDN, but I not found. What do you mean by my WCF service can't interpret the posted content? Do you receive an error status? Does the WCF service receive an incomplete XML file? I won't recieved any error messages, but, I'm receiving a null value for my Services attributes. Thanks, -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2427866
RE: Re: Restlet ClientResource Post Chunked Encoding - WCF Unsuported
Hello Ben, Yes, I had tried to use StringRepresentation, and my request continues to be Chunked. Thanks, -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2427857
Re: Supporting multiple types of authorization for a given route
Hi David, On Dec 5, 2009, at 3:47 PM, David Bordoley wrote: I was wondering if anyone had experience offering multiple types of authorization (HTTP BASIC, HTTP DIGEST, OAUTH, etc.) for a given route using Restlet. It isn't immediately apparent to me what the best way to do this is using the ChallengeAuthenticator class. Also what is the status of the 1.1 OAUTH extension? Will it be reintroduced in the 2.0 cycle? Thanks, In Restlet 1.1, I did this using my own Guard subclass: https://ncisvn.nci.nih.gov/svn/psc/trunk/web/src/main/java/edu/northwestern/bioinformatics/studycalendar/restlets/PscGuard.java This code supports both HTTP Basic and an application-specific scheme called psc_token. I haven't tried to update this for Restlet 2.0 yet. My understanding is that the security infrastructure is substantially different. Rhett -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2427885
Re: CacheDirective.maxAge(int) adds a quoted string to http headers
Hello Guido, I had a look at the http rfc, and I notice that some cache directives such as max-age specify *unquoted* values. This could have an impact... I'll fix that tomorrow. Best regards, Thierry Boileau Hi, thanks for making the CacheDirective stuff available, now. When setting max-age via the new mechanisms a line as follows is added: Cache-Control:max-age=3600 I'm absolutely no http expert. But with respect to RFC2616 14.6 age values are non-negative integers. Can it be confirmed than every popular browser will interpret this value correctly and behave accordingly? I'm writing this as I started playing with this directives to enhance caching (eg. cache ldap user information for one hour, cache listgrid layouts for one day etc.). But on Safari (4.0.4) it has no effect. I did not find the time to test other browsers or provide a simple scenario. But maybe my concerns about the string value are void, anyway. Regards, Guido Schmidt -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2427892
Re: Object exchange between Android and AppEngine
Hi Marcel, I have my business model on AppEngine and now like to use Android as a client to communicate via http. I'd like to keep my beans structure and simply transfer objects between client and server and then call servlets for method calls. a) Do you think this is a good approach? (Or are there nicer designs?) Why do you want to call Servlets? You could implement your logic in Restlets. best regards Stephan -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2427898
Re: Re: Restlet ClientResource Post Chunked Encoding - WCF Unsuported
In my case my response with JsonRepresentation was being chunked due to what I believe was a bug with JsonRepresentation (reported on this list, but I think it must be stuck in moderation as there has been no response). My approach to find out why I was getting the chunked header was to step through Restlet code in the debugger and see which code path was setting that header. In my case it turned out that JsonRepresentation does not know its content length when it is constructed via JsonRepresentation(String). You are probably having a different problem, but see if you can track down the reason for the chunked header being added. On Mon, Dec 7, 2009 at 8:10 AM, Luiz Alberto luiz...@gmail.com wrote: Hello Ben, Yes, I had tried to use StringRepresentation, and my request continues to be Chunked. Thanks, -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2427857 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2427910
XML format in ATOM content element
Hi, I am trying to use the Restlet ATOM extension and I cannot figure out why I am losing the formatting of my content element in the Atom document I am creating. Here is a piece of code from my class that extends ServerResource: public Representation getAtomFeed() throws IOException { Feed f = new Feed(); MapString, String attrs; f.setTitle(new Text(MediaType.TEXT_PLAIN, Feed Title)); f.setId(some identifier); Person p = new Person(); p.setName(me); f.getAuthors().add(p); Generator gen = new Generator(); gen.setName(RESTlet); gen.setUri(new Reference(http://www.restlet.org;)); gen.setVersion(2.0M6); f.setGenerator(gen); f.setUpdated(new Date()); //Add feed links //... //Perform query that returns a map of strings. attrs = something.getAttributes(someValue); Entry entry = new Entry(); entry.setUpdated(new Date()); entry.setId(identifier); Content c = new Content(); c.setToEncode(false); c.setInlineContent(new SaxRepresentation(MediaType.APPLICATION_XML) { @Override public void write(XmlWriter writer) { for(Map.EntryString, String e : attrs.entrySet()){ try { writer.dataElement(e.getKey(), e.getValue() == null ? : e.getValue()); } catch (SAXException e1) { e1.printStackTrace(); } } } }); entry.setContent(c); //Add entry links //... f.getEntries().add(entry); return f; } Here is the ATOM feed that this code creates: ?xml version=1.0 standalone='yes'? feed xmlns=http://www.w3.org/2005/Atom; author nameme/name /author generator uri=http://www.restlet.org; version=2.0M6RESTlet/generator idsome identifier/id title type=textFeed Title/title updated2009-12-07T13:03:04.79Z/updated entry content type=application/xmlDisplayNameJohn Smith MD/DisplayName FirstNameJohn/FirstName LastNameSmith/LastName SuffixMD/Suffix /content identry identifier/id updated2009-12-07T13:03:07.65Z/updated /entry /feed Is there a way to correct this format issue or I am completely off base with my resource code. Any help is appreciated.?xml version=1.0 standalone='yes'? feed xmlns=http://www.w3.org/2005/Atom; author nameme/name /author generator uri=http://www.restlet.org; version=2.0M6RESTlet/generator idsome identifier/id title type=textFeed Title/title updated2009-12-07T13:03:04.79Z/updated entry content type=application/xmlDisplayNameJohn Smith MD/DisplayName FirstNameJohn/FirstName LastNameSmith/LastName SuffixMD/Suffix /content identry identifier/id updated2009-12-07T13:03:07.65Z/updated /entry /feed
BUG?: JsonRepresentation does not inherit size from wrapped StringRep
JsonRepresentation has the member variable jsonRepresentation for using a wrapped Representation object in some cases. The bug I'm seeing is that getSize() on the JsonRepresentation object always returns -1 in those cases where it is backed by this other underlying representation. I believe a better behavior would be for JsonRepresntation to over getSize() to return jsonRepresentation.getSize() in those cases. I'm using 2.0-M5 (until M6 hits the public maven repo) but the problem looks like it is also in M6. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2427907
Re: XML format in ATOM content element
Not sure about your formatting problem, but I thought i'd mention that you need to add a namespace declaration (at the minimum use the default namespace) on the XML within your atom:content element, otherwise an XML processor is going to assume that your XML is in the Atom namespace and many processors will fail. That said, why not use a standard dialect such as hCard in xhtml to represent your contact objects? dave On Mon, Dec 7, 2009 at 10:24 AM, Rob Lincourt rob.linco...@gmail.com wrote: Hi, I am trying to use the Restlet ATOM extension and I cannot figure out why I am losing the formatting of my content element in the Atom document I am creating. Here is a piece of code from my class that extends ServerResource: public Representation getAtomFeed() throws IOException { Feed f = new Feed(); MapString, String attrs; f.setTitle(new Text(MediaType.TEXT_PLAIN, Feed Title)); f.setId(some identifier); Person p = new Person(); p.setName(me); f.getAuthors().add(p); Generator gen = new Generator(); gen.setName(RESTlet); gen.setUri(new Reference(http://www.restlet.org;)); gen.setVersion(2.0M6); f.setGenerator(gen); f.setUpdated(new Date()); //Add feed links //... //Perform query that returns a map of strings. attrs = something.getAttributes(someValue); Entry entry = new Entry(); entry.setUpdated(new Date()); entry.setId(identifier); Content c = new Content(); c.setToEncode(false); c.setInlineContent(new SaxRepresentation(MediaType.APPLICATION_XML) { �...@override public void write(XmlWriter writer) { for(Map.EntryString, String e : attrs.entrySet()){ try { writer.dataElement(e.getKey(), e.getValue() == null ? : e.getValue()); } catch (SAXException e1) { e1.printStackTrace(); } } } }); entry.setContent(c); //Add entry links //... f.getEntries().add(entry); return f; } Here is the ATOM feed that this code creates: ?xml version=1.0 standalone='yes'? feed xmlns=http://www.w3.org/2005/Atom; author nameme/name /author generator uri=http://www.restlet.org; version=2.0M6RESTlet/generator idsome identifier/id title type=textFeed Title/title updated2009-12-07T13:03:04.79Z/updated entry content type=application/xmlDisplayNameJohn Smith MD/DisplayName FirstNameJohn/FirstName LastNameSmith/LastName SuffixMD/Suffix /content identry identifier/id updated2009-12-07T13:03:07.65Z/updated /entry /feed Is there a way to correct this format issue or I am completely off base with my resource code. Any help is appreciated. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2428073
Re: BUG?: JsonRepresentation does not inherit size from wrapped StringRep
Hello Ben, your first post has been moderated, but was lost in the list of posts... sorry. Actually, the wrapped Representation is first parsed (in the private getJsonText() method) as JsonObject, even when the write method is called. Thus, it is difficult to know by advance the size of the text representation generated by the org.json library. If the wrapped representation is not aimed to be parsed (in order to get a JsonObject, JsonArray, etc) and is only aimed to be written, the JsonRepresentation is useless. Best regards, Thierry Boileau JsonRepresentation has the member variable jsonRepresentation for using a wrapped Representation object in some cases. The bug I'm seeing is that getSize() on the JsonRepresentation object always returns -1 in those cases where it is backed by this other underlying representation. I believe a better behavior would be for JsonRepresntation to over getSize() to return jsonRepresentation.getSize() in those cases. I'm using 2.0-M5 (until M6 hits the public maven repo) but the problem looks like it is also in M6. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2427907 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2428085
Re: Restlet ClientResource Post Chunked Encoding - WCF Unsuported
Hi Luiz, There are two cases a StringRepresentation has an unknown size: - the underlying string is null - an UnsupportedEncodingException is thrown when the size of the StringRepresentation is computed. The second case happens in the updateSize method: if (getCharacterSet() != null) { setSize(getText().getBytes(getCharacterSet().getName()).length); } else { setSize(getText().getBytes().length); } Do you specify a CharacterSet? If not, what is your default one? Best regards, Thierry Boileau Hello Ben, Yes, I had tried to use StringRepresentation, and my request continues to be Chunked. Thanks, -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2427857 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2428086