Tuesday, September 25, 2012

List of Java Question to be prepared before Interview


OOPS and CORE JAVA

What is JVM (Java Virtual Machine)?
What is JIT (Just-in-Time) Compilation?
What is Object Oriented Programming?
Whats a Class?
Whats an Object?
Whats the relation between Classes and Objects?
What are different properties provided by Object-oriented systems?
How do you implement inheritance in Java?
How can we implement polymorphism in Java?
Whats an interface and how will you go about implementing an interface?
What is an Abstract class?
What are Abstract methods?
Whats the difference between Abstract classes and Interfaces?
Whats difference between Static and Non-Static fields of a class?
What are inner classes and whats the practical implementation of inner classes?
What are packages?
What is a constructor in class?
Can constructors be parameterized?
Can you explain transient and volatile modifiers?
What is the use if instanceof  keyword?
What are Native methods in Java?
Explain in depth Garbage collector?
How does the garbage collector determine that the object has to be marked for deletion?
Can you explain finalize() method?
How can we force the garbage collector to run?
Whats the main difference between Switch and If  comparison?
Whats the use of JAVAP tool?
What are applets?
In which package is the applet class located?
What are native interfaces in Java?
what are Class loaders?
what is Bootstrap, Extension and System Class loader?
Can you explain the flow between bootstrap, extension and system class loader?
Can you explain how can you practically do dynamic loading?
How can you copy one array in to a different array?
Can you explain the core collection interfaces?
Can you explain in brief the collection classes which implement the collection interfaces?
Whats the difference between standard JAVA array and ArrayList class?
Whats the use of ensureCapacity in ArrayList class?
How can we obtain an array from an ArrayList class?
What is LinkedList class for?
Can you explain HashSet class in collections?
what is LinkedHashSet class?
what is a TreeSet class?
whats the use of Comparator Interface?
How can we access elements of a collection?
What is Map and SortedMap Interface?
Have you used any collection algorithm?
Why do we use collections when we had traditional ways for collection?
Can you name the legacy classes and interface for collections?
What is Enumeration Interface?
whats the main difference between ArrayList / HashMap and Vector / Hashtable?
Are String object Immutable, Can you explain the concept?
what is a StringBuffer class and how does it differs from String class?
what is the difference between StringBuilder and StringBuffer class?
What is Pass by Value and Pass by reference? How does JAVA handle the same?
What are access modifiers?
what is Assertion?
Can you explain the fundamentals of deep and shallow Cloning?
How do we implement Shallow cloning?
How do we implement deep cloning?
Whats the impact of private constructor?
What are the situations you will need a constructor to be private?
Can you explain final modifier?
What are static Initializers?
If we have multiple static initializer blocks how is the sequence handled?
Define casting? What are the different types of Casting?
Can you explain Widening conversion and Narrowing conversion?
Can we assign parent object to child objects?
Define exceptions?
Can you explain in short how JAVA exception handling works?
Can you explain different exception types?
Can you explain checked and unchecked exceptions?
Can we create our own exception class?
What are chained exceptions?
What is serialization?
How do we implement serialization actually?
Whats the use of Externalizable Interface?

Threading

Whats difference between thread and process?
What is thread safety and synchronization?
What is semaphore?
What are monitors?
Whats the importance of synchronized blocks?
How do we create threads?
whats the difference in using runnable and extends in threads?
Can you explain Thread.sleep?
How to stop a thread?
What is wait() and notify() ?
Can you explain how Scheduling and Priority works in threads?
Can you explain Yielding in threading?
what are daemon threads?


JDBC

How does JAVA interact with databases?
Can we interact with non-relational sources using JDBC?
Can you explain in depth the different sections in JDBC?
Can you explain in short how you go about using JDBC API in code?
How do you handle SQL exceptions?
If there is more than one exception in SQLException class how to go about displaying
it?
Explain Type1, Type2, Type3 and Type4 drivers in JDBC?
What are the advantages and disadvantages of using JDBC-ODBC bridge driver?
What are the advantages and disadvantages of using Native-API/ Partially Java Driver?
What are the advantages and disadvantages of using Net-Protocol/ All-Java driver?
What are the advantages and disadvantages of using Native-protocol/ All-Java driver?
Define meta-data?
What is DatabaseMetaData?
Can you explain ConnectionFactory class?
I want to display tables of a database how do I do it?
Define ResultSetMetaData?
What is the difference between ResultSet and RowSet?
Can ResultSet objects be serialized?
Can you explain ResultSet, RowSet, CachedRowset, JdbcRowset and
WebRowSet relation ship?
what are the different types of resultset?
Explain the concept of PreparedStatement statement interface?
Whats the difference between Statement and PreparedStatement?
How can we call stored procedure using JDBC?
Can you explain CallableStatement interface in detail?
How do you get a resultset object from stored procedure?
How can we do batch updates using CallableStatement Interface?
Define transactions?
what is ACID in transaction?
what are the four essential properties of a transaction?
Explain concurrency and locking?
What are different types of locks?
What are the different types of levels of resource on which locks can be placed?
Define lock escalation?
What is Table level and Row level locking?
What are the problems that can occur if you do not implement locking properly?
What are different transaction levels?
Twist: - what are different types of locks?
What is difference between optimistic and pessimistic locking?
What are deadlocks?
How can we set transaction level through JDBC API?
Can you explain transaction control in JDBC?
What are Savepoints in a transaction?
Servlets and JSP
What are Servlets?
What are advantages of servlets over CGI?
Can you explain Servlet life cycle?
What are the two important APIs in for Servlets?
Can you explain in detail javax.servlet package?
Whats the use of ServletContext?
How do we define an application level scope for servlet?
What's the difference between GenericServlet and HttpServlet?
Can you explain in detail javax.servlet.http package?
Whats the architecture of a Servlet package?
Why is HTTP protocol called as a stateless protocol?
What are the different ways we can maintain state between requests?
What is URL rewriting?
What are cookies?
What are sessions in Servlets?
Whats the difference between getSession(true) and getSession(false) ?
Whats the difference between doPost and doGet methods?
Which are the different ways you can communicate between servlets?
What is functionality of RequestDispatcher object?
How do we share data using getServletContext ()?
Explain the concept of SSI?
What are filters in JAVA?
Can you explain in short how do you go about implementing filters using Apache Tomcat?
Twist: - Explain step by step of how to implement filters?
whats the difference between Authentication and authorization?
Explain in brief the directory structure of a web application?
Can you explain JSP page life cycle?
What is EL?
how does EL search for an attribute?
What are the implicit EL objects in JSP?
How can we disable EL?
what is JSTL?
Can you explain in short what the different types of JSTL tags are?
How can we use beans in JSP?
What is tag for ?
What are JSP directives?
what are Page directives?
what are include directives?
Can you explain taglib directives?
How does JSP engines instantiate tag handler classes instances?
whats the difference between JavaBeans and taglib directives?
what are the different scopes an object can have in a JSP page?
what are different implicit objects of JSP?
what are different Authentication Options available in servlets?
Can you explain how do we practically implement security on a resource?
How do we practically implement form based authentication?
How do we authenticate using JDBC?
Can you explain JDBCRealm?
Can you explain how do you configure JNDIRealm?
How did you implement caching in JSP?


