Saturday 13 February 2016

Web Services All


What are web services ? Why use them ?
What is service oriented architecture ? Benefits ?
What is REST ? Characteristics ? Why use it ? What are the http methods supported by REST ? What is a resource ?
Difference between rest and soap ? When to use which ?
Difference between get and post ?    Difference between put and post ?
What happens if RestFull resources are accessed by multiple clients ? Do you need to make it thread-safe?
How to use web services with spring?
What is URI ? URI vs URL ?
What is statelessness ? Pros and cons ?
What are the components of REST request and response ?
*******************************************************       
                ANSWERS  
*******************************************************
What are web services ? Why use them ?
Web service is a mechanism by which two programs communicate over web.
Web services help in building scalable, dynamic, distributed software system.
According to Oracle:
Web services are client and server applications that communicate over the World Wide Web’s (WWW) HyperText Transfer Protocol (HTTP). As described by the World Wide Web Consortium (W3C), web services provide a standard means of interoperating between software applications running on a variety of platforms and frameworks. Web services are characterized by their great interoperability and extensibility, as well as their machine-processable descriptions, thanks to the use of XML. Web services can be combined in a loosely coupled way to achieve complex operations. Programs providing simple services can interact with each other to deliver sophisticated added-value services.
What is service oriented architecture? Benefits?
http://www.indiawebdevelopers.com/resource_center/articles/soa.html
When to use
What is REST? Characteristics? Why use it? What are RESTful web services? What are the http methods supported by REST? What is a resource?
REST stands for representational state transfer. It's a software architectural style for world wide web.
REST has following properties/constraints:
a) Client Server Architecture
b) Stateless
c) Cacheable
d) Layered
e) Uniform Interface
f) Code on Demand(optional)
It has many benefits such as :
a) Stateless, lightweight
b) Simple,  efficient, easy to implement architecture.

Restful webservices are web services which follow RESTful architecture. It is HTTP-based and and functionalites are exposed as resources via URI and HTTP-based verbs such as GET,POST,PUT,DELETE,HEAD,TRACE are used to create/modify resources.
Resource is similar to an object in oop except that it's accessed via HTTP verbs such as GET,POST,PUT,etc. (????)
I think any functionality or object exposed via web services is a resource(??)
I think this is correct: Any information that can be named can be a resource, a document or image, etc.
From Fielding's dissertation:
The key abstraction of information in REST is a resource. Any information that can be named can be a resource: a document or image, a temporal service (e.g. "today's weather in Los Angeles"), a collection of other resources, a non-virtual object (e.g. a person), and so on. In other words, any concept that might be the target of an author's hypertext reference must fit within the definition of a resource. A resource is a conceptual mapping to a set of entities, not the entity that corresponds to the mapping at any particular point in time.
Difference between rest and soap ? When to use which ?
a) Rest is lightweight compared to soap.
Soap tightly couple client and server while rest keeps them loosely coupled. Any changes in either side leads to change in soap. There is no wsdl, uddi in rest.
b) Rest can be used with xml or json while soap is limited to xml. JSON is human readable, easily parseable, close to JS.
c) Rest works on http while soap has it's own protocol.
d) SOAP provides more control than REST. Depending on the requirements , if not so much sophisticated implementation is required , REST can be used.
5.) Soap provides better security.
Difference between get and post? Difference between put and post?
a) GET is non-idempotent i.e, it doesn't changes the resource while POST is idempotent.
Is get vs post same in web services as in http ??Put and Post are very similar in rest. Put is used to create a new resource while post is used to edit any changes. Put is idempotent and POST is not.
What happens if RestFull resources are accessed by multiple clients ? Do you need to make it thread-safe?
For every request a new instance of resource is created. So, restful resources are inherently thread safe.
How to use web services with spring ?
Web services can be easily used with spring MVC.  Link to example.
What is URI? URI vs URL?
URI stands for Uniform Resource Identifier, it is the complete path of the resource. URL stands for Unifrom Resource Locator. URL tell the server location only. URL is part of URI.
What is statelessness? Pros and cons?
Statelessness refers to the feature that a component doesn't remember anything about the last request, i.e, it doesn't maintain any state. There is no difference between new request from a different machine or same machine.
Statelessness helps in developing lightweight, fast, distributed system.
Benefits:
a) Less memory overhead
b) No session related issues
c) Easy sharing of urls
d) Easy to develop scalable,distributed system because syn is not required across servers.
What are the components of REST request and response?
REST request and response is based on client server architecture. Internet is an example of RESTful architecture. It uses HTTP based verbs to perform any action over HTTP.


