Emkay-Webdesign

Top 34 Web Services Interview Questions

Welcome to the Web Services Interview Questions  with detailed answers. Just recently I have written a lot about web services. How we can develop SOAP and Relaxing web services in Java.

Here I am offering you a list of web services interview questions to help you in interview. Firstly there are generic concerns for web services principle because it’s not innovation or language particular and after that we have java web services interview questions.

  1. What is a Web Service?
  2. What are the advantages of Web Services?
  3. What are various kinds of Web Providers?
  4. What is SOAP?
  5. What are benefits of SOAP Web Services?
  6. What are downsides of SOAP Web Solutions?
  7. What is WSDL?
  8. What are various parts of WSDL?
  9. What is UDDI?
  10. What is difference between Top Down and Bottom Up technique in SOAP Web Services?
  11. What is REST Web Solutions?
  12. What are benefits of REST web services?
  13. What are downsides of REST web services?
  14. What is a Resource in Restful web services?
  15. What are various HTTP Methods supported in Restful Web Providers?
  16. Compare SOAP and REST web services?
  17. What are various methods to check web services?
  18. Can we keep user session in web services?
  19. What is difference between SOA and Web Solutions?
  20. What is the use of Accept and Content-Type Headers in HTTP Demand?
  21. How would you pick between SOAP and REST web services?
  22. What is JAX-WS API?
  23. Name some frameworks in Java to implement SOAP web services?
  24. Name important annotations utilized in JAX-WS API?
  25. What is use of javax.xml.ws. Endpoint class?
  26. What is the distinction between RPC Design and File Style SOAP web Providers?
  27. How to get WSDL file of a SOAP web service?
  28. What is sun-jaxws. xml file?
  29. What is JAX-RS API?
  30. Call some implementations of JAX-RS API?
  31. What is wsimport utility?
  32. Name important annotations utilized in JAX-RS API?
  33. What is making use of @XmlRootElement annotation?
  34. How to set various status code in HTTP action?

 

       1. What is a Web Service?

 

Web Solutions deal with client-server design where customer applications can access web services over the network. Web services offer endpoint URLs and expose methods that can be accessed over network through customer programs written in java, shell script or any other different innovations.

Web services are stateless and doesn’t keep user session like web applications.

 

       2. What are the advantages of Web Services?

A few of the advantages of web services are:

  • Interoperability: Web services are accessible over network and runs on HTTP/SOAP procedure and uses XML/JSON to carry information, thus it can be established in any programs language. Web service can be written in java shows and client can be PHP and vice versa.
  • Reusability: One web service can be utilized by lots of customer applications at the same time.
  • Loose Coupling: Web services client code is absolutely independent with server code, so we have actually achieved loose coupling in our application.
  • Easy to release and integrate, similar to web applications.
  • Multiple service variations can be performing at exact same time.

 

        3. What are various kinds of Web Providers?

There are 2 kinds of web services:

  1. SOAP Web Services: Runs on SOAP procedure and utilizes XML innovation for sending out data.
  2. Relaxing Web Solutions: It’s an architectural design and runs on HTTP/HTTPS procedure almost all the time. REST is a stateless client-server architecture where web services are resources and can be recognized by their URIs. Client applications can utilize HTTP GET/POST methods to invoke Relaxing web services.

      4. What is SOAP?

SOAP stands for Simple Things Gain Access To Protocol. SOAP is an XML based industry standard procedure for developing and establishing web services. Considering that it’s XML based, it’s platform and language independent. So our server can be based upon JAVA and customer can be on.NET, PHP etc. and vice versa.

soap interview question

         5. What are benefits of SOAP Web Services?

SOAP web services have all the advantages that web services has, a few of the extra advantages are:

  • WSDL document provides agreement and technical information of the web services for client applications without exposing the underlying implementation innovations.
  • SOAP utilizes XML information for payload along with agreement, so it can be easily read by any technology.
  • SOAP procedure is generally accepted, so it’s an industry standard technique with numerous quickly offered open source applications.

           6.  What are downsides of SOAP Web Solutions?