EJB

What is EJB?
what are the different kind of EJBs?
you are designing architecture for a project how do you decide whether you should use
session, entity or message driven bean?
Can you explain EJBHome and EJBObject in EJB?
Can client directly create object of session or entity beans?
Can you explain the concept of local interfaces?
What are the limitations of using Local object?
Which application server have you used for EJB ?
Can you explain step by step practically developing and deploying EJB component?
what is Passivation and Activation in EJB?
Can beans who are involved in transaction have Passivation process?
How does the server decide which beans to passivate and activate?
In what format is the conversational data written to the disk?
Can you explain in brief Life cycle for Stateless and Stateful beans?


Struts

Whats MVC pattern?
Define struts?
Can you explain the directory structure for a struts folder in brief ?
Can you give an overview of how a struts application flows?
Twist: - What are action and action form classes in Struts?

XML and Web Services

What is XML?
What is the version information in XML?
What is ROOT element in XML?
If XML does not have closing tag will it work?
Is XML case sensitive?
What is the difference between XML and HTML?
Is XML meant to replace HTML?
Can you explain why your project needed XML?
What is DTD (Document Type definition)?
What is well formed XML?
What is a valid XML?
What is CDATA section in XML?
What is CSS?
What is XSL?
What is element and attributes in XML?
What are the standard ways of parsing XML document?
In What scenarios will you use a DOM parser and SAX parser?
What is XSLT?
Define XPATH?
What is the concept of XPOINTER?
What is a Web Service ?
What is DISCO ?
What is SOAP ?
What is WSDL ?
Can you explain UDDI ?
Can you explain JAXP ?
What is a XML registry?
What is JAXR?
What is JAXM?
Can you explain how JAXM messaging model works?
Can you explain JAX-RPC?
Internationalization
Can you explain i18n and l10n?
Can you explain internationalization and localization?
What is Locale?
How do we display numbers, currency and Dates according to proper Locale format?
what are resource bundles?
How do we load a resource bundle file?
How can we do inheritance in resource bundles?


JNI

What is Native Interface in JAVA?
Can you say in brief steps required to implement Native interfaces in Java?
Can JNI be used for VB6, C# or VB.NET directly?
What are JNI functions and pointers?
How does the garbage collector know JNI objects are no more used?
Twist: - What are the different types of references JNI supports?
Twist: - How to do you delete global objects?
how does the native language C or C++ understand data types in JAVA?
Can you explain exception handling in JNI?
What are limitations for JNIEnv pointer in multi-threading scenarios?
What are the advantages and disadvantages of using JNI?
Architecture
What are design patterns ?
What is the difference between Factory and Abstract Factory Patterns?
What is MVC pattern?
Twist: - How can you implement MVC pattern in Servlets and JSP?
How can we implement singleton pattern in JAVA?
How do you implement prototype pattern in JAVA?
Twist: - How to implement cloning in JAVA? What is shallow copy and deep copy ?
Can you give a practical implementation of FAƇADE patterns?
How can we implement observer pattern in JAVA?
What is three tier architecture?
What is Service Oriented architecture?
What is aspect oriented programming?


Project Management

What is project management?
Is spending in IT projects constant through out the project?
Who is a stakeholder ?
Can you explain project life cycle ?
Twist :- How many phases are there in software project ?
Are risk constant through out the project ?
Can you explain different software development life cycles ?
What is triple constraint triangle in project management ?
What is a project baselines ?
What is effort variance?
How is normally a project management plan document organized ?
How do you estimate a project?
What is CAR (Causal Analysis and Resolution)?
What is DAR (Decision Analysis and Resolution) ?
What is a fish bone diagram ?
Twist:- What is Ishikawa diagram ?
What is pareto principle ?
Twist :- What is 80/20 principle ?
How do you handle change request?
What is internal change request?
What is difference between SITP and UTP in testing ?
What is the software you have used for project management?
What are the metrics followed in project management?
Twist: - What metrics will you look at in order to see the project is moving successfully?
You have people in your team who do not meet there deadlines or do not perform what
are the actions you will take ?
Twist :- Two of your resources have conflicts between them how would you sort it out ?
What is black box testing and White box testing?
Whats the difference between Unit testing, Assembly testing and Regression testing?
What is V model in testing?
How do you start a project?
How did you do resource allocations?
How will you do code reviews ?
What is CMMI?
What are the five levels in CMMI?
What is continuous and staged representation?
Can you explain the process areas?
What is SIX sigma?
What is DMAIC and DMADV ?
What are the various roles in Six Sigma implementation?
What are function points?
Twist: - Define Elementary process in FPA?
What are the different types of elementary process in FPA?
What are the different elements in Functions points?
Can you explain in GSC and VAF in function points?
What are unadjusted function points and how is it calculated?
Can you explain steps in function points?
What is the FP per day in your current company?
Twist :- What is your companys productivity factor ?
Do you know Use Case points?
What is COCOMO I, COCOMOII and COCOMOIII?
What is SMC approach of estimation?
How do you estimate maintenance project and change requests?


UML

What is UML?
How many types of diagrams are there in UML ?
Twist :- Explain in short all types of diagrams in UML ?
What are advantages of using UML?
Twist: - What is Modeling and why UML ?
What is the sequence of UML diagrams in project?
Twist: - How did you implement UML in your project?
Just a small Twist: - Do I need all UML diagrams in a project?
Give a small brief explanation of all Elements in activity diagrams?
Explain Different elements of a collaboration diagram ?
Explain Component diagrams ?
Explain all parts of a deployment diagram?
Describe the various components in sequence diagrams?
What are the element in State Chart diagrams ?
Describe different elements in Static Chart diagrams ?
Explain the different elements of a Use Case ?
Twist: - What is the difference between Activity and sequence diagrams?(I leave this to
the readers)

Java Web Services Questions