**************Unranked**********
High
Web services security (http://www.tutorialspoint.com/webservices/web_services_security.htm)
What is Oauth?
why rest is called so?
Can rest be used over soap or vice versa?
What is jersey, JAX-RS? Why use them?
What is idempotent?
How to test web services? Avg 

Low
What was before web services? (http://stackoverflow.com/questions/3028214/what-came-before-web-services-and-soa)





*****************************ANSWERED QUESIONS*******************
What are web services ? Why use them ?
What is service oriented architecture ? Benefits ?
What is REST ? Characteristics ? Why use it ? What are the http methods supported by REST ? What is a resource ?
Difference between rest and soap ? When to use which ?
Difference between get and post?Difference between put and post ?
What happens if RestFul resources are accessed by multiple clients ? Do you need to make it thread-safe?
How to use web services with spring?
What is URI ? URI vs URL ?
What is statelessness ? Pros and cons ?

What are the components of REST request and response ?
*********************************************************************************

Useful Links:

http://rest.elkstein.org
https://dzone.com/articles/web-services-architecture
http://programmers.stackexchange.com/questions/99389/how-do-i-convince-my-boss-to-use-rest-over-soap


What are web services?
What are the features of web services?
What the components of a Web Service?
How Does a Web Service Work?
What is the purpose of XML in a web service?
What is the purpose of SOAP in a web service?
What is the purpose of WSDL in a web service?
What are the benefits of Web Services?
What do you mean by Interoperability of Web Services?
What do you mean by loosely coupled architecture of Web services?
Do Web services supports Remote Procedure Calls(RPCs)?
What are the behavioral characteristics of web services?
What are the benefits of having XML based WEB services?
What is the benefit of a Web services being loosely coupled?
What is Synchronicity?
What are the core Roles in Web Service architecture?
What is the purpose of Service Provider in Web Service architecture?
What is the purpose of Service Requestor in Web Service architecture?
What is the purpose of Service Registry in Web Service architecture?
What are the core layers in Web Service Protocol Stack?
What is the purpose of Service Transport layer in Web Service Protocol Stack?
What is the purpose of XML Messaging layer in Web Service Protocol Stack?
What is the purpose of Service Description layer in Web Service Protocol Stack?
What is the purpose of Service Discovery layer in Web Service Protocol Stack?
What HTTP stands for?
What is HTTP?
What BEEP stands for?
What is BEEP?
What is XML-RPC?
How request is sent in XML-RPC?
How response is sent in XML-RPC?
What are the features of XML-RPC?
What SOAP stands for?
What is SOAP?
What are the features of SOAP?
Is SOAP platform independent?
What WSDL stands for?
What is WSDL?
What are the features of WSDL?
What UDDI stands for?
What is UDDI?
What are the features of UDDI?
What are the primary security issues with web services?
Which component of Web service describes interfaces to web services?
Which language UDDI uses?
Is XML-RPC is platform-dependent?
If a client sends an XML request to a server, can we ensure that the communication remains confidential?
If a client connects to a web service, how do we identify the user? Is the user authorized to use the service?
What do you mean by Web services manageability?

How to handle Network security threats in Web services?

What is a Web Service?
What are the advantages of Web Services?
What are different types of Web Services?
What is SOAP?
What are advantages of SOAP Web Services?
What are disadvantages of SOAP Web Services?
What is WSDL?
What are different components of WSDL?
What is UDDI?
What is difference between Top Down and Bottom Up approach in SOAP Web Services?
What is REST Web Services?
What are advantages of REST web services?
What are disadvantages of REST web services?
What is a Resource in Restful web services?
What are different HTTP Methods supported in Restful Web Services?
Compare SOAP and REST web services?
What are different ways to test web services?
Can we maintain user session in web services?
What is difference between SOA and Web Services?
What is the use of Accept and Content-Type Headers in HTTP Request?
How would you choose between SOAP and REST web services?
What is JAX-WS API?
Name some frameworks in Java to implement SOAP web services?
Name important annotations used in JAX-WS API?
What is use of javax.xml.ws.Endpoint class?
What is the difference between RPC Style and Document Style SOAP web Services?
How to get WSDL file of a SOAP web service?
What is sun-jaxws.xml file?
What is JAX-RS API?
Name some implementations of JAX-RS API?
What is wsimport utility?
Name important annotations used in JAX-RS API?
What is the use of @XmlRootElement annotation?

How to set different status code in HTTP response?

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.


2) What is new in this field for past few years?

The initiation of XML in this field is the advancement that provides web service a single language to communicate in between the RPCs, web services and their directories.

3) Give me an example of real web service?

