Software Testing Class

Web Service Sample Project & Testing

In this tutorial, we are going to develop a beginner’s level Web Service sample project testing using SOAP protocol for both RPC and Document style and after that, we will learn how to test it. Later in this tutorial series, we will learn about Web services based on the REST protocol.

Web Service Sample Project: (SOAP Protocol):

Web Service Testing Sample Project
Web service sample project testing

Software Requirements: Below are the basic requirements to build a Web service project in JAVA.

Project on SOAP Web Service using Document Style:

The project file for SOAP Web Service as “webservice-project-doc-style” can be downloaded from here. Below are the steps and explanations to run the SOAP Web Service.

  1. Firstly, create a JAVA interface that has a business method definition in it. In order to associate this interface with Webservice, use annotations “@WebService” and “SOAPBinding (style=Style.DOCUMENT) ” as I have demonstrated in the project.
  2. Secondly, create a class implementing the above interface and its business method. Similarly, in order to associate it with Webservice, use annotations “@WebService with endpoint interface location” and “SOAPBinding (style=Style.DOCUMENT)” as demonstrated in the project.
  3. Thirdly, publish this web service to expose the business logic.
  4. Once published, WSDL can be obtained at this link. http://localhost:8074/web?wsdl
  5. Now create a client class through which this service business method can be obtained to execute the business logic. Web Service client class uses the above WSDL URL to access WSDL and then obtains the qualifying name for the target namespace and web service name. Using both service method port is accessed and this is the procedure to call the web service as a client.

All above steps are demonstrated in the Web Service project for DOCUMENT style.

Project on SOAP Web Service using RPC Style:

Attached project file for SOAP Web Service as “webservice-project-rpc-style” which can be downloaded from here. Below are the steps and explanations to run the SOAP Web Service.

RPC Style WSDL:

[Click below image to enlarge]

Document Style WSDL:

[Click below image to enlarge]

Comparison between Document and RPC Style:

PropertiesRPC StyleDocument Style
DescriptionRPC Style generates the XML structure using method name and parameters.Document Style uses single XML document with XSD schema for its validation.
WSDL validationWSDL generated here is difficult to get validated against schema.WSDL generated can be validated against preferred schema with ease.
SOAP MessageSOAP message is sent as many elements in RPC style Web service.SOAP message is sent as a single document in Document style Web service.
Coupling complexitiesIt is tightly coupledIt is loosely coupled.
Operation nameIn RPC style Web services, SOAP message keeps the operation name.In Document Style Web Services, SOAP messages lose the operation name.
ParametersParameters are sent as discrete values.Parameters are sent in XML format.
WSDL file information about typesIt does not specifies any information about types (namespaces and schemaLocation)It specifies details about namespaces and schemaLocation
Message Part BodyIt defines name and type attributes in WSDL file for message part body.It defines name and element attributes in WSDL file for message part body.
Soap BodyIt defines use and namespace attributes in saop: body.It defines use attributes only, no namespaces are defined in saop: body.
WSDL snapshotsRPC style WSDL added above for comparison.Document style WSDL added above for comparison.

Pros and Cons of SOAP Web Service:

Pros:

Cones:

Over to you:

In the above tutorial we learnt about how to build SOAP Web services using both styles RPC and DOCUMENT style. Now next in this tutorial we will discuss about the web service testing.

Web Service Testing: In the last tutorials, we discussed the SoapUI tool which is used to test the web services and Web APIs and the testing steps which are actually involved in the web services testing. Here, we are going to discuss those steps in detail with the help of the above sample Web Service project.

These are the fundamental testing aspects to test any Web service, no matter which style it is written into. In our next tutorial series we are going to discuss on how to test WebService using SoapUI tool. Also for which we will first learn to install and configure SoapUI tool.

In next article we are going to cover “Tutorial 4 – Installation and configuration of SoapUI“.


⇓ Subscribe Us ⇓


If you are not regular reader of this website then highly recommends you to Sign up for our free email newsletter!! Sign up just providing your email address below:


 

Check email in your inbox for confirmation to get latest updates Software Testing for free.


  Happy Testing!!!
 
Exit mobile version