How to test Web services .3

-> full text Word Count: 2254, you need to take a few minutes reading time, you can also collection, and re-read when sufficient time -


-> Section I talked about "Web services infrastructure introduction" , Section II talked about "Web Services Test Tool"

-> This section describes the Web service project and test samples.

A .Web Services sample project: (SOAP protocol)

SOAP is an XML-based protocol:

  • Full form of SOAP is the Simple Object Access Protocol.

  • For communication between two applications cross-platform, SOAP is a W3C recommendation.

  • SOAP is platform-independent programming language and protocol.

Software requirements: The following is to build Web services projects in JAVA basic requirements:

  • Jre1.8.0_25 as JAVA runtime environment.

  • Eclipse IDE as a development tool.

  • A standard HTTP browser, such as Chrome and so on. This will help to view the WSDL.

 

II. Use document-style SOAP Web Service project

Data from the menu [material] - [source material] get at the SOAP Web Service project file in the format "webservice-project-doc-style". Here are the steps and instructions for running SOAP Web services:

 

  1. First, create a JAVA interface to have business methods defined. In order to be associated with this Web service interfaces, use the demo I had in the project Notes "@WebService" and "SOAPBinding (style = Style.DOCUMENT)".

  2. Second, create a class that implements the above interfaces and business methods. Similarly, in order to associate it with a Web service, using annotations "@WebService interface position" and "SOAPBinding (style = Style.DOCUMENT)", as shown in the project.

  3. Third, publish this Web service to expose business logic.

  4. Once published, you can get WSDL on this link. HTTP: // localhost: 8074 / WSDL Network

  5. Now create a client class, business methods can obtain this service by the client class to perform the business logic. Web Service client classes using the WSDL URL to access WSDL, then get qualified name of the target namespace and Web Service name. Using these two methods can access the service port, which is the process of Web services as a client call.

All of these steps in the Web Service project in a demonstration with DOCUMENT style.

 

III. Use RPC-style SOAP Web Services

SOAP Web Service project files as attachments "webservice-project-rpc-style", material information from the menu [] - [] at the source material acquisition. Here are the steps and instructions for running SOAP Web services:

  • First, create a JAVA interface to have business methods defined. In order to be associated with this Web service interfaces, use the comment "@WebService" and "SOAPBinding (style = Style.RPC)".

  • Second, create a class that implements the above interfaces and business methods. Similarly, in order to be associated with a Web service, use the annotation "@WebService and endpoint interface position" and "SOAPBinding (style = Style.RPC)".

  • Third, publish this Web service to expose business logic.

  • Once published, you can get WSDL on this link. HTTP: // localhost: 8075 / WSDL Network

  • Now create a client class, business methods can obtain this service by the client class to perform the business logic. Web Service client classes using the WSDL URL to access WSDL, then get qualified name of the target namespace and Web Service name. Using these two methods can access the service port, which is the process of Web services as a client call.

  • In the RPC-style Web service project, it demonstrates all the steps above.

RPC style WSDL:

 

Document style WSDL:

 

IV. Documentation and RPC-style differences

 

 V.  advantages and disadvantages of SOAP Web services

advantage:

  • SOAP has its own built-in security, known as WS-Security, and therefore highly protected.

  • As mentioned above, you can use any programming language (such as .Net, JAVA, etc.) to build SOAP Web services, and cross-platform execution.

Disadvantages:

  • Because SOAP Web services are XML-based format, it is necessary to read and parse XML documents. The most important is the need to follow many standard definition when building such a Web service. This slows down the speed SOAP Web services, and take up more bandwidth and resources.

  • WSDL is the only mechanism for positioning SOAP Web services. So it's not very flexible.

 

VI.  For information about Web services testing

 

Above, we learned how to use style RPC and DOCUMENT-style building SOAP Web Services; then we will discuss information about Web services testing.

 

Web services testing : two in the previous chapter, we discussed SoapUI tool for testing Web services and Web API and Web service test test steps actually involved. Here, we will discuss these steps in more detail with the help of the above sample Web service project:

 

  • WSDL file defines understand: After creating WDSL using Web services, will be required to write test cases to test WSDL standards exist, such as what kind of style it? Cover all the necessary input parameters? What type of data these input parameters is? and many more

  • Web Service operations provided by: test cases covering the necessary operations for the development of Web Service exists. Whether it is the right way to cover the required business logic?

  • XML SOAP request message sent as a request message format: test case covering the input data, the data type, the boundary conditions are verified, authentication stack overflow, function test and the like.

  • SOAP response received in the form of an XML message in response to message format: test covers the output data and the type of output data verification, authentication stack overflow, security testing, functional test cases and the like.

  • A simple local tool or a test program, can send XML message request and in the form of an XML message in response to receiving the request: This refers to test the WebService, we need to develop a client process, we can enter data through the program as a request and the test output data received as a response.

The basic test is to test any Web service, whether it is written in what style. Later, we will discuss how to use the tool to test SoapUI WebService. In addition, we will first of all learn to install and configure the tool SoapUI

 

Guess you like

Origin www.cnblogs.com/VVsky/p/11812383.html