One example of web services is IBM Web Services browser. You can get it from IBM Alphaworks site. This browser shows various demos related to web services. 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.

4) How you define web service protocol stack?

It is basically set of various protocols that can be used to explore and execute web services. The entire stack has four layers i.e. Service Transport, XML Messaging, Service Description and Service Discovery.

5) Can you define each of these layers of protocol stack?

The Service Transport layer transfer messages between different applications, such as HTTP, SMTP, FTP, and Blocks Extensible Exchange Protocol (BEEP). The XML Messaging layer encodes messages in XML format so that messages can be understood at each end, such as XML-RPC and SOAP. The Service Description layer describes the user interface to a web service, such as WSDL. The Service Discovery layer centralizes services to a common registry and offer simple publish functionality, such as UDDI.

6) Define XML – RPC?

It is a protocol that makes use of XML messages to do Remote Procedure Calls.

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.

9) What kind of security is needed for web services?

Image for Web Services
Web Services
The security level for web services should be more than that of what we say Secure Socket Layer (SSL). This level of security can be only achieved from Entrust Secure Transaction Platform. Web services need this level of security to ensure reliable transactions and secure confidential information .

10) Do you have any idea about foundation security services?

As implies from its name, these services are the foundation or basics of integration, authentication, authorization, digital signatures and encryption processes.

11) Define Entrust Identification Service?

Entrust Identification Service comes from the Entrust Security Transaction Platform. This platform allows companies to control the identities that are trusted to perform transactions for Web services transactions.

12) What UDDI means?

UDDI stands for Universal, Description, Discovery, and Integration. It is the discovery layer in the web services protocol stack.

13) Define Entrust Entitlements Service?

This service verifies entities that attempt to access a web service. For Example, the authentication service, the Entitlements Service ensures security in business operations.

14) Define Entrust Privacy Service?

As its name implies, it deals with security and confidentiality. This service encrypts data to ensure that only concerned parties can access the data.

15) What do you mean by PKI?

It means Public-Key Infrastructure.

16) What tools are used to test a web service?

I have used SoapUI for SOAP WS and Firefox poster plugin for RESTFul Services.

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.

18) Discuss various approaches to develop SOAP based web service?

We can develop SOAP based web service with two different types of approaches such as contract-first and contract-last. In the first approach, the contract is defined first and then the classes are derived from the contract while in the later one, the classes are defined first and then the contract is derived from these classes.

19) If you have to choose one approach, then what will be your choice?

In my point of view, the first approach that is the contract-first approach is more feasible as compared to the second one but still it depends on other factors too.

20) Is there any special application required to access web service?

No, you don’t need to install any special application to access web service. You can access web service from any application that supports XML based object request and response.

21) Can you name few free and commercial implementations for web services?

The implementations I know are Apache SOAP, JAX-WS Reference Implementation, JAX-RS Reference Implementation, Metro, Apache CXF, MS.NET and Java 6.

22) Name browser that allows access to web service?

JavaScript XmlHttpRequest object is required to access web service via browsers. The browsers that support this object are Internet Explorer, Safari and Mozilla-based browsers like FireFox.

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).

24) How one can provide API to users?

To provide an API to the users, one can easily do this with an “open table”. All you need to do is to write open table which is basically an XML schema that point to a web service.

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.

26) How can you document web service?

Web services are contemplated as self-documenting because they provide entire information regarding the available methods and parameters used for XML based standard, known as WSDL. One can also provide more information to explain web services via their own WebService and WebMethod attributes.

27) What are the situations, when we need ASP.NET web services?

ASP.NET web services are used when one need to implement three tier architecture in a web service. It allows handy ways to use middle tier components through internet. The main advantage of .NET Web services is that they are capable enough to communicate across firewalls because they use SOAP as transport protocol.

28) What are distributed technologies?