1. What are the features of web services?
A. Web services(WS)
· Web services can convert your applications into web applications
· Web services can be used by other applications
· Web services are published, found and used through the web
· Web services platform is XML + Http
· WS are application components
· WS communicate using open protocols
· WS are self contained and self describing
· WS can be discovered using UDDI (Universal Discovery, Description and Integration)
· XML is the basis for web services
2. How does the web services work?
A. The basic platform for web services is XML and HTTP. The HTTP protocol is the most widely used internet protocol. XML can be used between different platforms and programming languages. XML expresses the complex messages and functions. Following are the basic components of web services platform.
· SOAP(Simple Object Access Protocol)
· UDDI (Universal Description, Discovery and Integration)
· WSDL (Web Services Description Language)
3. Why web services?
· Interoperability is the most important factor
· Reusability of application components
· WS makes your application to publish its function or message to the rest of the world
· using the WS applications can exchange data between different applications and different platforms
· WS used XML to code and decode the data (which is understandable by all applications written in any language)
· WS uses SOAP to transport the data using open protocols
4. What are the three basic elements of web services platform?
· SOAP(Simple Object Access Protocol)
· UDDI (Universal Description, Discovery and Integration)
· WSDL (Web Services Description Language)
5. What is SOAP?
A. SOAP is a XML based protocol that is used by applications to exchange information over HTTP. Or simply we can define it as a protocol for accessing a web service.
The basic Web services platform is XML plus HTTP.
· SOAP is a communication protocol used for communication between applications
· SOAP is a format for sending messages
· SOAP is based on XML (eXtensible Markup Language)
· SOAP is designed to communicate via Internet
· SOAP is platform and language independent
· SOAP is based on XML
· SOAP is simple and extensible
· SOAP allows you to get around firewalls
· SOAP will be developed as a W3C standard
6. What is WSDL?
A. WSDL is an XML based language for describing web services. It also tell you how to access the services that it is providing.
· WSDL is an XML document
· WSDL is used to describe web services, along with the message format and protocol details for the web service
· WSDL is also used to locate Web Services
· WSDL is not yet a W3C standard
7. What is UDDI?
A. UDDI stands for Universal Description, Discovery and Integration. It is a Directory Service where businesses can register and search for web services.
· UDDI is a directory for storing information about web services
· UDDI is a directory of web service interfaces described by WSDL
· UDDI communicates via SOAP
8. What exactly WSDL document contains?
A. It is a document written in XML and used to describe web services. It specifies the location of the service and the operations (or methods) the service exposes.
9. Describe the major elements of a WSDL document?
A. There are four major elements in a WSDL document.
1. - defines the operations performed by the web service
2. - The message used by the web service
3. - defines the data types used by the application
4. - The communication protocols used by the web service
The above four components are generally used in a WSDL document. In addition to above components there are few more elements that can be used in WSDL, like extension elements and a service element that makes it possible to group together the definitions of several web services in one single WSDL document.
10. Explain WSDL ports?
1. is a most important element in the WSDL document.
2. The port defines the connection point to the web service
3. it describes a service, the operations that can be performed and the messages that are involved
4. it can be compared to a function library or a module or a class in general programming languages
11. Explain WSDL message?
1. defines the data elements of an operation
2. each message can consists of one or more parts
3. defines the data types of its parts
4. these parts can be compared to the parameters of a function in general programming languages
12. Explain WSDL types?
1. element defines the data types used by the web service
2. WSDL uses XML Schema syntax to define the data types (for maximum platform neutrality)
13. Explain WSDL binding?
A. WSDL binding element defines 1) message format and 2) protocol details for each port
14. What are different operation types in WSDL?
A. WSDL generally uses request-response type operation. But WSDL has actually four operation types.
1. One-way -> The operation can receive a message but it will not return a message.
2. request-response -> The operation can receive a request and will return a response
3. solicit-response -> The operation can send a request and waill wait for a response
4. Notification -> The operation can send a message but will not wait for a response
15. Explain breifly about WSDL binding to SOAP?
A. The element has two attributes.
1. name attribute - defines the name of the binding
2. type attribute - poitnts to the port for the binding
element has two attributes.
1. style attribute - It can be an "rpc" or a document
2. transport attribute - defines the SOAP protocol to use. HTTP(S) and SMTP are the valid application layer protocols used as Transport for SOAP.
Operation element defines the operation that the port exposes. For each operation, we need to specify the corresponding saopAction. You also need to specify how the input and output are encoded. The different types are literal, encoding types.
16. What is UDDI based on?
A. UDDI is based on XML, SOAP and DNS.
17. What are the Benefits of UDDI?
A.
· Making it possible to discover the right business from the millions currently online
· Defining how to enable commerce once the preferred business is discovered
· Reaching new customers and increasing access to current customers
· Expanding offerings and extending market reach
· Solving customer-driven need to remove barriers to allow for rapid participation in the global Internet economy
· Describing services and business processes programmatically in a single, open, and secure environment
18.  What are the two approaches to create a webservice?
Top Down: From WSDL one generates the Java Classes
Bottom Up: From Java classes one generates the WSDL
19.  Few tools used in your project if you used webservices.
 SOAP UI: Test the web service
 Some times some of the back end services might not available , so you can create a mock response and run the webservice service from the soap ui. Then your program should hit the mock response and you can check the functionality.
 Stylus Studio: Create the XML Schema and generate the binding classes.
 Axis2: Create the web service
20. Explain the use of Castor?
Castor is used to create the binding classes from the schema XML over HTTP

Reference for to learn Web Services:
http://www.j2eebrain.com/java-J2ee-developing-web-services-part-1.html
http://www.j2eebrain.com/java-J2ee-developing-web-services-part-2.html
http://www.j2eebrain.com/java-J2ee-developing-web-services-part-3.html

SOAP Interview Questions and Answer



1)   Explain about SOAP?
SOAP acts as a medium to provide basic messaging framework. On these basic messaging frameworks abstract layers are built. It transfers messages across the board in different protocols; it also acts as a medium to transmit XML based messages over the network.

2)   Give an example about the functioning of SOAP?
Consider a real estate database with huge data ranges. If a user wants to search about a particular term, the message with all the required features such as price, availability, place, etc will be returned to the user in an XML formatted document which the user can integrate into third party site for additional performance.

3)   Explain about Remote call procedure?
Remote call procedure is considered as a very important function in SOAP. In RCP a user (node) sends a request to another node (server) where the information is processes and sent to the user. It immediately sends message across the network.

4)   Explain about Transport methods in SOAP?
Internet application layer is used to transfer messages from one end to another end. Various products have been transported successfully from one end to another end using SOAP. Both SMTP and HTTP are two successful transport protocols used in transmitting information, but HTTP has gained good ground than HTTP.

5)   Explain about HTTPS in SOAP?
HTTPS is similar to HTTP but it has an additional layer underneath the internet application layer which makes the data encrypted. This protocol is widely used than IOP or DCOM because those protocols are filtered by firewalls. HTTPS protocol advocates WS-I method to provide security for transmission of secured data.

