Test the WebService interface tool

Test webservice interface tool, download link:

http://download.csdn.net/download/heqinghua217/9934135

[WebService] interface test method

There are many ways as follows:

First, use the WSCaller.jar tool to test: p>

Prerequisite: Know the url of wsdl.

The release method of wsCaller executable program is a wsCaller.jar package, which does not include the Java runtime environment. You can copy wsCaller.jar to any computer with Java runtime environment (JRE/JDK 1.3.1 or higher is required), and run wsCaller with the following command:

java -jarwsCaller.jar

The method of using wsCaller software is very simple. Here is the main interface of wsCaller:

First enter the WSDL Location input box you want to call or test The WSDL location of the Web Service, such as “http://www.somesite.com/axis/services/StockQuoteService?wsdl”, and then click the “Find” button. wsCaller will check the URL address you entered and get the WSDL information of the Web Service. If the information is successfully obtained, wsCaller will list the Web Service and all the callable methods in the service provided in the Service and Operation drop-down list boxes. You can select the name of the method you want to call or test in the list box. After selection, the parameter list box in the middle of the wsCaller window will list all the parameters of the method, including the name, type and parameter value input of each parameter Box (only input boxes are provided for [IN] or [IN, OUT] type parameters). You can enter the value of each parameter. As shown in the figure below:

At this time, if you want to call the method and view its results, just click the “Invoke” button below. If you want to test the execution time of the method, you can specify the number of repeated calls in the “Invoke Times” box, and then press the “Invoke” button. wsCaller will automatically call the method you specify. If the call is successful, wsCaller will display the result dialog box, which includes the total time spent calling the method, the average time of each call and the return value of the method (including the return value and all output Type parameters). As shown below:

The wsCaller software is developed based on the Axis library (Apache eXtensible Interaction System). For the introduction of the Axis library and its copyright information, please refer to the Apache Software Foundation website http://www.apache.org/.

Second, write java Main() function, create XFireProxyFactory to call the declared Interface interface function.

Prerequisite: know the url of wsdl, know the interface (method) declaration of the webservice program.

Example:

public static voidmain(String[] args) {
Service srvcModel = new ObjectServiceFactory()
.create(IHelloWorldService.class);
XFireProxyFactory factory = new XFireProxyFactory(XFireFactory
.newInstance().getXFire());

StringhelloWorldURL = “http://99.48.225.100:9999/ WS/services/HelloWorldService“;
try {
IHelloWorldService srvc = (IHelloWorldService)factory.create(
srvcModel, helloWorldURL);
System.out.print(srvc.example( “dennis”));
catch (MalformedURLException e) {
e.printStackTrace();
}

}

3. Use the Eclipse wizard to generate a client calling program for webservice.

Prerequisite: know the url of wsdl, know the interface (method) declaration of the webservice program.

Steps:

1) Add the Xfire plug-in in Eclipse:

In the plugins of the Eclipse installation directory, include:

org .codehaus.xfire.eclipse.ui_1.0.2.xfire126.jar,

org.codehaus.xfire.eclipse.ui.wizards_1.0.2.xfire126.jar,

org.codehaus .xfire.eclipse.core_1.0.2.xfire126.jar

In the features of the Eclipse installation directory contains:

org.codehaus.xfire.eclipse_1.0.2.xfire126

2) Create a Web Project project in Eclipse and set it as the WSClient project name.

At the same time, right click on the project and add Xfire nature.

3) Create a Web Service Client file group under the WSClient project [or a file group of Code Generation from WSDL document! ].

Click the right button of the project, new–“other–“…

Enter the webservice url, such as: http:/ /localhost:9999/WS/services/HelloWorldService?wsdl

Choose the directory where the generated files are placed. Complete generation!

4) Modify the files in the generated file group: main function in ****client.java.

For example: the generated file is BizRemoteServiceClient.java, in the main function Found in:

BizRemoteServiceSoapbizRemoteServiceSoap = client.getBizRemoteServiceSoapLocalEndpoint();

This statement can be replaced by BizRemoteServiceSoap bizRemoteServiceSoap = client.getBizRemoteServiceSoap();!

public static voidmain(String[] args) {

BizRemoteServiceClientclient = new BizRemoteServiceClient();

//create a default service endpoint
//BizRemoteServiceSoap bizRemoteServiceSoap =client.getBizRemoteServiceSoapLocalEndpoint();

BizRemoteServiceSoapbizRemoteServiceSoap = client.getBizRemoteServiceSoap();

custom//TODO:Add client code/< /
//bizRemoteServiceSoap.yourServiceOperationHere();

MyResponseMyResponse=bizRemoteServiceSoap.login(“ivy1”, “111”);
System.out.println(MyResponse.getFlag());
System.out.println(MyResponse.getDetail());
System.out.println(“test client completed”);
System.exit(0);
}< /p>

The green code part is the test code added according to the test business logic! It depends on the specific test task!

Run the main function directly and see the result!

Leave a Comment

Your email address will not be published.