Wednesday, 20 January 2016

Java Web Service Interview Questions

 Top 20 Java Web Service Interview Questions

 


1) 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
2) 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.
3) 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
4) 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);
5) 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.
12-24-2014 10-49-03 AM
6) 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
7) 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
8) 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).
9) 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
10) 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.
11) 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.
12) 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.
13) 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
14) 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.
15) 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
16) 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
17) 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.
18) 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.
19) 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.
20) 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: