Latest News

    • Web Services Architecture – When to Use SOAP vs REST

      SOAP (Simple Object Access Protocol) and REST (Representation State Transfer) are popular with developers working on system integration based projects. Software architects will design the application from various perspectives and also decides, based on various reasons, which approach to take to expose new API to third party applications. As a software architect, it is good practice to involve your development team lead during system architecture process.   This article, based on my experience, will discuss when to use SOAP or REST web services to expose your API to third party clients.   Web Services Demystified Web services are part of the Services Oriented Architecture. Web services are used as the model for process decomposition and assembly. I have been involved in discussion where there were some misconception between web services and web API.   The W3C defines a Web Service generally as:   A software system designed to support interoperable machine-to-machine interaction over a network.   Web API also known as Server-Side Web API is a programmatic interface to a defined request-response message system, typically expressed in JSON or XML, which is exposed via the web – most commonly by means of an HTTP-based web server. (extracted from Wikipedia)   Based on the above definition, one can insinuate when SOAP should be used instead of REST and vice-versa but it is not as simple as it looks. We can agree that Web Services are not the same as Web API. Accessing an image over the web is not calling a web service but retrieving a web resources using is Universal Resource Identifier. HTML has a well-defined standard approach to serving resources to clients and does not require the use of web service in order to fulfill their request.   Why Use REST over SOAP Developers are passionate people. Let's briefly analyze some of the reasons they mentioned when considering REST over SOAP:   REST is easier than SOAP I'm not sure what developers refer to when they argue that REST is easier than SOAP. Based on my experience, depending on the requirement, developing REST services can quickly become very complex just as any other SOA projects. What is your service abstracting from the client? What is the level of security required? Is your service a long running asynchronous process? And many other requirements will increase the level of complexity. Testability: apparently it easier to test RESTFul web services than their SOAP counter parts. This is only partially true; for simple REST services, developers only have to point their browser to the service endpoints and a result would be returned in the response. But what happens once you need to add the HTTP headers and passing of tokens, parameters validation… This is still testable but chances are you will require a plugin for your browser in order to test those features. If a plugin is required then the ease of testing is exactly the same as using SOAPUI for testing SOAP based services.   RESTFul Web Services serves JSON that is faster to parse than XML This so called "benefit" is related to consuming web services in a browser. RESTFul web services can also serve XML and any MIME type that you desire. This article is not focused on discussing JSON vs XML; and I wouldn't write any separate article on the topic. JSON relates to JavaScript and as JS is very closed to the web, as in providing interaction on the web with HTML and CSS, most developers automatically assumes that it also linked to interacting with RESTFul web services. If you didn't know before, I'm sure that you can guess that RESTFul web services are language agnostic. Regarding the speed in processing the XML markup as opposed to JSON, a performance test conducted by David Lead, Lead Engineer at MarkLogic Inc, find out to be a myth.   REST is built for the Web Well this is true according to Roy Fielding dissertation; after all he is credited with the creation of REST style architecture. REST, unlike SOAP, uses the underlying technology for transport and communication between clients and servers. The architecture style is optimized for the modern web architecture. The web has outgrown is initial requirements and this can be seen through HTML5 and web sockets standardization. The web has become a platform on its own right, maybe WebOS. Some applications will require server-side state saving such as financial applications to e-commerce.   Caching When using REST over HTTP, it will utilize the features available in HTTP such as caching, security in terms of TLS and authentication. Architects know that dynamic resources should not be cached. Let's discuss this with an example; we have a RESTFul web service to serve us some stock quotes when provided with a stock ticker. Stock quotes changes per milliseconds, if we make a request for BARC (Barclays Bank), there is a chance that the quote that we have receive a minute ago would be different in two minutes. This shows that we cannot always use the caching features implemented in the protocol. HTTP Caching be useful in client requests of static content but if the caching feature of HTTP is not enough for your requirements, then you should also evaluate SOAP as you will be building your own cache either way not relying on the protocol.   HTTP Verb Binding HTTP verb binding is supposedly a feature worth discussing when comparing REST vs SOAP. Much of public facing API referred to as RESTFul are more REST-like and do not implement all HTTP verb in the manner they are supposed to. For example; when creating new resources, most developers use POST instead of PUT. Even deleting resources are sent through POST request instead of DELETE.   SOAP also defines a binding to the HTTP protocol. When binding to HTTP, all SOAP requests are sent through POST request.   Security Security is never mentioned when discussing the benefits of REST over SOAP. Two simples security is provided on the HTTP protocol layer such as basic authentication and communication encryption through TLS. SOAP security is well standardized through WS-SECURITY. HTTP is not secured, as seen in the news all the time, therefore web services relying on the protocol needs to implement their own rigorous security. Security goes beyond simple authentication and confidentiality, and also includes authorization and integrity. When it comes to ease of implementation, I believe that SOAP is that at the forefront.   Conclusion This was meant to be a short blog post but it seems we got to passionate about the subject.   I accept that there are many other factors to consider when choosing SOAP vs REST but I will over simplify it here. For machine-to-machine communications such as business processing with BPEL, transaction security and integrity, I suggest using SOAP. SOAP binding to HTTP is possible and XML parsing is not noticeably slower than JSON on the browser. For building public facing API, REST is not the undisputed champion. Consider the actual application requirements and evaluate the benefits. People would say that REST protocol agnostic and work on anything that has URI is beside the point. According to its creator, REST was conceived for the evolution of the web. Most so-called RESTFul web services available on the internet are more truly REST-like as they do not follow the principle of the architectural style. One good thing about working with REST is that application do not need a service contract a la SOAP (WSDL). WADL was never standardized and I do not believe that developers would implement it. I remember looking for Twitter WADL to integrate it.   I will leave you to make your own conclusion. There is so much I can write in a blog post. Feel free to leave any comments to keep the discussion going.

Thursday, 12 November 2009

Develop High Transaction Web Applications with Java MySQL & NetBeans

This entry is a brief tutorial on how to develop high transactional web application. I will be looking at how to develop a high transactional application while maintaining data integrityFor the purpose of keeping this entry simple, I will be using some RAD tools, the NetBeans IDE, to generate most of the code.

In order to follow the tutorial, you will need the following:
  1. NetBeans IDE 6.7+
  2. Java JDK 1.6+ (my version is 1.6.0_17)
  3. MySQL 5.1+
  4. MySQL Sakila database
  5. Apache Tomcat 6.x
  6. An understanding of JPA transactions and ReSTful web services
This is my definition of High Transaction Applications:

A high transaction application is one that can serve multiple simultaneous requests from clients and keep them secure from each other. The application has only two purposes: read or write data to/from a repository either JMS or DB. The transactions have to meet the ACID criteria in order to be deployed in the real world.

Ok, the above is my definition and you are free to redefine it. I am going to build a web application that will be an n-tier application:
  • Database back-end (MySQL)
  • Entity classes
  • ReSTful Web Services to allow other developers to integrate the application with theirs
  • A web based front-end
For the simplicity of the article, I will not implement any security such as user or application level security (authentication and database table privileges). This tutorial is mostly geared toward the newbies but I am sure that more advanced developers would benefit too.

Let's get coding.

  1. Make sure that you have loaded the MySQL Sakila database into your MySQL database. You can download the Sakila database from the NetBeans plugin centre (see here).
  2. Create a new web application and name whatever you like. I have named mine "WebApplication". I will now refer the application as WebApplication. Make sure to choose Tomcat as your deployment server
  3. Add the MySQL driver "mysql-connector-java-5.0.7-bin" to the WebApplication libraries. NetBeans will work and connect to the DB even without the driver but once you deploy your application to a server, the application will not be able to connect to the DB and throw a ClassNotFoundException com.mysql.jdbc.driver.

  4. We are going to develop the back-end first. NetBeans makes it very easy for us to create Entity classes from database. I would recommend newbies to learn how to manually create Entity classes and configure the persistence.xml file. This tutorial makes use of JPA but one should ignore the drawbacks of JPA/ ORM frameworks.



  5. Right click on the project name and choose Entity Classes from Database... On the next screen choose the "filmActor" table and click on the Add button. Make sure that "Include Related Tables" box is checked underneath the Selected Tables panel. The screenshot does not show the "filmActor" table as I have previously generated the Entity class but I am sure you get the idea.





  6. If you are required to create a Persistence Unit, click on the persistence button -> you can accept the default name -> choose your Persistence Library -> choose your database connection -> choose "None" for Table Generation Strategy -> click Finish








  7. After choosing the table to generate the Entity from click next -> fill Package name -> tick Generate Name Query... -> click Finish


  8.  

    NetBeans generates all the Entity classes based on the database table that you have chosen. The next thing that we want to do is generate a set of ReSTful web services from the generated Entity classes. Again, NetBeans facilitates the work for us (it is important that you also know how to create the classes manually or you will not know how to debug them if there is any problem in the future).

  9. Right click on the project name "WebApplication" -> RESTful Web Services from Entity Classes... -> Choose the Entity Classes that you would like to generate the WS for and click add or add all -> click next -> on the following screen, accept the default values and click Finish




  10. You can go ahead and test your ReSTFul Web Services by right clicking on the name of the application and click on Test RESTful Web Services




  11. The previous step will launch your web browser within which you can test your web services (click on the node on the left and see the queries on the right)




  12. Back in the NetBeans IDE; right click on the project name "WebApplication" -> click on JSF Pages from Entity Classes... (The JSF pages will not use the web services as there are packaged together with the Entity Classes. This will improve performances and still allow external applications to integrate). Choose the Entity Classes that you would like to generate the pages for -> click next. On the final screen, fill in the package name for the JPA Controller and JSF Classes -> click finish




    NetBeans will generate the necessary files to create a CRUD application with a user interface. I suggest that you familiarize yourself with the generated code.



  13. Expand the Configuration folder under your project name "WebApplication" and the web.xml file. At around line 38, change the content of the welcome-file-list to look as follow

    <welcome-file-list>
            <welcome-file>faces/welcomeJSF.jsp</welcome-file>
    </welcome-file-list>
    This will make the generate JSF page to be the landing page for the application when requested. Make sure that you do have a "welcomeJSF.jsp" file before making the change.



  14. Right click on the application name -> Run. The application should load in your web browser. Now go on, play around with the application. And why not create a client to send request to the web services? (not today)


You can load test your application by using Apache JMeter. It is easy to run and configure. If you want to take a look at how JPA implements the ACID features, browse to your controller classes. Here is a short introduction to JPA transaction. Hope you enjoyed and if you need any clarification, just leave me a comment and try to get back to you ASAP (if time permits).
  • Blogger Comments
  • Facebook Comments