Some of the downsides of SOAP procedure are:

  • Only XML can be used, JSON and other lightweight formats are not supported.
  • SOAP is based on the agreement, so there is a tight coupling between client and server applications.
  • SOAP is slow since payload is big for an easy string message, given that it uses XML format.
  • Anytime there is change in the server side agreement, client stub classes require to be created once again.
  • Can’t be checked quickly in internet browser

          7. What is WSDL?

WSDL means Web Service Description Language. WSDL is an XML based file that provides technical information about the web service. Some of the useful information in WSDL file are: approach name, port types, service end point, binding, method specifications etc.

          8. What are various parts of WSDL?

A few of the various tags in WSDL xml are:

  • xsd: import namespace and schemaLocation: provides WSDL URL and unique namespace for web service.
  • message: for method arguments
  • part: for approach argument name and type
  • portType: service name, there can be numerous services in a wsdl file.
  • operation: includes technique name
  • soap: address for endpoint URL.

         9. What is UDDI?

UDDI is acronym for Universal Description, Discovery and Combination. UDDI is a directory of web services where client applications can lookup for web services. Web Providers can sign up to the UDDI server and make them available to client applications.

        10. What is difference between Top Down and Bottom Up technique in SOAP Web Services?

In Leading Down approach very first WSDL file is produced to establish the agreement in between web service and client and after that code is composed, it’s also called as agreement first method. This is difficult to execute because classes need to be written to validate the agreement developed in WSDL. Advantage of this method is that both client and server code can be written in parallel.

In Bottom Up approach, first web service code is written and then WSDL is generated. It’s likewise called as agreement last method. This technique is simple to execute due to the fact that WSDL is created based on code. In this approach client code need to wait for WSDL from server side to start their work.

       11. What is REST Web Solutions?

REST is the acronym for REpresentational State Transfer. REST is an architectural design for establishing applications that can be accessed over the network. REST architectural design was generated light by Roy Fielding in his doctoral thesis in 2000.

REST is a stateless client-server architecture where web services are resources and can be recognized by their URIs. Client applications can utilize HTTP GET/POST techniques to conjure up Restful web services. REST doesn’t specify any specific procedure to use, but in almost all cases it’s utilized over HTTP/HTTPS. When compared to SOAP web services, these are light-weight and does not follow any requirement. We can utilize XML, JSON, text or any other type of information for demand and response.

rest security interview questions

         12. What are benefits of REST web services?

A few of the benefits of REST web services are:

  • Learning curve is easy because it deals with HTTP protocol
  • Supports numerous innovations for information transfer such as text, xml, json, image etc.
  • No contract defined in between server and customer, so loosely combined implementation.
  • REST is a light-weight protocol
  • REST methods can be tested easily over browser.

        13.  What are downsides of REST web services?

Some of the disadvantages of REST are:

  • Given that there is no agreement specified in between service and customer, it has to be interacted through other methods such as paperwork or emails.
  • Considering that it deals with HTTP, there can’t be asynchronous calls.
  • Sessions can’t be maintained.

       14. What is a Resource in Restful web services?

Resource is the fundamental idea of Restful architecture. A resource is an item with a type, relationship with other resources and techniques that operate on it. Resources are identified with their URI, HTTP methods they support and request/response information type and format of data.

        15. What are various HTTP Methods supported in Restful Web Providers?

Relaxing web services supported HTTP methods are – GET, PUBLISH, PUT, DELETE and HEAD.

        16. Compare SOAP and REST web services?

soap and rest web services interview questions

        17. What are various methods to check web services?

SOAP web services can be checked programmatically by creating client stubs from WSDL or through software application such as Soap UI.

REST web services can be evaluated quickly with program, curl commands and through internet browser extensions. Resources supporting GET technique can be tested with internet browser itself, with no program.

      18.  Can we keep user session in web services?

Web services are stateless so we can’t keep user sessions in web services.

      19. What is difference between SOA and Web Solutions?

Service Oriented Architecture (SOA) is an architectural pattern where applications are created in regards to services that can be accessed through interaction protocol over network. SOA is a style pattern and does not go into application.

Web Services can be considered Providers in SOAP architecture and supplying methods to implement SOA pattern.

       20. What is the use of Accept and Content-Type Headers in HTTP Demand?

These are important headers in Relaxing web services. Accept headers tells web service what sort of response client is accepting, so if a web service is capable of sending action in XML and JSON format and client sends Accept header as “application/xml” then XML reaction will be sent. For Accept header “application/json”, server will send the JSON reaction.

Content-Type header is used to inform server what is the format of data being sent in the request. If Content-Type header is “application/xml” then server will try to parse it as XML data. This header works in HTTP Post and Put demands.

         21. How would you pick between SOAP and REST web services?

Web Solutions deal with client-server design and when it comes to choose in between SOAP and REST, everything depends upon job requirements. Let’s take a look at a few of the conditions impacting our choice:

  • Do you know your web service customers beforehand? If Yes, then you can define a contract before application and SOAP seems better choice. But if you don’t then REST appears much better choice since you can supply sample request/response and test cases easily for customer applications to use later.
  • How much time you have? For fast execution REST is the very best choice. You can produce web service easily, test it through browser/curl and prepare yourself for your clients.
  • What type of data format are supported? If only XML then you can go with SOAP however if you think about supporting JSON also in future then go with REST.

       22. What is JAX-WS API?

JAX-WS represents Java API for XML Web Solutions. JAX-WS is XML based Java API to develop web services server and customer application. It’s part of basic Java API, so we don’t require to include anything else which dealing with it. Describe JAX-WS Tutorial for a complete example.

       23. Name some frameworks in Java to implement SOAP web services?

We can develop SOAP web services using JAX-WS API, nevertheless some of the other structures that can be used are Apache Axis and Apache CXF. Keep in mind that they are not implementations of JAX-WS API, they are completely different framework that deal with Servlet model to expose your company reasoning classes as SOAP web services. Learn more at Java SOAP Web Service Eclipse example.

        24. Name important annotations utilized in JAX-WS API?

A few of the crucial annotations utilized in JAX-WS API are:

  •  @WebService.
  •  @SOAPBinding.
  •  @WebMethod.

        25. What is use of javax.xml.ws.Endpoint class?

Endpoint class provides helpful approaches to create endpoint and publish existing implementation as web service. This comes helpful in screening web services before making additional changes to release it on real server.

        26. What is the distinction between RPC Design and File Style SOAP web Providers?

RPC design generate WSDL document based on the method name and it’s criteria. No type definitions exist in WSDL file.

Document design includes type and can be verified against predefined schema. Let’s take a look at these with an easy program. Below is a simple test program where I am utilizing Endpoint to publish my simple SOAP web service.

TestService.java.

plan com.journaldev.jaxws.service;.

import javax.jws.WebMethod;.

import javax.jws.WebService;.

import javax.jws.soap.SOAPBinding;.

import javax.xml.ws.Endpoint;.

@WebService.

@SOAPBinding( design = SOAPBinding.Style.RPC).

public class TestService

When I run above program and then gain access to the WSDL, it offers me listed below XML.

rpc.xml.

<?xml version=’1.0′ encoding=’UTF-8′?>