The increasing ratio of distributed applications has raised demand for distributed technologies. It allows segmenting of application units and transferring them to different computers on different networks.

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.

30) Can you tell few benefits of web services?

The biggest advantage of web service is that is supported by wide variety of platforms. Moreover, in near future, web services may spread its boundary and enhance new methods that will provide ease to clients. The enhancement will not affect the clients, even if they offer old methods and parameters.

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).

32) Explain in brief, what DISCO is?

DISCO means discovery. It groups the list of interrelated web services. The organization that provides web services, issues a DISCO file on its server and that file contains the links of all the provided web services. This standard is good when client knows the company already. Also it can be used within a local network as well.

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.

34) Explain the .NET web services supported data types? 

.Net web services uses XML-based standards to transfer/receive information. Thus, .NET web services can only works with data types known by XML schema standard. Like FileSteam, Eventlog etc. are not recognized by the XML schema standards and hence, not supported in web services.

35) How a .NET web service is tested?

ASP.NET uses a test page routinely, when one calls for the URL of .asmx file in any browser. This page shows complete information regarding web services.

36) How a .NET web service is consumed?

Since we know that web services are constructed on XML standards. Therefore, clients need to have complete understanding of XML-based messages to interchange messages. Clients can communicate with web services through .NET framework that offers proxy mechanisms. These proxy mechanisms have detailed information regarding data sharing within web services that can be easily used by the clients.

37) Can you name the two Microsoft solutions for distributed applications?

The two Microsoft solutions for distributed applications are .NET Web Services and .NET Remoting.

38) Differentiate between .NET Web Services and .NET Remoting?

As far as protocol is concerned, .NET Web Service uses HTTP, while, .NET Remoting uses any protocol i.e. TCP/HTTP/SMTP. When it comes to performance, .NET Remoting is comparatively, faster than.NET Web Service. Also, as .NET Web Services are hosted via IIS, therefore, it is far more reliable than the .NET Remoting.

39) Name the components to be published while deploying a Web Service?

The components that need to be published during a web service deployment are Web Application Directory, Webservice.asmx File, Webservice.Disco File, Web.Config File and Bin Directory.

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.

41) How web services are implemented in .NET?

To implement web services in .NET, HTTP handlers are used that interrupt requests to .asmx files.

42) Explain few disadvantages of Response Caching?

Response Caching is useless or incompetent when method accepts extensive amount of values because caching means to store lot of information.  Also, if the method depends on external source of information, and that are not provided within the parameters then such methods are bypassed.

43) What is the alternate solution to Response Caching?

One can use Data Caching (System.Web.Caching.Cach) instead of Response Caching.

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.

45) How can one access a class as a web service?

To access a class as a web service, one should inherit the class from the System.Web.Services.WebService class and qualify the class with the WebService attribute.

46) How can one access the web service class method via internet?

To access web service class method via internet, one should qualify a method with the WebMethod attribute.

47) How a SOAP message is structured?

A SOAP message is consists of SOAP Envelope, SOAP Headers, and SOAP Body.

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.

This question is already mentioned earlier.

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.

51) Explain what is JAVA web services? What are the methods to create web services?

Java webservices is developed to build and deploy basic web service on JAVA platform.

To create a web services, there are two approaches that are adopted

Top-down approach
Top-up approach
52) Explain what is JAXP?

JAXP is a JAVA API for XML processing that enables application to write, read, manipulate and transform XML data.  Similarly, to perform other various function there are other Java API’s as well like JAX-RPC, JAXM, JAXR, JAXB, etc.

53) Mention the JAXB binding framework?

JAXB binding framework is available in three Java Packages

xml.bind: This package defines abstract classes and interfaces that are used directly with content classes
xml.bind.util: This package contains utility classes that may be availed by client applications to manage marshalling, unmarshalling and validation events
xml.bind.helper: This helper package gives partial implementations for some of the javax.xml.bind interfaces. These APIs are not to be directly used by applications using JAXB architecture
54) Give a simple example of how XML document can be Marshal and Unmarshal in JAVA framework?

Marshalling is the process of converting XML document into Java readable form while UnMarshalling is the reverse process of Marshalling.  Let see how Java unmarshals an XML document and then marshals it back

JAXBContext jc= JAXBContext.newInstance (“com.acme.foo”);

// unmarshal from foo.xml

Unmarshaller u = jc.createUnmarshaller () ;

FooObject fooObj=

(FooObject)u.unmarshal (new File (“foo.xml”) );

// marshal to sytem.out

Marshaller m = jc.createMarshaller ();

m.marshal (fooObj, System.out);

55) Explain what does Marshaller do if jaxb.encoding property is not declared?

By default, the Marshaller will use “UTF-8” if jaxb.encoding property is not declared.

56) Mention what are the types of validation can a JAXB client can perform?

There are two types of JAXB client validation that a JAXB can perform

Unmarshal Time Validation
On-Demand Validation
57) Mention what are the three ways to handle the event encountered during the marshal, unmarshal and validate operations?

Using the default event handler
Register and Implement a custom event handler
Use the ValidationEventCollector utility
58) Explain where does JAXB compiler is located?

JAXB schema binding compiler is placed in the <JWSDP_Home>/jaxb/bin directory.  In this directory, there are two scripts, xjc.sh (Solaris/Linux) and xjc.bat (Windows).

59) In what cases do you need to customize the default binding?

In some cases, you are required to customize the default binding like

Creating API documentation for the schema derived JAXB packages, classes, methods and constants
Giving semantically meaningful customized names for cases that the default XML name-to-Java identifier mapping cannot handle automatically
Overriding default binding- like specifying that a model group should be attached to a class rather than a list
60) Explain what is Inline Customization?

Customization to JAXB bindings made by means of inline binding declarations  in an XML schema file that take the form of <xsd:appinfo> elements embedded in schema <xsd:annotation>elements.

61) Explain what is XML signature?

XML can be used to sign any arbitrary data whether it is a binary or XML.  The data is recognized via URIs in one or more reference elements.  It is described in one or more forms, like detached, enveloping or enveloped.

62) Explain what is Stax?

Stax stands for Streaming API for XML; it is an API to read and write XML documents, originating from the JAVA programming language.

63) Mention what are the usual XML APIs?

The usual XML APIs includes

DOM based or Tree based APIs: The whole document is read into memory as a tree structure for random availability by calling application
Event based APIs: The application registers to get events as entities are encountered within the source document
64) Explain what is Push parsing and Pull parsing?

Pull Parsing: Streaming pull parsing is referred to a programming model in which a client application calls methods on an XML parsing library, when it needed to communicate with an XML infoset- which means the client will only gets XML data when it is asked for
Push Parsing: In Push Parsing, the parser pushes parsing events or XML data to the application.  In push model, the parser got the hold over the parsing  process and the parser calls the implemented handler methods.
65) Explain on which technology does XWS security is based on? List out the options that XWS security provides for securing JAX-RPC applications?

XWS security is based on securing web services build on JAX-RPC and on stand-alone application based on SAAJ.  For securing JAX-RPC application, options that XWS security provides are

XML digital signature
XML encryption
Username token verification
XWS security framework APIs
66) List out the six packages available in XML Digital signature API?

Digital signature API is

xml.crypto
xml.crypto.dsig
xml.crypto.dsig.keyinfo
xml.crypto.dsig.spec
xml.crypto.dom
xml.crypto.dsig.dom
67) Explain what is JAXR?

JAXR is the JAVA programming APIs for Java platform application to access and programmatically interact with various kinds of meta-data registries.

68) Explain what does the JAXR architecture consist of?

JAXR architecture is consists of a JAXR client and JAXR provider.

JAXR client: It is a client program which uses the JAXR API to use a registry through a JAXR provider
JAXR provider: It is an implementation of the JAXR API that provide access to a particular registry provider or to a class of registry providers that are built on a common speicifications.
69) Explain what is JAXM messaging models?

There are two types of messaging models for JAXM synchronous and asynchronous

Synchronous messaging model: In such type of model, client directly communicates with the source. In this, the client will send the request and waits.
Asynchronous messaging model: In this model, client directs the message to the messaging provider and returns back.  Messaging provider then executes the routing of the message to the end source.
70) Explain what is UDDI, DISCO and WSDL?

UDDI: It means Universal Description, Discovery and I It is the directory that is used to publish and discover public web services
DISCO: It is commonly known as discovery. It clubs common services together and exposes schemas document of the web services

WSDL: It stands for web service description language (WSDL). It is used to describe web services.  The description includes URL of web services, properties and methods supported by web services, data type it supports and protocol detail it supports

No comments:

Post a Comment