SOA / Web Services / Java

A Technology Blog

Developing web service – Top-Down vs Bottom-Up approach

Posted by Vivek on December 25, 2009

I have worked on or seen a lot of projects using web services and there are many projects that even if use a single web service are touted as a SOA based project. Also, if you look at their approach of developing web service, you will find that they had never gone through a service identification phase and that they could have done without using any webservice. Most of the developers are nowadays handed over an intelligent IDE like jdeveloper or RAD and it becomes very easy for them to write some java code and just right click on the service interface class and choose the option of “generate web service”. And it’s all done. They become web service developers. Do you really think it’s that easy :). Forget about web services, I have come across developers who have worked on one of the many ESBs in the market without having any knowledge of web service or principles of SOA and they call themselves Integration architect or EAI specialist. This post is for those who have used bottom-up approach or code-first approach of developing web service and do not understand the limitation of using it. This post is to highlight the advantages of using contract or WSDL first or top-down approach of developing a web services.

1. Almost all projects are business driven and not IT driven. This means that your business should be aligned with IT and your architecture should be agile enough to adapt to the ever-changing business requirements. Top-Down approach helps you do that. How? Imagine a web service developed using bottom-up approach. The WSDL generated will contain embedded schema often referred to as business object. So each time your business object changes, you will regenerate your WSDL. This also means that you will need to republish your WSDL to service registry and inform all consumers about the change. On the other hand, in a top-down approach you can import/include your business object and if the object changes WSDL will not undergo any change. Also, the business object or XSD can be used by many services and in such case it can be reused.

2. You can develop a service using any programming language like java, .net etc. Each language has its own datatype and when you generate a WSDL you ask the SOAP engine (that contains a binding mechanism) to perform serialization of data types and convert those data types to equivalent data types defined by an XSD. The basic mapping between Java and XSD, for instance, is defined by JAX-RPC specification. So it becomes necessary for a java developer to go through the specification to understand what data type is he/she going to advertise  to the client. Thers is another way that a developer can use if he/she insists to use a particluar java data type. In such cases, he/she needs to configure a bean and tell the binding mechanism (JAXB, xmlbeans etc.) which java class may to which XML schema type.  Each SOAP engine (Axis, CXF etc) comes with a binding mechanism inside and it is not possible to access the binding mechanism directly while generating WSDL. Also, most clients add their flavor to the SOAP engine and do not allow the developer to customize the binding framework.

3.  It is difficult to enforce restrictions in code and then generate WSDL. For instance, If the WSDL/XSD requires that an object can be nillable, then the developer may need to replace the primitive data types with their wrapper classes and regenerate the WSDL. Some developers use array in their code and when they generate WSDL it defines the datatype as arrayOfStrings. This is strictly discouraged by the WS-I basic profile as it causes interoperability issues. Remember, consumer of a web service can generate client in any language and he should have that freedom. You cannot use features that are not compliant with WS-I basic profile. There are various tools in market that allow you to check if your WSDL is WS-I BP conformant and it is very helpful for any developer who uses contract first approach. Obviously, you may not want to keep changing you code until it generates a WSDL that is WS-I BP conformant.

4. If your project is a typical SOA project then you must be using a service registry/repository to provide SOA governance. As everyone knows a registry stores metadata about the service and is a catalog of services, it should contain a lot of intricate details (version, milestones, creat date, expiration date etc) about any service. The service registry inherits a lot of information from your WSDL which means that the WSDL should be descriptive and should not require administrator to enter details manually in registry or should not require client to access registry for details that can be documented in a WSDL. The documentation element of a WSDL is an important place holder for such information but most of the tools do not generate documetation element inside WSDL.    

5. There are lot of web services standards and incorporating these standards means the SOAP header will contain extra information. Hoever, a code first approach nowadays has support of annotations to specify header details in WSDL (when generated), it is always a better idea to use contract first approach to specify the header information. The web service client should know what it is going to receive in the SOAP header.