6)   Explain about the role of XML in SOAP?
XML is chosen as a standard format because it was already in use by many large companies and immensely due to its open source nature. A wide variety of tools are available on shelves which ease the process of transition to SOAP. XML can significantly reduce the speed and efficiency but binary XML is being considered as a format for future.

7)   What are the advantages which a user can get when he uses SOAP?
•   SOAP by passes all firewalls thus making the process easier.
•   It has huge collection of protocols
•   It is platform and language independent
•   Simplicity and extensible nature makes it the most wanted.

8)   State some disadvantages due to the usage of SOAP?
1)   SOAP is much slower than middleware technologies
2)   Due to the usage of HTTP for transporting messages and not the defined ESB or WS-Addressing interaction of parties over a message is fixed.
3)   Information regarding the usability of HTTP for different purposes is not present which makes the application protocol level problematic.

9)   Explain about message passing in RPC?
RPC is very friendly in implementing the client to server interaction model which makes it very prominent. When the server is interacting and searching for information the client side messaging is blocked and server activity goes on. RPC has huge pool of protocols which at times make it difficult to work with. Client server interaction can be best achieved by RPC.

10)    Explain the difference between RPC and Local calls?
An important difference between Remote call procedure and local call is that remote call can fail often and this occurs without the knowledge of the user. Local calls are easily handled. Another main difficulty lies with the code writing capability because it is written in a low level language.

11)    What are the elements which should be contained in SOAP message?
Following elements are contained in the SOAP message.
1)   An envelope element which identifies and translates the XML document into a SOAP message.
2)   A header element is a must as it should contain header message.
3)   A body is required which should contain call and response message.
4)   Fault element is required which can communicate about the errors occurred during the process

12)    Explain about the syntax rules in SOAP?
Some of the important syntax rules are as follows:
1)   SOAP should be coded in XML
2)   SOAP envelope should be used for SOAP message
3)   A SOAP encoding namespace must be used by SOAP.
4)   A DTD reference and a XML processing instruction should not be contained.

13)    Explain about the encoding style attribute?
This is used to define the data types in the document. Any SOAP element may use this format and it gets implemented on the child and contents of the SOAP. SOAP element will never have a default encoding.

14)    Explain about the SOAP Envelope element?
A SOAP message will have the SOAP element as the root element. SOAP element name space should always have the value of : as that defines the Envelope.

15)    Explain about the actor element?
A SOAP message has to travel a very long distance between its client and server but during the process a part of the message may be intended to be deployed to another destination which is made possible by the SOAP elements actor attribute which address the header element to a particular location.

16)    Explain about the mustUnderstand Attribute?
This attribute indicates whether the header is optional or mandatory for the recipient to process. If you add mustUnderstand =”1” to the child element of the header element then it states that the header element must be processed otherwise it leads to failure.

17)    Explain about the SOAP body element?
This part of the element will contain the message which is intended for the ultimate delivery point. An element can be described inside the body element as a default namespace which indicates about the error message during the process. SOAP element acts just like a code to be processed during the execution of a certain application.

J2EE QUESTION AND ANSWERS



  1. What makes J2EE suitable for distributed multitiered Applications?
    - The J2EE platform uses a multitiered distributed application model. Application logic is divided into components according to function, and the various application components that make up a J2EE application are installed on different machines depending on the tier in the multitiered J2EE environment to which the application component belongs. The J2EE application parts are:
    • Client-tier components run on the client machine.
    • Web-tier components run on the J2EE server.
    • Business-tier components run on the J2EE server.
    • Enterprise information system (EIS)-tier software runs on the EIS server.
  2. What is J2EE? - J2EE is an environment for developing and deploying enterprise applications. The J2EE platform consists of a set of services, application programming interfaces (APIs), and protocols that provide the functionality for developing multitiered, web-based applications.
  3. What are the components of J2EE application?
    - A J2EE component is a self-contained functional software unit that is assembled into a J2EE application with its related classes and files and communicates with other components. The J2EE specification defines the following J2EE components:
1.      Application clients and applets are client components.
2.      Java Servlet and JavaServer Pages technology components are web components.
3.      Enterprise JavaBeans components (enterprise beans) are business components.
4.      Resource adapter components provided by EIS and tool vendors.
  1. What do Enterprise JavaBeans components contain? - Enterprise JavaBeans components contains Business code, which is logic
    that solves or meets the needs of a particular business domain such as banking, retail, or finance, is handled by enterprise beans running in the business tier. All the business code is contained inside an Enterprise Bean which receives data from client programs, processes it (if necessary), and sends it to the enterprise information system tier for storage. An enterprise bean also retrieves data from storage, processes it (if necessary), and sends it back to the client program.
  2. Is J2EE application only a web-based? - No, It depends on type of application that client wants. A J2EE application can be web-based or non-web-based. if an application client executes on the client machine, it is a non-web-based J2EE application. The J2EE application can provide a way for users to handle tasks such as J2EE system or application administration. It typically has a graphical user interface created from Swing or AWT APIs, or a command-line interface. When user request, it can open an HTTP connection to establish communication with a servlet running in the web tier.
  3. Are JavaBeans J2EE components? - No. JavaBeans components are not considered J2EE components by the J2EE specification. They are written to manage the data flow between an application client or applet and components running on the J2EE server or between server components and a database. JavaBeans components written for the J2EE platform have instance variables and get and set methods for accessing the data in the instance variables. JavaBeans components used in this way are typically simple in design and implementation, but should conform to the naming and design conventions outlined in the JavaBeans component architecture.
  4. Is HTML page a web component? - No. Static HTML pages and applets are bundled with web components during application assembly, but are not considered web components by the J2EE specification. Even the server-side utility classes are not considered web components, either.
  5. What can be considered as a web component? - J2EE Web components can be either servlets or JSP pages. Servlets are Java programming language classes that dynamically process requests and construct responses. JSP pages are text-based documents that execute as servlets but allow a more natural approach to creating static content.
  6. What is the container? - Containers are the interface between a component and the low-level platform specific functionality that supports the component. Before a Web, enterprise bean, or application client component can be executed, it must be assembled into a J2EE application and deployed into its container.
  7. What are container services? - A container is a runtime support of a system-level entity. Containers provide components with services such as lifecycle management, security, deployment, and threading.
  8. What is the web container? - Servlet and JSP containers are collectively referred to as Web containers. It manages the execution of JSP page and servlet components for J2EE applications. Web components and their container run on the J2EE server.
  9. What is Enterprise JavaBeans (EJB) container? - It manages the execution of enterprise beans for J2EE applications.
    Enterprise beans and their container run on the J2EE server.
  10. What is Applet container? - IManages the execution of applets. Consists of a Web browser and Java Plugin running on the client together.
  11. How do we package J2EE components? - J2EE components are packaged separately and bundled into a J2EE application for deployment. Each component, its related files such as GIF and HTML files or server-side utility classes, and a deployment descriptor are assembled into a module and added to the J2EE application. A J2EE application is composed of one or more enterprise bean,Web, or application client component modules. The final enterprise solution can use one J2EE application or be made up of two or more J2EE applications, depending on design requirements. A J2EE application and each of its modules has its own deployment descriptor. A deployment descriptor is an XML document with an .xml extension that describes a component’s deployment settings.
  12. What is a thin client? - A thin client is a lightweight interface to the application that does not have such operations like query databases, execute complex business rules, or connect to legacy applications.
  13. What are types of J2EE clients? - Following are the types of J2EE clients:
    • Applets
    • Application clients
    • Java Web Start-enabled rich clients, powered by Java Web Start technology.
    • Wireless clients, based on Mobile Information Device Profile (MIDP) technology.
  1. What is deployment descriptor? - A deployment descriptor is an Extensible Markup Language (XML) text-based file with an .xml extension that describes a component’s deployment settings. A J2EE application and each of its modules has its own deployment descriptor. For example, an enterprise bean module deployment descriptor declares transaction attributes and security authorizations
    for an enterprise bean. Because deployment descriptor information is declarative, it can be changed without modifying the bean source code. At run time, the J2EE server reads the deployment descriptor and acts upon the component accordingly.
  2. What is the EAR file? - An EAR file is a standard JAR file with an .ear extension, named from Enterprise ARchive file. A J2EE application with all of its modules is delivered in EAR file.
  3. What is JTA and JTS? - JTA is the abbreviation for the Java Transaction API. JTS is the abbreviation for the Jave Transaction Service. JTA provides a standard interface and allows you to demarcate transactions in a manner that is independent of the transaction manager implementation. The J2EE SDK implements the transaction manager with JTS. But your code doesn’t call the JTS methods directly. Instead, it invokes the JTA methods, which then call the lower-level JTS routines. Therefore, JTA is a high level transaction interface that your application uses to control transaction. and JTS is a low level transaction interface and ejb uses behind the scenes (client code doesn’t directly interact with JTS. It is based on object transaction service(OTS) which is part of CORBA.
  4. What is JAXP? - JAXP stands for Java API for XML. XML is a language for representing and describing text-based data which can be read and handled by any program or tool that uses XML APIs. It provides standard services to determine the type of an arbitrary piece of data, encapsulate access to it, discover the operations available on it, and create the appropriate JavaBeans component to perform those operations.
  5. What is J2EE Connector? - The J2EE Connector API is used by J2EE tools vendors and system integrators to create resource adapters that support access to enterprise information systems that can be plugged into any J2EE product. Each type of database or EIS has a different resource adapter. Note: A resource adapter is a software component that allows J2EE application components to access and interact with the underlying resource manager. Because a resource adapter is specific to its resource manager, there is typically a different resource adapter for each type of database or enterprise information system.
  6. What is JAAP? - The Java Authentication and Authorization Service (JAAS) provides a way for a J2EE application to authenticate and authorize a specific user or group of users to run it. It is a standard Pluggable Authentication Module (PAM) framework that extends the Java 2 platform security architecture to support user-based authorization.
  7. What is Java Naming and Directory Service? - The JNDI provides naming and directory functionality. It provides applications with methods for performing standard directory operations, such as associating attributes with objects and searching for objects using their attributes. Using JNDI, a J2EE application can store and retrieve any type of named Java object. Because JNDI is independent of any specific implementations, applications can use JNDI to access multiple naming and directory services, including existing naming and
    directory services such as LDAP, NDS, DNS, and NIS.
  8. What is Struts? - A Web page development framework. Struts combines Java Servlets, Java Server Pages, custom tags, and message resources into a unified framework. It is a cooperative, synergistic platform, suitable for development teams, independent developers, and everyone between.
  9. How is the MVC design pattern used in Struts framework? - In the MVC design pattern, application flow is mediated by a central Controller. The Controller delegates requests to an appropriate handler. The handlers are tied to a Model, and each handler acts as an adapter between the request and the Model. The Model represents, or encapsulates, an application’s business logic or state. Control is usually then forwarded back through the Controller to the appropriate View. The forwarding can be determined by consulting a set of mappings, usually loaded from a database or configuration file. This provides a loose coupling between the View and Model, which can make an application significantly easier to create and maintain. Controller: Servlet controller which supplied by Struts itself; View: what you can see on the screen, a JSP page and presentation components; Model: System state and a business logic JavaBeans.

REST Web services Framework questions answers



1) What is REST and RESTful web services ?
this is the first REST interview question on most of interviews as not everybody familiar with REST and also
start discussion based on candidates response. Anyway REST stands for REpresentational State Transfer (REST) its a relatively new concept of writing web services which enforces a stateless client server design where web services are treated as resource and can be accessed and identified by there URL unlike SOAP web services which were defined by WSDL.

Web services written by apply REST Architectural concept are called RESTful web services which focus on System resources and how state of Resource should be transferred over http protocol to a different clients written in different languages. In RESTful web services http methods like GET, PUT, POST and DELETE can can be used to perform CRUD operations.

2) What is differences between RESTful web services and SOAP web services ?
Though both RESTful web series and SOAP web service can operate cross platform they are architecturally different to each other, here is some of differences between REST and SOAP:

1) REST is more simple and easy to use than SOAP
2) REST uses HTTP protocol for producing or consuming web services while SOAP uses XML.
3) REST is lightweight as compared to SOAP and preferred choice in mobile devices and PDA's.
4) REST supports different format like text, JSON and XML while SOAP only support XML.
5) REST web services call can be cached to improve performance.

3) What is Restlet framework ?
Restlet is leading RESTful web framework for Java applications is used to build RESTFul web services it has two part Restlet API and a Restlet implementation much like Servlet specification. There are many implementation of Restet framework available you just need to add there jar in your classpath to use them. By using Restlet web framework you can write client and server.

4) What is Resource in REST framework ?
it represent a "resource" in REST architecture. on RESTLET API it has life cycle methods like init(), handle() and release() and contains a Context, Request and Response corresponding to specific target resource. This is now deprecated over ServerResource class and you should use that. see Restlet documentation for more details.

5) Can you use Restlet without any web-container ?
Yes, Restlet framework provide default server which can be used to handle service request in web container is not available.

6) What is difference between Restlets and Jersey ?
This REST web service interview questions is open for you all, post you answer in comment section.

7) What is RESTEasy ?
RESTEasy is another REST framework introduced in JBoss Application Server. This was rather easy REST interview questions. you can answer in detail only if you have used this or working in JBoss.

8) What are the tools used for creating RESTFull web services ?
You can use AJAX(Asynchronous JavaScript with XAML) and Direct Web Removing to consume web serives in web application. Both Eclipse and NetBeans also supported development of RESTFul services.

9) How to display custom error pages using RestFull web services ?
In order to customize error you need to extend StatusService and implement getRepresentation(Status, Request, Response) method with your custom code now assign instance of your CustomStatusService to appropriate "statusService property".

10) Which HTTP methods are supported by RestFull web services ?
Another common REST interview questioning RESTFul web service each Resource supports GET, POST, PUT and DELETE http methods.GET is mapped to represent(), POST - acceptRepresentation(), PUT- storeRepresentation and DELET for rmeoveRepresentation.

11) What is difference between top-down and bottom-up approach of developing web services ?
In top-down approach first WSDL document is created and than Java classes are developed based on WSDL contract, so if WSDL contract changes you got to change your Java classes while in case of bottom up approach of web service development you first create Java code and then use annotations like @WebService to specify contract or interface and WSDL field will be automatically generated from your build.

12) What happens if RestFull resources are accessed by multiple clients ? do you need to make it thread-safe?
Since a new Resource instance is created for every incoming Request there is no need to make it thread-safe or add synchronization. multiple client can safely access RestFull resources concurrently.


Web Service Questions and Answers

What is a Web service?
Many people and companies have debated the exact definition of Web services. At a minimum, however, a Web service is any piece of software that makes itself available over the Internet and uses a standardized XML messaging system.
XML is used to encode all communications to a Web service. For example, a client invokes a Web service by sending an XML message, and then waits for a corresponding XML response. Because all communication is in XML, Web services are not tied to any one operating system or programming language--Java can talk with Perl; Windows applications can talk with UNIX applications.
Beyond this basic definition, a Web service may also have two additional (and desirable) properties:
First, a Web service can have a public interface, defined in a common XML grammar. The interface describes all the methods available to clients and specifies the signature for each method. Currently, interface definition is accomplished via the Web Service Description Language (WSDL). (See FAQ number 7.)
Second, if you create a Web service, there should be some relatively simple mechanism for you to publish this fact. Likewise, there should be some simple mechanism for interested parties to locate the service and locate its public interface. The most prominent directory of Web services is currently available via UDDI, or Universal Description, Discovery, and Integration. (See FAQ number 8.)
Web services currently run a wide gamut from news syndication and stock-market data to weather reports and package-tracking systems. For a quick look at the range of Web services currently available, check out the XMethods directory of Web services.
What is new about Web services?
People have been using Remote Procedure Calls (RPC) for some time now, and they long ago discovered how to send such calls over HTTP.
So, what is really new about Web services? The answer is XML.
XML lies at the core of Web services, and provides a common language for describing Remote Procedure Calls, Web services, and Web service directories.
Prior to XML, one could share data among different applications, but XML makes this so much easier to do. In the same vein, one can share services and code without Web services, but XML makes it easier to do these as well.
By standardizing on XML, different applications can more easily talk to one another, and this makes software a whole lot more interesting.
I keep reading about Web services, but I have never actually seen one. Can you show me a real Web service in action?
If you want a more intuitive feel for Web services, try out the IBM Web Services Browser, available on the IBM Alphaworks site. The browser provides a series of Web services demonstrations. Behind the scenes, it ties together SOAP, WSDL, and UDDI to provide a simple plug-and-play interface for finding and invoking Web services. For example, you can find a stock-quote service, a traffic-report service, and a weather service. Each service is independent, and you can stack services like building blocks. You can, therefore, create a single page that displays multiple services--where the end result looks like a stripped-down version of my.yahoo or my.excite.
What is the Web service protocol stack?
The Web service protocol stack is an evolving set of protocols used to define, discover, and implement Web services. The core protocol stack consists of four layers:
Service Transport: This layer is responsible for transporting messages between applications. Currently, this includes HTTP, SMTP, FTP, and newer protocols, such as Blocks Extensible Exchange Protocol (BEEP).
XML Messaging: This layer is responsible for encoding messages in a common XML format so that messages can be understood at either end. Currently, this includes XML-RPC and SOAP.
Service Description: This layer is responsible for describing the public interface to a specific Web service. Currently, service description is handled via the WSDL.
Service Discovery: This layer is responsible for centralizing services into a common registry, and providing easy publish/find functionality. Currently, service discovery is handled via the UDDI.
Beyond the essentials of XML-RPC, SOAP, WSDL, and UDDI, the Web service protocol stack includes a whole zoo of newer, evolving protocols. These include WSFL (Web Services Flow Language), SOAP-DSIG (SOAP Security Extensions: Digital Signature), and USML (UDDI Search Markup Language). For an overview of these protocols, check out Pavel Kulchenko's article, Web Services Acronyms, Demystified, on XML.com.
Fortunately, you do not need to understand the full protocol stack to get started with Web services. Assuming you already know the basics of HTTP, it is best to start at the XML Messaging layer and work your way up.
What is XML-RPC?
XML-RPC is a protocol that uses XML messages to perform Remote Procedure Calls. Requests are encoded in XML and sent via HTTP POST; XML responses are embedded in the body of the HTTP response.
More succinctly, XML-RPC = HTTP + XML + Remote Procedure Calls.
Because XML-RPC is platform independent, diverse applications can communicate with one another. For example, a Java client can speak XML-RPC to a Perl server.
To get a quick sense of XML-RPC, here is a sample XML-RPC request to a weather service (with the HTTP Headers omitted):
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodCall>
<methodName>weather.getWeather</methodName>
<params>
<param><value>10016</value></param>
</params>
</methodCall>
The request consists of a simple element, which specifies the method name (getWeather) and any method parameters (zip code).

Here is a sample XML-RPC response from the weather service:

<?xml version="1.0" encoding="ISO-8859-1"?>
<methodResponse>
<params>
<param>
<value><int>65</int></value>
</param>
</params>
</methodResponse>
The response consists of a single element, which specifies the return value (the current temperature). In this case, the return value is specified as an integer.
In many ways, XML-RPC is much simpler than SOAP, and therefore represents the easiest way to get started with Web services.
The official XML-RPC specification is available at XML-RPC.com. Dozens of XML-RPC implementations are available in Perl, Python, Java, and Ruby. See the XML-RPC home page for a complete list of implementations.
What is SOAP?
SOAP is an XML-based protocol for exchanging information between computers. Although SOAP can be used in a variety of messaging systems and can be delivered via a variety of transport protocols, the main focus of SOAP is Remote Procedure Calls (RPC) transported via HTTP. Like XML-RPC, SOAP is platform independent, and therefore enables diverse applications to communicate with one another.

To get a quick sense of SOAP, here is a sample SOAP request to a weather service (with the HTTP Headers omitted):

