Web services are in high demand in this era of technology. The world is shifting to online sources, and to manage it, web services are required. Here is given complete guide to Java Web Service Interview Questions in this article.
Java Web Services
A web service is a communication service between two or more electronic devices via www (World Wide Web). It is also responsible for responding to a request made by a server to access a web document over the network. In Java Web Services, communication is done through HTTP (Hypertext Transfer Protocol) over www by using XML-based documents.
In today’s world, there are tons of applications made. It isn’t easy to maintain an association between these different applications. But this task is possible through Java Web Services. These services are platform-independent and hence acts as a source of communication among various web applications.
Preparations For Interview For Java Web Services
Java is a vast language, and the web services it provides are dozens. Java web services are a completely different and huge field. It includes:
- Java Web Services Architecture
- Components of Java Web Services
- The Language Used for Java Web Services (WSDL)
- APIs Used for Java Web Services
- Web Services Security etc.
Frequently Asked Questions In Java Web Service Interview
Below is a list of frequently asked questions in a Java Web Services interview and their detailed answers.
- What are different Java Web services, and which one is better?
There are two primary web services in Java:
- SOAP (Simple Object Access Protocol)
- REST ( Representational State Transfer)
Choosing the better one:
Both services have their advantages, and choosing the best one depends on the situation. However, in many cases, REST is better than SOAP. This is because of the following reasons:
- REST services imply faster, uses less bandwidth, and have high formatting flexibility.
- SOAP provides support to only XML data format while REST web services work with all data formats, and the data is coupled with JSON.
- The data for request-call is cached in REST, while SOAP cannot cache data.
- SOAP services have strict rules for users during interaction with the server.
- Both REST and SOAP use different languages. REST API uses WADL, while SOAP API uses WSDL. So it also depends on the condition to choose the service.
- Why are web services essential in Software Development?
A straightforward answer to this question would be without web services, this world of electronic media would not be as powerful as it is now. There are many plus points for web services. For example:
- Without web services, there would not be any communication between different software running on other platforms. Even the same software made in different languages would not be able to communicate.
- Web services also provide operational services like security, reliability, versatility to check the performance of the software.
- Work-flows are also designed and carried out through web services.
- Many client applications can use a single web service at the same time.
- Web services are extensible.
- How many layers does the web service protocol stack have?
Web services consist of four layers of protocols. These are mentioned below in order:
- Service Transport (responsible for sending or receiving client’s requests.)
- XML Messaging (messages/requests are encoded in XML format here that is friendly to other client’s applications)
- Service Description (as clear from the name, it provides descriptions of services, i.e., availability)
- Service Discovery (in the end, this is used to publish web services over the internet)
- Name the protocols or languages that are used in the web services protocol stack.
- In the Service Transport layer, HTTP, FTP, BEEP, SMTP protocols.
- In the XML Messaging layer, XML-RPC and SOAP protocols are used.
- Only WSDL is used in the Service Description layer.
- Finally, in the Service Discovery layer, UDDI is used.
- What is a WSDL document?
WSDL is an XML- based document that gives all technical details of the web services. The information provided by the WSDL document includes:
- Port types
- Method name
- Service endpoint
- Method parameters
- Binding etc.
Some tags are also used in a WSDL XML. These include:
- Xsd import namespace
- SchemaLocation provides a new namespace for web service
- Message for method arguments
- PortType provides service name
- Operation contains the method name
- Why do we need ASP.Net Web services?
ASP.NET web services refer to the three-tier architecture and are applied when such architecture is needed. SOAP protocols are in common with web services and the ASP.NET. Web services of ASP.NET can communicate across the firewall.
- Describe terms UDDI and BEEP.
- UDDI – UDDI stands for Universal Description, Discovery, and Integration. It is the directory for web services. Web services are registered to the UDDI server, and clients’ applications get them from here.
- BEEP – BEEP is a protocol called Blocks Extensible Exchange Protocol. It is the protocol through which new protocols for different applications are built. Features of BEEP includes:
- Error Handling
- What do you know about XML digital signature API?
Six packages are used in XML digital signature API. These are described below:
- javax.xml.crypto package – this package contains classes that performs functions like creating XML signature or encrypting XML data
- javax.xml.crypto.dsig package – this package contains W3C XML digital signature specification and XML signature class.
- javax.xml.crypto.dsig.keyinfo package – this package contains interfaces for storing key information and the recommended structure in the W3C XML digital signature specification.
- javax.xml.crypto.dsig.spec package – it contains classes and interfaces that represents several input parameters.
- javax.xml.crypto.dom package – this package contains classes specific to DOM for javax.xml.crypto package.
- javax.xml.crypto.dsig.dom package – this package contains classes specific to DOM for javax.xml.crypto.dsig package.
- Explain web service architecture?
The web service architecture consists of three different layers. The roles of these layers are given below:
- Service Provider. This layer makes web services accessible for the clients to use for their applications later on. These are over-the-web services. It uses the Publish interface of the service registry to provide the available web service to the client’s application.
- Service Requestor. This layer is responsible for requesting any required service over the internet. The client’s application can be written in any language, and clients can request any service. The request is sent by sending an XML message.
- Service Registry. It is the centralized directory that stores all the web services. It also locates the web services when needed for the client’s application. New services can be added here, and existing services can be fetched.
- Describe the HTTP methods that are supported by REST web services.
REST web services support six HTTP methods. Their names, along with the functions performed, are:
- GET method has read-only access to the web resources
- POST method updates all the available resources
- The PUT method is used to create new resources
- The DELETE method is used to remove/delete any resource/s
- The HEAD method is used to return HTTP header
- OPTIONS method is used to perform operations on the resources
- Name APIs used by Java Web Services.
The APIs used in developing Java API methods are:
- What are JAX-WS and JAX-RS?
JAX-WS is a Java API for XML web services. It is the standard XML-based Java API that is used to create SOAP web services. On the other hand, JAX-RS is a Java API for REST web service. It contains a set of APIs that are used to create web services that support REST. JAX-RS is a part of Java EE6.
- What is XML-RPC?
XML-RPC is a protocol that is used to call a function on any remote computer by using XML. XML stands for Extensible Markup Language and RPC stand for Remote Procedure Call. Hence the name well defines its function.
Some significant features of XML-RPC are:
- XML-RPC is platform-independent
- It can bear communication among a large number of applications
- HTTP protocols are used for passing information
- the requests encoded by XML are sent through HTTP POST
- the response of the XML request is embedded in an HTTP response
- Name the standards used in web services.
Following are some standards that are used in web services; all of these have specific functions:
- Simple Object Access Protocol (SOAP) Message Transmission Optimization Mechanism (MTOM)
- Hypertext Transfer Protocol (HTTP)
- Universal Description, Discovery, and Integration (UDDI)
- Web Service Definition Language (WSDL)
- Web service Discovery Tool (DISCO)
Web services are a vast topic, but the above described are the most commonly asked questions for Java Web Services interviews. Some other simple questions are prepared while learning the course. One should recall the following concepts before going for the interview:
- Basics About Java Language
- Features of Web Services
- Annotations Used in Different APIs
- Difference Between API and Web Services
By learning the answers to the questions mentioned above and recalling all other concepts, the interview would be a success for sure.
Best of luck!