64 comments :

  1. So... basically, this is a tutorial on how to use the NetBeans RAD features. I am not seeing anything about "high transaction" web applications. Guess you get what you paid for.

    ReplyDelete
  2. @Ara, NetBeans RAD features are useful in creating high transaction web app. High transaction web app if updating a DBMS system, need to make sure that they implement all the ACID features correctly. If you run the tutorial and take a look at the "controller" classes, you will see how the code is generate. I am not saying the code generate is bug, actually I said the complete opposite. You have to check your code to make sure that you:

    - open a connection
    - execute the statements
    - commit the changes (transaction)
    - roll back if there's any problem.

    High transaction goes beyond just code and brings in system architecture, caching and data replication.

    This is entry was more about the code side.

    ReplyDelete
  3. This is good written blog and helped me lot to share so many things from here..Thanks for this valuable post.
    web designing company

    ReplyDelete
  4. Hello mates, its wonderful paragraph concerning cultureand completely explained, keep it up all the time. my weblog;
    CMS developer London

    ReplyDelete
  5. I have read all the comments and suggestions posted by the visitors for this article are very fine,We will wait for your next article so only.Thanks! Webdesign

    ReplyDelete
  6. I recently found many useful information in your website especially this blog page. Among the lots of comments on your articles. Thanks for sharing. Webdesign

    ReplyDelete
  7. This is such a great resource that you are providing and you give it away for free. Webdesign

    ReplyDelete
  8. Webdesigner waar u een professionele en betaalbare website kan laten maken? De nr. 1 webdesigner in Limburg, Antwerpen en Vlaams-Brabant voor SEO websites. Webdesigner

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. Nice information and great. Thanks for sharing with us. Great job. If you want to see a collection of xcritical software visit our site

    ReplyDelete
  11. I quickly got this feeling of debilitation since I felt like none of my stuff was anyplace close comparable to that. Webdesign

    ReplyDelete
  12. Easily, the article is actually the best topic on this registry related issue. I fit in with your conclusions and will eagerly look forward to your next updates. Just saying thanks will not just be sufficient, for the fantasti c lucidity in your writing. I will instantly grab your rss feed to stay informed of any updates.
    java software outsourcing company ukraine

    ReplyDelete
  13. There are still dissertation website pages utilizing the online as you end up evidently says as part of your webpage. distinct sql

    ReplyDelete

  14. are you looking for web development company then click

    web development company in USA

    either you are looking for mobile app development then click

    Mobile app development company in USA

    either you are looking for cloud services then click

    cloud services provider company in USA

    either you are looking for Artificial Intelligence services then click

    Artificial Intelligence services provider company in USA

    ReplyDelete
  15. Hello I am so delighted I located your blog, I really located you by mistake, while I was watching on google for something else, Anyways I am here now and could just like to say thank for a tremendous post and a all round entertaining website. Please do keep up the great work. Web design

    ReplyDelete
  16. Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post. latest web series

    ReplyDelete
  17. I am glad that I saw this post. It is informative blog for us and we need this type of blog thanks for share this blog, Keep posting such instructional blogs and I am looking forward for your future posts.cursus zelfstandig ondernemer

    ReplyDelete
  18. It was wondering if I could use this write-up on my other website, I will link it back to your website though.Great Thanks. cloud hosting

    ReplyDelete
  19. Jab Apki Gallery Ya Mobile Phone Se Photo Deleted Ho Jaati Hai Tab Aap Badi Asani Se Wapas Recovey Kar Shkte Hai Use Leaye Aap Ye Post Pad Shkte Hai Delete Photo Wapas Kaise Laye Saath Hi Ager Aap Jana Chate Hai My Name Ringtone Maker Ke Baare Mai Tho Aap Badi Asani Se Tho Ye Post Pad Shkte Hai Apne Naam Ki Ringtone Kaise Banaye

    ReplyDelete
  20. This comment has been removed by the author.

    ReplyDelete
  21. Likewise your internet design is the very first impression of your site.The best internet design and development companies highly concentrate on their
    approach.find out here

    ReplyDelete
  22. According to Google Algorithm 2017, a site ought to be ResponsiveWebsite. Our eCommerce websites give you the ability to sell your goods and
    services via various retail channels.
    hire a web designer

    ReplyDelete
  23. I'd be trampled if all sites webdesign agencies gave articles like these awesome articles.

    ReplyDelete
  24. software testing company in India
    software testing company in Hyderabad
    Thanks for sharing such a valuable information with us about Develop High Transaction Web Applications with Java MySQL & NetBeans.
    please keep sharing.

    ReplyDelete
  25. I like your post. It is good to see you verbalize from the heart and clarity on this important subject can be easily observed... sayapro checker

    ReplyDelete
  26. Wohh just what I was looking for, regards for posting.
    ข้อดีUFASLOT

    ReplyDelete
  27. Also, a survey showed user satisfaction. This easy partnership brought about impactful changes, making the system more user-friendly and efficient.
    companies that make logos

    ReplyDelete
  28. Admiring the time and effort you put into your blog and detailed information you offer! Glad to chat your blog, I seem to be forward to more reliable articles and I think we all wish to thank so many good articles, blog to share with us. Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more . i am for the first time here. I found this board and I in finding It truly helpful & it helped me out a lot. I hope to present something back and help others such as you helped me 먹튀검증

    ReplyDelete
  29. Heya! I just wanted to ask if you ever have any trouble with hackers? My last blog (wordpress) was hacked and I ended up losing many months of hard work due to no back up. Do you have any solutions to protect against hackers?| 토토사이트주소

    ReplyDelete
  30. Hey buddies, such a marvelous blog you have made I’m surprised to read such informative stuf
    android app agency

    ReplyDelete
  31. This blog is further than my expectations. Nice work guys!!!
    best brand agencies

    ReplyDelete
  32. Newstyle Print offers high end, low cost banner printing in the UK 먹튀검증사이트

    ReplyDelete
  33. Nice to be visiting your blog once more, it has been months for me. Well this article that ive been waited for therefore long. i want this article to finish my assignment within the faculty, and it has same topic together with your article. Thanks, nice share. I wanted to thank you for this in your liking ensnare!! I particularly enjoying all tiny little bit of it I have you ever bookmarked to check out delivered stuff you pronounce. The blog and data is excellent and informative as well . 먹튀지구대

    ReplyDelete
  34. I want to to thank you for this great read!! I definitely loved every bit of it. I've got you saved as a favorite to check out new things youI’ve been surfing online more than 2 hours today, yet I never found any interesting article like yours. It is pretty worth enough for me. Personally, if all website owners and bloggers made good content as you did, the internet will be a lot more useful than ever before. 안전놀이터모음

    ReplyDelete
  35. I want to to thank you for this great read!! I definitely loved every bit of it. I've got you saved as a favorite to check out new things youI’ve been surfing online more than 2 hours today, yet I never found any interesting article like yours. It is pretty worth enough for me. Personally, if all website owners and bloggers made good content as you did, the internet will be a lot more useful than ever before. 토토사이트

    ReplyDelete
  36. I’ve been surfing online more than 2 hours today, yet I never found any interesting article like yours. It is pretty worth enough for me. Personally, if all website owners and bloggers made good content as you did, the internet will be a lot more useful than ever before. 먹튀검증

    ReplyDelete
  37. I read a article under the same title some time ago, but this articles quality is much, much better. How you do this.. Wonderful blog post. This is absolute magic from you! I have never seen a more wonderful post than this one. You've really made my day today with this. I hope you keep this up! You completed a number of nice points there. I did a search on the issue and found nearly all people will have the same opinion with your blog. 카디즈에이전시

    ReplyDelete
  38. This is an excellent post I seen thanks to share it. It is really what I wanted to see hope in future you will continue for sharing such a excellent post. I will really appreciate the writer's choice for choosing this excellent article appropriate to my matter.Here is deep description about the article matter which helped me more. I see some amazingly important and kept up to length of your strength searching for in your on the site 온카맨

    ReplyDelete
  39. I appreciate this article for the well-researched content and excellent wording. I got so interested in this material that I couldn’t stop reading. Your blog is really impressiv 토토커뮤니티

    ReplyDelete
  40. howdy! This article couldn't be written lots better! Searching through this article rings a bell in my memory of my previous roommate! He usually kept preaching approximately this. I'm going to deliver this article to him. Fairly sure he could have a extraordinary observe. Thanks for sharing! Excellent day, i think your weblog may be having browser compatibility issues. As soon as i test your blog in safari, it looks wonderful but at the same time as starting in i. E., it has some overlapping issues. I just favored to present you a short heads up! Except that, high-quality web page! Spot on with this write-up, i definitely feel this top notch website desires a high-quality deal extra interest. I’ll probably be returning to look at via more, thank you for the statistics! Aw, this became a really proper publish. Taking the time and real try to create a very good article… however what am i able to say… i positioned topics off a whole lot and do now not manage to get nearly something performed. 먹튀검증

    ReplyDelete
  41. great to be here in your article or post, whatever, I figure I ought to likewise buckle down for my own site like I see some great and refreshed working in your site. The post is very amazing around the world many people want to read this type of post I am also part of them and after the reading give good reviews . There is such a great amount in this article I could never have thought of alone. Your substance gives perusers things to consider in a fascinating way. 해피머니상

    ReplyDelete
  42. I’m going to read this. I’ll be sure to come back. thanks for sharing. and also This article gives the light in which we can observe the reality. this is very nice one and gives indepth information. thanks for this nice article. 토토제작

    ReplyDelete
  43. I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. 바카라사이트

    ReplyDelete
  44. "I’m going to read this. I’ll be sure to come back. thanks for sharing. and also This article gives the light in which we can observe the reality. this is very nice one and gives indepth information. thanks for this nice article...

    " 토토제작

    ReplyDelete
  45. Great article and a nice way to promote online. I'm satisfied with the information that you provided 먹튀폴리스

    ReplyDelete
  46. Hi, I log on to your new stuff like every week. Your humoristic style is witty, keep it up canaan avalon 1166 pro

    ReplyDelete
  47. Very neat article post.Really looking forward to read more. Cool. 꽁머니

    ReplyDelete
  48. This was really an interesting topic and I kinda agree with what you have mentioned here! 출장홈타이

    ReplyDelete
  49. definately enjoy every little bit of it and I have you bookmarked to check out new stuff of your blog a must read blog! 먹튀검증

    ReplyDelete
  50. Thanks, I have been hunting for details about this subject for ages and yours is the best I ave found so far. 토토커뮤니티

    ReplyDelete
  51. This article was written by a real thinking writer. I agree many of the with the solid points made by the writer. I’ll be back. social media management australia

    ReplyDelete
  52. I simply want to tell you that I am new to weblog and definitely liked this blog site. Very likely I’m going to bookmark your blog . You absolutely have wonderful stories. Cheers for sharing with us your blog. 메이저사이트

    ReplyDelete
  53. "Thanks so much for the post.Much thanks again. Awesome.

    " 슬롯사이트

    ReplyDelete
  54. All your hard work is much appreciated. Nobody can stop to admire you. Lots of appreciation. 먹튀검증

    ReplyDelete
  55. I think this is a sublime article, and the content published is fantastic. This content will help me to complete a paper that I've been working on for the last 2 weeks. It was a difficult 2 weeks, but I am glad the work is done now. 온라인바카라

    ReplyDelete
  56. Great article and a nice way to promote online. I'm satisfied with the information that you provided 꽁머니

    ReplyDelete
  57. I have a hard time describing my thoughts on content, but I really felt I should here. Your article is really great. I like the way you wrote this information 먹튀검증

    ReplyDelete
  58. "Hello, just wanted to tell you, I loved this blog post. It was helpful.
    Keep on posting!" 먹튀검증

    ReplyDelete
  59. "Hello, just wanted to tell you, I loved this blog post. It was helpful.
    Keep on posting!" 출장마사지

    ReplyDelete
  60. wow... what a great blog, this writter who wrote this article it's realy a great blogger, this article so inspiring me to be a better person 스마일주소

    ReplyDelete
  61. I ve been recommended this site by an acquaintance.I hope it helps. 먹튀검증사이트

    ReplyDelete
  62. It s my great luck to find this place. I ll visit today and tomorrow. Thank you. 메이저사이트

    ReplyDelete
  63. The cool things here. I am very satisfied to see. Thank you for your writing. 토토

    ReplyDelete

Item Reviewed: Develop High Transaction Web Applications with Java MySQL & NetBeans Description: Rating: 5 Reviewed By: Unknown