<!– Published by JAX-WS RI (http://jax-ws.java.net). RI’s version is JAX-WS RI 2.2.10 svn-revision#919b322c92f13ad085a933e8dd6dd35d4947364b. –><!– Generated by JAX-WS RI (http://jax-ws.java.net). RI’s version is JAX-WS RI 2.2.10 svn-revision#919b322c92f13ad085a933e8dd6dd35d4947364b. –>

<definitions xmlns:wsu=”http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd” xmlns:wsp=”http://www.w3.org/ns/ws-policy” xmlns:wsp1_2=”http://schemas.xmlsoap.org/ws/2004/09/policy” xmlns:wsam=”http://www.w3.org/2007/05/addressing/metadata” xmlns:soap=”http://schemas.xmlsoap.org/wsdl/soap/” xmlns:tns=”http://service.jaxws.journaldev.com/” xmlns:xsd=”http://www.w3.org/2001/XMLSchema” xmlns=”http://schemas.xmlsoap.org/wsdl/” targetNamespace=”http://service.jaxws.journaldev.com/” name=”TestServiceService”>

<types/>

<message name=”sayHello”>

<part name=”arg0″ type=”xsd:string”/>

</message>

<message name=”sayHelloResponse”>

<part name=”return” type=”xsd:string”/>

</message>

<portType name=”TestService”>

<operation name=”sayHello”>

<input wsam:Action=”http://service.jaxws.journaldev.com/TestService/sayHelloRequest” message=”tns:sayHello”/>

<output wsam:Action=”http://service.jaxws.journaldev.com/TestService/sayHelloResponse” message=”tns:sayHelloResponse”/>

</operation>

</portType>

<binding name=”TestServicePortBinding” type=”tns:TestService”>

<soap:binding transport=”http://schemas.xmlsoap.org/soap/http” style=”rpc”/>

<operation name=”sayHello”>

<soap:operation soapAction=””/>

<input>

<soap:body use=”literal” namespace=”http://service.jaxws.journaldev.com/”/>

</input>

<output>

<soap:body use=”literal” namespace=”http://service.jaxws.journaldev.com/”/>

</output>

</operation>

</binding>

<service name=”TestServiceService”>

<port name=”TestServicePort” binding=”tns:TestServicePortBinding”>

<soap:address location=”http://localhost:8888/testWS”/>

</port>

</service>

</definitions>

<!– Released by JAX-WS RI( http://jax-ws.java.net). RI’s version is JAX-WS RI 2.2.10 svn-revision # 919b322c92f13ad085a933e8dd6dd35d4947364b.– ><!– Generated by JAX-WS RI (http://jax-ws.java.net). RI’s

<?xml version=’1.0′ encoding=’UTF-8′?>

<!– Published by JAX-WS RI (http://jax-ws.java.net). RI’s version is JAX-WS RI 2.2.10 svn-revision#919b322c92f13ad085a933e8dd6dd35d4947364b. –><!– Generated by JAX-WS RI (http://jax-ws.java.net). RI’s version is JAX-WS RI 2.2.10 svn-revision#919b322c92f13ad085a933e8dd6dd35d4947364b. –>

<definitions xmlns:wsu=”http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd” xmlns:wsp=”http://www.w3.org/ns/ws-policy” xmlns:wsp1_2=”http://schemas.xmlsoap.org/ws/2004/09/policy” xmlns:wsam=”http://www.w3.org/2007/05/addressing/metadata” xmlns:soap=”http://schemas.xmlsoap.org/wsdl/soap/” xmlns:tns=”http://service.jaxws.journaldev.com/” xmlns:xsd=”http://www.w3.org/2001/XMLSchema” xmlns=”http://schemas.xmlsoap.org/wsdl/” targetNamespace=”http://service.jaxws.journaldev.com/” name=”TestServiceService”>

<types>

<xsd:schema>

<xsd:import namespace=”http://service.jaxws.journaldev.com/” schemaLocation=”http://localhost:8888/testWS?xsd=1″/>

</xsd:schema>

</types>

<message name=”sayHello”>

<part name=”parameters” element=”tns:sayHello”/>

</message>

<message name=”sayHelloResponse”>

<part name=”parameters” element=”tns:sayHelloResponse”/>

</message>

<portType name=”TestService”>

<operation name=”sayHello”>

<input wsam:Action=”http://service.jaxws.journaldev.com/TestService/sayHelloRequest” message=”tns:sayHello”/>

<output wsam:Action=”http://service.jaxws.journaldev.com/TestService/sayHelloResponse” message=”tns:sayHelloResponse”/>

</operation>

</portType>

<binding name=”TestServicePortBinding” type=”tns:TestService”>

<soap:binding transport=”http://schemas.xmlsoap.org/soap/http” style=”document”/>

<operation name=”sayHello”>

<soap:operation soapAction=””/>

<input>

<soap:body use=”literal”/>

</input>

<output>

<soap:body use=”literal”/>

</output>

</operation>

</binding>

<service name=”TestServiceService”>

<port name=”TestServicePort” binding=”tns:TestServicePortBinding”>

<soap:address location=”http://localhost:8888/testWS”/>

</port>

</service>

</definitions>

variation is JAX-WS RI 2.2.10 svn-revision # 919b322c92f13ad085a933e8dd6dd35d4947364b.– >< definitions xmlns: wsu=” http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd” xmlns: wsp=” http://www.w3.org/ns/ws-policy” xmlns: wsp1_2=

<!– Published by JAX-WS RI (http://jax-ws.java.net). RI’s version is JAX-WS RI 2.2.10 svn-revision#919b322c92f13ad085a933e8dd6dd35d4947364b. –>

<xs:schema xmlns:tns=”http://service.jaxws.journaldev.com/” xmlns:xs=”http://www.w3.org/2001/XMLSchema” version=”1.0″ targetNamespace=”http://service.jaxws.journaldev.com/”>

<xs:element name=”sayHello” type=”tns:sayHello”/>

<xs:element name=”sayHelloResponse” type=”tns:sayHelloResponse”/>

<xs:complexType name=”sayHello”>

<xs:sequence>

<xs:element name=”arg0″ type=”xs:string” minOccurs=”0″/>

</xs:sequence>

</xs:complexType>

<xs:complexType name=”sayHelloResponse”>

<xs:sequence>

<xs:element name=”return” type=”xs:string” minOccurs=”0″/>

</xs:sequence>

</xs:complexType>

</xs:schema>

” http://schemas.xmlsoap.org/ws/2004/09/policy” xmlns: wsam=” http://www.w3.org/2007/05/addressing/metadata” xmlns: soap=” http://schemas.xmlsoap.org/wsdl/soap/ “xmlns: tns=” http://service.jaxws.journaldev.com/” xmlns: xsd=” http://www.w3.org/2001/XMLSchema” xmlns=” http://schemas.xmlsoap.org/wsdl/ “targetNamespace=” http://service.jaxws.journaldev.com/” name=” TestServiceService” >< input wsam: Action=” http://service.jaxws.journaldev.com/TestService/sayHelloRequest” message=”

tns: sayHello”/ >< output wsam: Action =” http://service.jaxws.journaldev.com/TestService/sayHelloResponse “message=” tns: sayHelloResponse”/ > <binding name =” TestServicePortBinding” type =” tns: TestService “>< soap: binding transport=” http://schemas.xmlsoap.org/soap/http” style=

” rpc”/ > <soap: body usage=” actual” namespace =” http://service.jaxws.journaldev.com/”/ > <soap: body usage=” actual” namespace =” http://service.jaxws.journaldev.com/ “/ >< port name=” TestServicePort” binding =” tns: TestServicePortBinding” > <soap: address location=” http://localhost:8888/testWS”/ >

Notice that types aspect is empty and we can’t confirm it against any schema. Now simply alter the SOAPBinding.Style.RPC to SOAPBinding.Style.DOCUMENT and you will get below WSDL.

document.xml.<!– Published by JAX-WS RI( http://jax-ws.java.net). RI’s version is JAX-WS RI 2.2.10 svn-revision # 919b322c92f13ad085a933e8dd6dd35d4947364b.– ><!– Produced by JAX-WS RI( http://jax-ws.java.net). RI’s variation is JAX-WS RI 2.2.10 svn-revision # 919b322c92f13ad085a933e8dd6dd35d4947364b.– >< definitions xmlns: wsu =” http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd” xmlns: wsp=” http://www.w3.org/ns/ws-policy “xmlns: wsp1_2=” http://schemas.xmlsoap.org/ws/2004/09/policy” xmlns: wsam=” http://www.w3.org/2007/05/addressing/metadata” xmlns: soap= “http://schemas.xmlsoap.org/wsdl/soap/” xmlns: tns=” http://service.jaxws.journaldev.com/” xmlns: xsd= “http://www.w3.org/2001/XMLSchema” xmlns =” http://schemas.xmlsoap.org/wsdl/ “targetNamespace=” http://service.jaxws.journaldev.com/” name =” TestServiceService” >< xsd: import namespace= “http://service.jaxws.journaldev.com/” schemaLocation=” http://localhost:8888/testWS?xsd=1″/ >< part name= “criteria” aspect=” tns: sayHelloResponse”/ >< input wsam: Action=” http://service.jaxws.journaldev.com/TestService/sayHelloRequest” message= “tns: sayHello”/ > <output wsam: Action= “http://service.jaxws.journaldev.com/TestService/sayHelloResponse” message= “tns: sayHelloResponse”/ >< binding name=” TestServicePortBinding “type=” tns: TestService”

>< soap: binding transportation=” http://schemas.xmlsoap.org/soap/http” style=” document”/ >

<endpoints xmlns=”http://java.sun.com/xml/ns/jax-ws/ri/runtime” version=”2.0″>

<endpoint.

name=”PersonServiceImpl”

implementation=”com.journaldev.jaxws.service.PersonServiceImpl”

url-pattern=”/personWS”/>

</endpoints>

< port name=”TestServicePort” binding=”tns: TestServicePortBinding” > < soap: address area=”http://localhost:8888/testWS”/ >

Open schemaLocation URL in web browser and you will get listed below XML. schemaLocation.xml. <!– Published by JAX-WS RI (http://jax-ws.java.net). RI’s variation is JAX-WS RI 2.2.10 svn-revision # 919b322c92f13ad085a933e8dd6dd35d4947364b.– > < xs: schema xmlns: tns=”http://service.jaxws.journaldev.com/” xmlns: xs=”http://www.w3.org/2001/XMLSchema” variation=”1.0″ targetNamespace=”http://service.jaxws.journaldev.com/” > < xs: element name=”sayHelloResponse” type=”tns: sayHelloResponse”/ > < xs: element name=”arg0″ type=”xs: string” minOccurs=”0″/ > < xs: aspect name=”return” type=”xs: string” minOccurs=”0″/ >

So here WSDL file can be verified against the schema definintion.

     27. How to get WSDL file of a SOAP web service?

wsdl to the SOAP endoint URL. In above example, we can access it at http://localhost:8888/testWS?wsdl location.

      28. What is sun-jaxws. xml file?

This file is utilized to offer endpoints information when JAX-WS web services are deployed in servlet container such as Tomcat.

This file exists in WEB-INF directory site and includes endpoint name, implementation class and URL pattern. For example;

sun-jaxws. xml.

< endpoints xmlns=”http://java.sun.com/xml/ns/jax-ws/ri/runtime” version=”2.0″ > < endpoint. name=”PersonServiceImpl” application=”com.journaldev.jaxws.service. PersonServiceImpl” url-pattern =”/ personWS”/ ></endpoints>

     29. What is JAX-RS API?

Java API for RESTful Web Services( JAX-RS) is the Java API for developing REST web services. JAX-RS uses annotations to simplify the advancement and implementation of web services. JAX-RS becomes part of JDK, so you do not need to consist of anything to use it’s annotations.

     30. Call some implementations of JAX-RS API?

There are 2 major applications of JAX-RS API.

  1. Jersey: Jersey is the referral application provided by Sun. For using Jersey as our JAX-RS implementation, all we require to configure its servlet in web.xml and include needed reliances. Note that JAX-RS API is part of JDK not Jersey, so we need to include its reliance jars in our application.
  2. RESTEasy: RESTEasy is the JBoss task that provides JAX-RS execution.

    31. What is wsimport utility?

We can use wsimport utility to create the customer stubs. This energy features standard installation of JDK. Listed below image shows an example execution of this utility for one of JAX-WS project.

webservices in java interview questions

       32. Name important annotations utilized in JAX-RS API?

A few of the important JAX-RS annotations are:.

  •  @Path: utilized to specify the relative course of class and techniques. We can get the URI of a webservice by scanning the Course annotation worth.
  • @GET, @PUT, @POST, @DELETE and @HEAD: utilized to specify the HTTP demand type for an approach.
  • @Produces, @Consumes: used to define the demand and reaction types.
  •  @PathParam: utilized to bind the approach specification to course worth by parsing it.

        33. What is making use of @XmlRootElement annotation?

XmlRootElement annotation is utilized by JAXB to transform java challenge XML and vice versa. So we have to annotate model classes with this annotation.

        34. How to set various status code in HTTP action?

For setting HTTP status code aside from 200, we have to utilize javax.ws.rs.core.Response class for action. Below are some of the sample return statements showing it’s usage.

return Response.status( 422 ). entity( exception). build();.

return Response.ok( action). develop();// 200.

That’s all for web services interview concerns, let me know what you consider it through comments. If you believe that I have missed some crucial concerns, please let me understand through comments and I will more than happy to address them and add to the list.

 

 

Top 34 Web Services Interview Questions

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top
Adblock
detector