1) Define Web Service?
A web service is a kind of software that is accessible on the Internet. It makes use of the XML messaging system and offers an easy to understand, interface for the end users.
3) Give me an example of real web service?
Basically web services can be used with the help of SOAP, WSDL, and UDDI . All these, provide a plug-and-play interface for using web services such as stock-quote service, a traffic-report service, weather service etc.
7) Define SOAP?
SOAP is an XML based protocol to transfer between computers.
8) Define WSDL?
It means Web Services Description Language. It is basically the service description layer in the web service protocol stock. The Service Description layer describes the user interface to a web service.
17) Differentiate between a SOA and a Web service?
SOA is a design and architecture to implement other services. SOA can be easily implemented using various protocols such as HTTP, HTTPS, JMS, SMTP, RMI, IIOP, RPC etc. While Web service, itself is an implemented technology. In fact one can implement SOA using the web service.
23) What is REST?
REST stands for Representational State Transfer. REST itself is not a standard, while it uses various standards such as HTTP, URL, XML/HTML/GIF/JPEG (Resource Representations) and text/xml, text/html, image/gif, image/jpeg, etc (MIME Types).
25) Name the various communication channels in web service?
Web service is integrated with three protocols such as HTTP/POST, HTTP/GET, and SOAP. It provides three different communication channels to clients. Client can choose any communication method as per requirements.
29) Differentiate between web services, CORBA and DCOM?
Web services transfer/receive messages to/from application respectively, via HTTP protocol. It uses XML to encode data.
CORBA and DCOM transfer/receive messages to/from application respectively, via non-standard protocols such as IIOP and RPC.
31) Can you name some standards used in web services?
The standards used in web services are WSDL (used to create interface definition), SOAP (used to structure data), HTTP (communication channels), DISCO (used to create discovery documents) and UDDI (used to create business registries).
33) Explain in brief, what UDDI is?
UDDI (Universal Description, Discovery, and Integration) provides consolidated directory for web services on the internet. Clients use UDDI to find web services as per their business needs. It basically hosts the web services from various companies. In order to share web services, you need to publish it in UDDI.
40) What are the steps performed by the client to access a web service?
First of all a web reference to the web service is created by the client in his application. Then a proxy class is generated. After that an object of the proxy class is created and at last, the web service is accessed via that proxy object.
44) Brief few drawbacks of using GET and POST methods to communicate with the web service?
These methods are less secure and inhibit users to pass structures and objects as arguments. Also, it doesn’t allow users to pass ByRef arguments.
48) Can you name different kinds of web services?
There are two types of web services in total i.e. SOAP based web service and RESTful web service.
49) What’s different in RESTful web services?
The RESTful web services contains no contract or WSDL file.
50) Give me few reasons to use RESTful web service?
The RESTFul web services are simple to implement and test. It supports various data formats such as XML, JSON etc.
http://www.gointerviews.com/top-50-web-services-interview-questions/
What is WSDL?
WSDL is an XML-based language for describing Web services and how to access them.
WSDL Describes Web Services
WSDL stands for Web Services Description Language.
WSDL is a document written in XML. The document describes a Web service. It specifies the location of the service and the operations (or methods) the service exposes.
http://www.w3schools.com/wsdl/wsdl_intro.asp
Does Web Service call is synchronous or asynchronous ?
An asynchronous web service allows a client to submit a request, process the request and respond to the client after a given time -- the client would not block all activity on receiving a response.
Comparatively, a web service that is synchronous would provide a client directly with a response, expecting the client to block all activity until a response is returned. In this case the web service would limit the client to process requests one at a time.
What is the difference between Java RMI and JMS?
RMI is a form of Remote Procedure Call (RPC). It is a lightweight, Java specific API that expects the caller and receiver to be available at the time of communication.
JMS is a reliable messaging subsystem. Messages can be passed even if one of the parties is not available. It is an alternative to things like MQSeries.
RMI doesn't deal with guaranteed delivery or asynchronous responses, JMS does.
difference between RMI, WebService, CORBA
RMI is Java's native method of invoking methods on objects that are located in a different JVM - Remote Method Invocation. It passes objects over the wire in binary, and can run either over the JRMP (Java Remote Method Protocol) or via IIOP (CORBA's Internet Inter-ORB Protocol)
CORBA is a language neutral remote method invocation protocol specified by the OMG standards group, and works with C/C++, Smalltalk, etc as well as with Java. CORBA laos sends data across the wire in binary format, and specifies interfaces in a scheme known as IDL (Interface Definition Language)
Web Services are remote invocations that are sent across the wire usually via SOAP (a flavour of XML data) over HTTP, but they can also go as SOAP/JMS, or other bindings - SMTP, etc
Wednesday, November 21, 2012
inheritance vs composition
About inheritance
In this article, I'll be talking about single inheritance through class extension, as in:
class Fruit {
//...
}
class Apple extends Fruit {
//...
}
In this simple example, class Apple is related to class Fruit by inheritance, because Apple extends Fruit. In this example, Fruit is the superclass and Apple is the subclass.
bout composition
By composition, I simply mean using instance variables that are references to other objects. For example:
class Fruit {
//...
}
class Apple {
private Fruit fruit = new Fruit();
//...
}
In the example above, class Apple is related to class Fruit by composition, because Apple has an instance variable that holds a reference to a Fruit object. In this example, Apple is what I will call the front-end class and Fruit is what I will call the back-end class. In a composition relationship, the front-end class holds a reference in one of its instance variables to a back-end class.
The composition alternative
Given that the inheritance relationship makes it hard to change the interface of a superclass, it is worth looking at an alternative approach provided by composition. It turns out that when your goal is code reuse, composition provides an approach that yields easier-to-change cod
http://www.artima.com/designtechniques/compoinh.html
In this article, I'll be talking about single inheritance through class extension, as in:
class Fruit {
//...
}
class Apple extends Fruit {
//...
}
In this simple example, class Apple is related to class Fruit by inheritance, because Apple extends Fruit. In this example, Fruit is the superclass and Apple is the subclass.
bout composition
By composition, I simply mean using instance variables that are references to other objects. For example:
class Fruit {
//...
}
class Apple {
private Fruit fruit = new Fruit();
//...
}
In the example above, class Apple is related to class Fruit by composition, because Apple has an instance variable that holds a reference to a Fruit object. In this example, Apple is what I will call the front-end class and Fruit is what I will call the back-end class. In a composition relationship, the front-end class holds a reference in one of its instance variables to a back-end class.
The composition alternative
Given that the inheritance relationship makes it hard to change the interface of a superclass, it is worth looking at an alternative approach provided by composition. It turns out that when your goal is code reuse, composition provides an approach that yields easier-to-change cod
http://www.artima.com/designtechniques/compoinh.html
inheritance vs delegation java
- inheritance vs delegation java
Inheritance is used to create a hierarchical-type code structure that tries to keep as much “common” code near the top of the hierarchy.
In small, static systems, inheritance can be ok.
But large inheritance chains can also lead to hard-to-maintain code
design patterns that favor composition over inheritance for more info when to use inheritance and when not to.
Delegation is simply passing a duty off to someone/something else.
Delegation is alternative to inheritance.
Delegation means that you use an object of another class as an instance variable, and forward messages to the instance.
It is better than inheritance because it makes you to think about each message you forward, because the instance is of a known class, rather than a new class, and because it doesn’t force you to accept all the methods of the super class
you can provide only the methods that really make sense.
Delegation can also a powerful design/reuse technique.
The primary advantage of delegation is run-time flexibility
the delegate can easily be changed at run-time.
the choice between delegation and inheritance is driven by external factors such as programming language support for multiple inheritance or design constraints requiring polymorphism.
Consider threads in Java. You can associate a class with a thread in one of two ways: either by extending (inheriting) directly from class Thread, or by implementing the Runnable interface and then delegating to a Thread object
Often the approach taken is based on the restriction in Java that a class can only extend one class (i.e., Java does not support multiple inheritance). If the class you want to associate with a thread already extends some other class in the design, then you would have to use delegation; otherwise, extending class Thread would usually be the simpler approach
http://www.techartifact.com/blogs/2009/05/delegation-versus-inheritance-in-java.html#ixzz2CqNmtYMM
Lazy initialization
- Lazy initialization
In a software design pattern view, lazy initialization is often used together with a factory method pattern. This combines three ideas:
using a factory method to get instances of a class (factory method pattern)
storing the instances in a map, so you get the same instance the next time you ask for an instance with same parameter (Multiton pattern, similar to the singleton pattern)
using lazy initialization to instantiate the object the first time it is requested (lazy initialization pattern).
http://en.wikipedia.org/wiki/Lazy_initialization#Java
- Lazy initialization is a performance optimization.
if the hashCode value for an object might not actually be needed by its caller, always calculating the hashCode for all instances of the object may be felt to be unnecessary.
since accessing a file system or network is relatively slow, such operations should be put off until they are absolutely required.
Lazy initialization has two objectives :
delay an expensive operation until it's absolutely necessary
store the result of that expensive operation, such that you won't need to repeat it again
http://www.javapractices.com/topic/TopicAction.do?Id=34