37 Responses to “Developing web service – Top-Down vs Bottom-Up approach”

  1. Greetings and thanks for a intriguing web site. I am still thinking over what you write.


  2. Robert Pappas said

    The argument that has the most merit is #1. If you generate WSDL from Java objects, you risk breaking the WSDL when those Java objects change. So…the WSDL acts as an extra layer of abstraction to insulate you from Java chanes.

    However, I would argue that extra abstraction layer could just as easily (actualy…much MORE easily) in Java (or .NET). Don’t serialize your business objects directly into XML. Create separate DTO objects that will hold the data you want to transmit. Copy data from the business objects into the DTO objects. Don’t ever change the DTO objects when the business objects change. Now your WSDL is protected from change.

    Arguments #2, #3, #4, and #5 above are more technical issues and “gotchas” that you just have to watch out for and work around. But the work around in all cases is less painful than having to hand-craft WSDL. A big development shop could probably afford to hire a WSDL expert. But smaller shops will just have Java or .NET developers, and these developers don’t wanna mess with WSDL at all. (Trust me on that). There are more developers in smaller shops that bigger shops.


    • Vivek said

      I completely agree with your point Robert. It is easier to adopt the code first approach and smaller projects do not face much problem by doing that. However, these project do not aim for building an SOA as they are not long running and are very limited in scope. Also, to become a SOA ready organization, one has to shift its focus from short term loss to long term benefits and that is something not very feasible for small organizations.

      – Vivek


  3. srikar said

    Hi sir,

    Your information is much more valuable to beginners like me. I am really thankful for writing this kind of expert article. If you don’t mind, could you please advice me the list of java api’s (in order) i should prepare for becoming webservices and soa expert. I am confused with lot of webservice api’s such as jax-rpc or jax-ws or many more. Did jax-rpc is still demanding? Kindly understand that i am a beginner in webservices and soa. please write your reply to


  4. Vinkal Khetarpal said

    Hi Vivek,
    I am very beginner to Web Services.
    1. Can you please tell me the API which are need to be explore before starting to WS in Java?
    2. How to start SOA learning…?
    Please Help me and reply me at :


  5. Thanks for this thoughtful, and concise, overview of the issues. Very useful.


  6. Vivek – Please also send me the info as Vinkal requested regarding Web services/XML/SOA/WSDL. Thanks!


  7. Sara said

    Hi Vivek – Great information and I would love it if you could also send me Could you also send me the info regarding getting started with Web Services/SOA/WSDL that you did for others.
    Thanks so much, Sara


  8. vyas said

    Hi Vivek- i am a trainee java developer working on web services.can you please send me the information on how to get started with web services on my E-mail

    Thank you so much.


  9. sony said

    Hi Vivek –

    I am also very new to Web Services. Please send me the informations/details regarding Web services/XML/SOA/WSDL. Also suggest me some recommended books for the same. Thanks in advance!


  10. Suraj said

    Thank you Vivek for your article. Can you also send me the required information regarding implementing webservices to



  11. Neil said

    Please send the concise notes to prepare for SCDJWS 5/6 to me at



  12. Katz said

    hi Vivel,

    I agree with what you are said. me too feel that generating webservice from WSDL is good. Please send me the same info on webservice to my id


  13. Sanjeev said

    Vivek, Thanks for the very focused and concise article. Can you also send me the required information regarding implementing webservices to:


  14. Chaitanya said

    I am planning to write Java Web Services certification. Could you please send me the concise notes to prepare for SCDJWS exam?

    My email id is

    Thank you



  15. abhipn said

    Thanks for informative notes . Can you please share concise notes to prepare for SCDJWS 5 to


  16. prem said



  17. GVB Subrahmanyam said

    Hi Vivek,
    good article. please send me the notes for web services creation. Appreciate it.
    g v b s v v


  18. Raj said

    Nice article, please send me the notes for web services.
    Thanks in advance


  19. Raj said

    Nice article, can you please forward me the Webservices notes to Thanks in advance.


  20. Nitin said

    Hi Vivek,
    I would appreciate if you can send me top-down approach of creating webservices to my email id
    I am more interested to know wsdl generation manually.



  21. Manoj said

    I am also new to Web Services. Please send me the details on how to start Web services/XML/SOA/WSDL. Also suggest me some good books for web services and SOA.


  22. Shailendra said

    I want to start Web Services and very much interested in Axis/REST/ApacheCXF etc. And I am quite comfortable in xml.
    Could you please let me know how to start web service implementation (in java) ? Or if you can suggest some books based on rpc and ws.

    Thanks a lot


  23. prakasini said

    nice one.I am trying to build the webservice gateway.Please help me with webservice notes.


  24. Vivek, I haveguidence gone through a huge no of articles regarding web services but your article is among best of those few articles from which i grasped knowledge of developing web service.Thanks for your help could you please mail me some good articles related to web service and SOA so that i can visualize the development of web service from scratch as suggested by you the contract first approach.Please send me your precise at


  25. Vikram Sinha said

    Hi Vivek

    I am very new to web services. Can you send me some article on how to get started with web services. I want to follow the top-down approach

    Thanks much


  26. could you please send me the Webservices notes to



  27. Krishna said

    Hi Vivek,

    This is a nice article.. can you please share information related to WS and the concise material you mentioned about with me as well. My email id is


  28. Mashudul Ambia said

    Great Article! Could you please also send me the info you sent to Vinkal and other regarding Web services/XML/SOA/WSDL. Thanks!


  29. Mashudul Ambia said

    Hi Vivek,
    Great Article! Could you please also send me the info you sent to Vinkal and others regarding Web services/XML/SOA/WSDL. Thanks!

    my Email:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: