tag:blogger.com,1999:blog-2976711854892236281.post4350702927421229543..comments2024-03-28T05:10:00.697+02:00Comments on Zen in the art of IT: Spring 3: RESTful Web service SupportBrianhttp://www.blogger.com/profile/09252223334818664049noreply@blogger.comBlogger13125tag:blogger.com,1999:blog-2976711854892236281.post-90976301222586636282021-09-28T04:16:25.411+02:002021-09-28T04:16:25.411+02:00Đặt vé máy bay tại Aivivu, tham khảo
vé máy bay đ...Đặt vé máy bay tại Aivivu, tham khảo<br /><br /><a href="https://aivivu.com/ve-may-bay-di-my-us-gia-re-bao-nhieu-tien/" rel="nofollow">vé máy bay đi Mỹ tháng nào rẻ nhất</a><br /><br /><a href="https://datvere.vn/ve-may-bay-tu-my-ve-viet-nam/" rel="nofollow">từ mỹ về việt nam được chưa</a><br /><br /><a href="https://datvere.vn/ve-may-bay-tu-canada-ve-viet-nam/" rel="nofollow">giá vé máy bay từ Vancouver về việt nam</a><br /><br /><a href="https://vevietnamairline.com/ve-may-bay-tu-nhat-ban-ve-viet-nam-9312" rel="nofollow">vietnamairline từ nhật về việt nam</a><br /><br /><a href="https://datvere.vn/ve-may-bay-tu-han-quoc-ve-viet-nam/" rel="nofollow">ve may bay tu han quoc ve viet nam</a><br /><br /><a href="https://vevietnamairline.com/ve-may-bay-tu-dai-loan-ve-viet-nam-9313" rel="nofollow">Vé máy bay từ Đài Loan về Việt Nam</a><br /><br /><a href="https://aivivu.com/ve-may-bay-chuyen-gia-nuoc-ngoai-sang-viet-nam/" rel="nofollow">Chuyến bay cho chuyên gia nước ngoài</a>vé máy bay từ canada về việt namhttps://aivivu.com/ve-may-bay-tu-canada-ve-viet-nam-gia-re/noreply@blogger.comtag:blogger.com,1999:blog-2976711854892236281.post-60243930413508274082010-10-14T02:12:51.909+02:002010-10-14T02:12:51.909+02:00i'm wrestling with issues similar to those you...i'm wrestling with issues similar to those you describe here. i'm having issues with the restTemplate.postForObject() method. Would you please take a look at my post here? i would appreciate any feedback. thanks for your time.<br />tia<br /><br />http://stackoverflow.com/questions/3928163/spring-resttemplate-post-parameters-from-complex-objectAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-2976711854892236281.post-80471559889723582752010-07-13T18:36:30.985+02:002010-07-13T18:36:30.985+02:00Thanks Brian,
Able to run it using Spring 3.0.3.
...Thanks Brian,<br /><br />Able to run it using Spring 3.0.3.<br />Do elaborate on the ClassPathXmlApplicationContext and how to render the response in an xml format.<br /><br />Thanks,<br />VishwaAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-2976711854892236281.post-11752145830115677822010-07-13T11:46:46.325+02:002010-07-13T11:46:46.325+02:00Hi, a main() method should be fine. I just prefer ...Hi, a main() method should be fine. I just prefer using Unit tests rather than main methods, and if you get all the code from SVN you can just use it that way.<br /><br />If you want to keep using a main(). You just need to use an application context like the applicationContext.xml I have in the src/test/resources with a ClassPathXmlApplicationContext ...Brianhttps://www.blogger.com/profile/09252223334818664049noreply@blogger.comtag:blogger.com,1999:blog-2976711854892236281.post-15483900988310831442010-07-13T11:36:36.495+02:002010-07-13T11:36:36.495+02:00Hi Brian,
Could you inform me of a method to invo...Hi Brian,<br /><br />Could you inform me of a method to invoke the client without using main() method. That seems to be a major issue with my way of working.<br /><br />Regards,<br />VishwaAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-2976711854892236281.post-6415279646575258352010-07-13T09:24:03.485+02:002010-07-13T09:24:03.485+02:00Hi again,
Ok, I am going to delete some of you cod...Hi again,<br />Ok, I am going to delete some of you code comments just to keep it neat.. :)<br /><br />By the looks of it, it is because you are using 3.0.0 and not the same version as me (3.0.2)...<br />looking at the release notes for 3.0.1:<br />http://jira.springframework.org/secure/ReleaseNote.jspa?projectId=10000&version=11331<br /><br />There seem to be quite a few fixes for:<br />@ResponseBody and @RequestMapping.<br /><br />You cant get rid of '@ResponseBody', there just seems there were a couple issues with it in 3.0.0<br /><br />I have updated this example to be a more real life example, and it now uses JPA to actually create, read, update and delete to and from a MySQL DB... will have the code in SVN a little later.Brianhttps://www.blogger.com/profile/09252223334818664049noreply@blogger.comtag:blogger.com,1999:blog-2976711854892236281.post-56455559710222266392010-07-12T14:48:56.370+02:002010-07-12T14:48:56.370+02:00*************************************************
...*************************************************<br /><br />Stack Trace for this code:<br /><br />Exception in thread "main" org.springframework.web.client.HttpServerErrorException: 500 Internal Server Error<br /> at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:71)<br /> at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:392)<br /> at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:349)<br /> at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:307)<br /> at org.springframework.web.client.RestTemplate.put(RestTemplate.java:256)<br /> at client.UserClient.updateUserDetails(UserClient.java:38)<br /> at client.UserClient.main(UserClient.java:55)<br />*************************************************<br /><br />Development Environment :<br />IDE : Eclipse SDK Europa<br />Apache Tomcat 6.0<br />JDK 1.6<br />Spring 3.0<br />Maven Plugin <br /><br />Thanks,<br />Vishwa Trivedi<br />*************************************************<br />These are the details from my side.<br />I am using the main() method to invoke the client methods, also I wasn't able to autowire so had to instantiate RestTemplate.<br /><br />Any pointers will be appreciated.<br /><br />Thanks,<br />Vishwa TrivediAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-2976711854892236281.post-33110216266672034252010-07-12T14:47:39.979+02:002010-07-12T14:47:39.979+02:00This comment has been removed by a blog administrator.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2976711854892236281.post-21784409190933181372010-07-12T14:39:39.609+02:002010-07-12T14:39:39.609+02:00Hi Brian,
Thanks for your reply. There seems to be...Hi Brian,<br />Thanks for your reply. There seems to be some problem with the @ResponseBody annotation in the UsersController class wrt the PUT method(have removed it). I am a newbie in Spring and RESTful, so to be sure I will post the entire structure for your reference. I have made some trivial changes though and somehow I am not even aware of the repercussions.<br /><br />Thanks,<br />Vishwa TrivediAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-2976711854892236281.post-69984309382133217742010-07-12T12:11:31.574+02:002010-07-12T12:11:31.574+02:00Hi Vishwa,
Well I doubt I can help you with the i...Hi Vishwa,<br /><br />Well I doubt I can help you with the information given, I assume you have changed a couple things. I just checked my example again and everything still works... :)<br /><br />But, I'll give it a shot anyways...<br /><br />I tried to break mine a little, but using bad data and objects... never got that exception... What is your controller doing on the method annotated with<br />"@RequestMapping(method=RequestMethod.PUT)"?<br /><br />Is it returning the right type? null? exception?<br />The reason I ask is the HTTP error code for 406 means:<br />"Web server detects that the data it wants to return is not acceptable to the client, it returns a header containing the 406 error code"<br /><br />So I would guess you are returning something wasn't expecting..<br /><br />Just looking at the line numbers on the stack trace and in my code and the RestTemplate code they do not tie up.<br />So what version of Spring are you using?Brianhttps://www.blogger.com/profile/09252223334818664049noreply@blogger.comtag:blogger.com,1999:blog-2976711854892236281.post-23718160822342554742010-07-12T11:21:01.750+02:002010-07-12T11:21:01.750+02:00Hi,
The code is generating an error for the PUT me...Hi,<br />The code is generating an error for the PUT method. Stack trace :<br /><br />*************************************************<br />org.springframework.web.client.HttpClientErrorException: 406 Not Acceptable<br />at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:69)<br /> at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:392)<br /> at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:349)<br /> at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:307)<br /> at org.springframework.web.client.RestTemplate.put(RestTemplate.java:256)<br /> at client.UserClient.updateUserDetails(UserClient.java:39)<br /> at client.UserClient.main(UserClient.java:60)<br /><br />*************************************************<br /><br />The error code being generated is quite an unusual one. <br />I am not able to figure this out. Kindly help.<br /><br />Vishwa TrivediAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-2976711854892236281.post-79352586003436770092010-07-09T11:39:10.686+02:002010-07-09T11:39:10.686+02:00This refers the the HTTP server cache, not the bro...This refers the the HTTP server cache, not the browser cache.<br /><br />It will be configured differently for each webserver out there... below is a link to the apache docs on their caching...<br />http://httpd.apache.org/docs/2.1/caching.html<br /><br />And here is another site with some more information.<br />http://www.websiteoptimization.com/speed/tweak/cache/Brianhttps://www.blogger.com/profile/09252223334818664049noreply@blogger.comtag:blogger.com,1999:blog-2976711854892236281.post-13396379489497299972010-07-09T09:29:10.005+02:002010-07-09T09:29:10.005+02:00"REST takes advantage of HTTP caches. (A cach..."REST takes advantage of HTTP caches. (A cache can't to do anything a POST; but they can cache GETs and expire those entries based on PUTs and DELETEs.)."<br /><br />I don't get this point.<br /><br />So on browser 1 there is a get request. The browser cache it for futher access.<br /><br />Then on browser 2, another computer and all, a user perform a PUT or DELETE on the same resource.<br /><br />How browser 1 will be aware that the resource isn't available anymore and will clear it's cache ?Foudreshttps://www.blogger.com/profile/05977228915328575616noreply@blogger.com