<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://www.w3.org/2001/09/soap-envelope"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:getWeather
xmlns:ns1="urn:examples:weatherservice"
SOAP-ENV:encodingStyle=" http://www.w3.org/2001/09/soap-encoding
<zipcode xsi:type="xsd:string">10016</zipcode>
</ns1:getWeather>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
As you can see, the request is slightly more complicated than XML-RPC and makes use of both XML namespaces and XML Schemas. Much like XML-RPC, however, the body of the request specifies both a method name (getWeather), and a list of parameters (zipcode).

Here is a sample SOAP response from the weather service:

<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://www.w3.org/2001/09/soap-envelope"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:getWeatherResponse
xmlns:ns1="urn:examples:weatherservice"
SOAP-ENV:encodingStyle="http://www.w3.org/2001/09/soap-encoding">
<return xsi:type="xsd:int">65</return>
</ns1:getWeatherResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

The response indicates a single integer return value (the current temperature).
The World Wide Web Consortium (W3C) is in the process of creating a SOAP standard. The latest working draft is designated as SOAP 1.2, and the specification is now broken into two parts. Part 1 describes the SOAP messaging framework and envelope specification. Part 2 describes the SOAP encoding rules, the SOAP-RPC convention, and HTTP binding details.
What is WSDL?
The Web Services Description Language (WSDL) currently represents the service description layer within the Web service protocol stack.
In a nutshell, WSDL is an XML grammar for specifying a public interface for a Web service. This public interface can include the following:

Information on all publicly available functions.
Data type information for all XML messages.
Binding information about the specific transport protocol to be used.
Address information for locating the specified service.

WSDL is not necessarily tied to a specific XML messaging system, but it does include built-in extensions for describing SOAP services.

Below is a sample WSDL file. This file describes the public interface for the weather service used in the SOAP example above. Obviously, there are many details to understanding the example. For now, just consider two points.
First, the <message> elements specify the individual XML messages that are transferred between computers. In this case, we have a getWeatherRequest and a getWeatherResponse. Second, the element specifies that the service is available via SOAP and is available at a specific URL.

<?xml version="1.0" encoding="UTF-8"?>
<definitions name="WeatherService"
targetNamespace="http://www.ecerami.com/wsdl/WeatherService.wsdl"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.ecerami.com/wsdl/WeatherService.wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<message name="getWeatherRequest">
<part name="zipcode" type="xsd:string"/>
</message>
<message name="getWeatherResponse">
<part name="temperature" type="xsd:int"/>
</message>

<portType name="Weather_PortType">
<operation name="getWeather">
<input message="tns:getWeatherRequest"/>
<output message="tns:getWeatherResponse"/>
</operation>
</portType>

<binding name="Weather_Binding" type="tns:Weather_PortType">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getWeather">
<soap:operation soapAction=""/>
<input>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:examples:weatherservice"
use="encoded"/>
</input>
<output>
<soap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:examples:weatherservice"
use="encoded"/>
</output>
</operation>
</binding>

<service name="Weather_Service">
<documentation>WSDL File for Weather Service</documentation>
<port binding="tns:Weather_Binding" name="Weather_Port">
<soap:address
location="http://localhost:8080/soap/servlet/rpcrouter"/>
</port>
</service>
</definitions>
Using WSDL, a client can locate a Web service, and invoke any of the publicly available functions. With WSDL-aware tools, this process can be entirely automated, enabling applications to easily integrate new services with little or no manual code. For example, check out the GLUE platform from the Mind Electric.
WSDL has been submitted to the W3C, but it currently has no official status within the W3C. See this W3C page for the latest draft.
What is UDDI?
UDDI (Universal Description, Discovery, and Integration) currently represents the discovery layer within the Web services protocol stack.
UDDI was originally created by Microsoft, IBM, and Ariba, and represents a technical specification for publishing and finding businesses and Web services.
At its core, UDDI consists of two parts.
First, UDDI is a technical specification for building a distributed directory of businesses and Web services. Data is stored within a specific XML format, and the UDDI specification includes API details for searching existing data and publishing new datAns.
Second, the UDDI Business Registry is a fully operational implementation of the UDDI specification. Launched in May 2001 by Microsoft and IBM, the UDDI registry now enables anyone to search existing UDDI datAns. It also enables any company to register themselves and their services.
The data captured within UDDI is divided into three main categories:
White Pages: This includes general information about a specific company. For example, business name, business description, and address.
Yellow Pages: This includes general classification data for either the company or the service offered. For example, this data may include industry, product, or geographic codes based on standard taxonomies.
Green Pages: This includes technical information about a Web service. Generally, this includes a pointer to an external specification, and an address for invoking the Web service.
You can view the Microsoft UDDI site, or the IBM UDDI site. The complete UDDI specification is available at uddi.org.
Beta versions of UDDI Version 2 are available at:
Hewlett Packard
IBM
Microsoft
SAP
How do I get started with Web Services?
The easiest way to get started with Web services is to learn XML-RPC. Check out the XML-RPC specification or read my book, Web Services Essentials. O'Reilly has also recently released a book on Programming Web Services with XML-RPC by Simon St.Laurent, Joe Johnston, and Edd Dumbill.
Once you have learned the basics of XML-RPC, move onto SOAP, WSDL, and UDDI. These topics are also covered in Web Services Essentials. For a comprehensive treatment of SOAP, check out O'Reilly's Programming Web Services with SOAP, by Doug Tidwell, James Snell, and Pavel Kulchenko.
Does the W3C support any Web service standards?
The World Wide Web Consortium (W3C) is actively pursuing standardization of Web service protocols. In September 2000, the W3C established an XML Protocol Activity. The goal of the group is to establish a formal standard for SOAP. A draft version of SOAP 1.2 is currently under review, and progressing through the official W3C recommendation process.
On January 25, 2002, the W3C also announced the formation of a Web Service Activity. This new activity will include the current SOAP work as well as two new groups. The first new group is the Web Services Description Working Group, which will take up work on WSDL. The second new group is the Web Services Architecture Working Group, which will attempt to create a cohesive framework for Web service protocols.

Overview

QUES. What are the different application integration styles?

ANS. There are a number of different integration styles like

1. Shared database
2. batch file transfer
3. Invoking remote procedures (RPC)
4. Exchanging asynchronous messages over a message oriented middle-ware (MOM).


QUES. What are the different styles of Web Services used for application integration?
ANS. SOAP WS and RESTful Web Service


