Monday, 17 October 2011

Tomcat + Axis2 + Eclipse + Axis2 Code Gen Part 5

Part 5 Create a Tester program.


Create a new java class from HookInForestWSClient project.



Key in the class name as HookInForestWSTester and click on Finish button.






Copy and paste the below coding into the java class.



import org.apache.axis2.AxisFault;


import hookinforest.service.FTPAlternativeServiceStub;
import hookinforest.service.FTPAlternativeServiceStub.FTPAlternativeVO;
import hookinforest.service.FTPAlternativeServiceStub.GenerateFile;
import hookinforest.service.FTPAlternativeServiceStub.GenerateFileResponse;


public class HookInForestWSTester {
public static void main(String[] args) {
try {

FTPAlternativeServiceStub ftpAlternativeServiceStub = new FTPAlternativeServiceStub();
GenerateFile generateFile = new GenerateFile();
FTPAlternativeVO ftpAlternativeVO = new FTPAlternativeVO();
ftpAlternativeVO.setTicketPath("c:/HookInForestWSTesting.txt");
ftpAlternativeVO.setTicketContent("This is a test");
generateFile.setArgs0(ftpAlternativeVO);
GenerateFileResponse generateFileResponse = new GenerateFileResponse();
generateFileResponse = ftpAlternativeServiceStub.generateFile(generateFile);
   System.out.println("Call Result : "+ generateFileResponse.get_return().getStatus());
} catch (AxisFault e) {
e.printStackTrace();
}catch(Exception e)
{
e.printStackTrace();
}
}
}

Right click the source code and run as java application.


If you see the message "Call Result : true" from console, that means you have successfully run the tester application.

Go to C drive and check, you should able to find the HookInForestWSTesting.txt at there.


No comments:

Post a Comment