QUES. What are the differences between both SOAP WS and RESTful WS? 
ANS. 
  • The SOAP WS supports both remote procedure call (i.e. RPC) and message oriented middle-ware (MOM) integration styles. The Restful Web Service supports only RPC integration style.
  • The SOAP WS is transport protocol neutral. Supports multiple protocols like HTTP(S),  Messaging, TCP, UDP SMTP, etc. The REST is transport protocol specific. Supports only HTTP or HTTPS protocols.
  • The SOAP WS permits only XML data format.You define operations, which tunnels through the POST. The focus is on accessing the named operations and exposing the application logic as a service. The REST permits multiple data formats like XML, JSON data, text, HTML, etc. Any browser can be used because the REST approach uses the standard GET, PUT, POST, and DELETE Web operations. The focus is on accessing the named resources and exposing the data as a service. REST has AJAX support. It can use the XMLHttpRequest object. Good for stateless CRUD (Create, Read, Update, and Delete) operations.
         GET - represent()
         POST - acceptRepresention()
         PUT - storeRepresention()
         DELETE - removeRepresention()
  • SOAP based reads cannot be cached. REST based reads can be cached. Performs and scales better.
  • SOAP WS supports both SSL security and WS-security, which adds some enterprise security features like maintaining security right up to the point where it is needed, maintaining identities through intermediaries and not just point to point SSL only, securing different parts of the message with different security algorithms, etc. The REST supports only point-to-point SSL security. The SSL encrypts the whole message, whether all of it is sensitive or not.
  • The SOAP has comprehensive support for both ACID based  transaction management  for short-lived transactions and compensation based transaction management for long-running transactions. It also supports two-phase commit across distributed resources. The REST supports transactions, but it  is neither ACID compliant nor can provide two phase commit across distributed transactional resources as it is limited by its HTTP protocol.
  • The SOAP has success or retry logic built in and provides end-to-end reliability even through SOAP intermediaries. REST does not have a standard messaging system, and expects clients invoking the service to deal with communication failures by retrying.
QUES. How would you decide what style of Web Service to use? SOAP WS or REST?
ANS. In general, a REST based Web service is preferred due to its simplicity, performance, scalability, and support for multiple data formats. SOAP is favored where service requires comprehensive support for security and transactional reliability.

The answer really depends on the functional and non-functional requirements. Asking the questions listed below will help you choose.
  • Does the service expose data or business logic? (REST is a better choice for exposing data, SOAP WS might be a better choice for logic).Do the consumers and the service providers require a formal contract? (SOAP has a formal contract via WSDL)
  • Do we need to support multiple data formats?
  • Do we need to make AJAX calls? (REST can use the XMLHttpRequest)
  • Is the call synchronous or  asynchronous?
  • Is the call stateful or stateless? (REST is suited for statless CRUD operations)
  • What level of security is required? (SOAP WS has better support for security)
  • What level of transaction support is required? (SOAP WS has better support for transaction management)
  • Do we have limited band width? (SOAP is more verbose)
  • What’s best for the developers who will build clients for the service? (REST is easier to implement, test, and maintain)
QUES. What tools do you use to test your Web Services?
ANS. SoapUI tool for SOAP WS and the Firefox "poster" plugin for RESTFul services.


QUES. What is the difference between SOA and a Web service?
ANS.
SOA is a software design principle and an architectural pattern for implementing loosely coupled, reusable and coarse grained services. You can implement SOA using any protocols such as HTTP, HTTPS, JMS, SMTP, RMI, IIOP (i.e. EJB uses IIOP), RPC etc. Messages can be in XML or Data Transfer Objects (DTOs).    

Web service is an implementation technology and one of the ways to implement SOANS. You can build SOA based applications without using Web services – for example by using other traditional technologies like Java RMI, EJB, JMS based messaging, etc. But what Web services offer is the standards based  and platform-independent service via HTTP, XML, SOAP, WSDL and UDDI, thus allowing interoperability between heterogeneous technologies such as J2EE and .NET.


QUES. Web services when you can use traditional style middle-ware such as RPC, CORBA, RMI and DCOM?
ANS.

The traditional middle-wares tightly couple connections to the applications and it can break if you make any modification to your application. Tightly coupled applications are hard to maintain and less reusable. Generally do not support heterogeneity. Do not work across Internet. Can be more expensive and hard to use.

Web Services support loosely coupled connections. The interface of the Web service provides a layer of abstraction between the client and the server. The loosely coupled applications reduce the cost of maintenance and increases re-usability. Web Services present a new form of middle-ware based on XML and Web. Web services are language and platform independent. You can develop a Web service using any language and deploy it on to any platform, from small device to the largest supercomputer. Web service uses language neutral protocols such as HTTP and communicates between disparate applications by passing XML messages to each other via a Web API. Do work across internet, less expensive and easier to use.


QUES. What are the different approaches to developing SOAP based Web service? ANS. 2 approaches.
  • The contract-first approach, where you define the contract first with XSD and WSDL and generate the Java classes from the contract.
  • The contract-last approach where you define the Java classes first and then generate the contract, which is the WSDL file from the Java classes.

Note: The WSDL describes all operations that the service provides, locations of the endpoints (i.e.e where the services can be invoked), and simple and complex elements that can be passed in requests and responses.


QUES. What are the pros and cons of each approach, and which approach would you prefer?

ANS.

Contract-first Web service

PROS:
  • Clients are decoupled from the server; hence the implementation logic can be revised on the server without affecting the clients.
  • Developers can work simultaneously on client and server side based on the contract both agreed on.
  • You have full control over how the request and response messages are constructed -- for example, should "status" go as an element or as an attribute? The contract clearly defines it. You can change OXM (i.e. Object to XML Mapping) libraries without having to worry if the "status" would be generated as "attribute" instead of an element. Potentially, even Web service frameworks and tool kits can be changed as well from say Apache Axis to Apache CXF, etc
 
CONS:
  • More upfront work is involved in setting up the XSDs and WSDLs. There are tools like XML Spy, Oxygen XML, etc to make things easier. The object models need to be written as well.
     
  • Developers need to learn XSDs and WSDLs in addition to just knowing JavAns.
 
Contract-last Web service
 
PROS:
  • Developers don't have to learn anything related to XSDs, WSDLs, and SOAP. The services are created quickly by exposing the existing service logic with frameworks/tool sets. For example, via IDE based wizards, etc.
      
  • The learning curve and development time can be smaller compared to the Contract-first Web service.
 
CONS:
  •  The development time can be shorter to initially develop it, but what about the on going maintenance and extension time if the contract changes or new elements need to be added? In this approach, since the clients and servers are more tightly coupled, the future changes may break the client contract and affect all clients or require the services to be properly versioned and managed.
  •  In this approach, The XML payloads cannot be controlled. This means changing your OXM libraries could cause something that used to be an element to become an attribute with the change of the OXM.


Advance Java Blogging

Java New Articles

Javas Latest News

Java Web Services and XML

Ajax Latest News

Mac OS Java Features

Advance Spotlights

Patterns Features