|
|
XFire is a next-generation Java SOAP framework from Codehaus. It makes the service-oriented development approachable through its easy-to-use APIs and the support of the Web Service standards. Using XFire framework to develop clients for Web Service requires JDK 5.0 or higher. Additionally, XFire provides the tools to generate Java code from WSDL files or a URL.
In the following tutorial, we use Eclipse as the development tools with XFire plug-ins. The XFire plug-ins can be downloaded from http://xfire.codehaus.org/Eclipse+Plugin. To develop a client application with WebExronos service requires two steps:
Step 1: Create a new project or select a current project. The designated project will be the client of WebExronos service.
Step 2: Import the WSDL file from the URL using XFire tools. The tool will create the client classes according to the WSDL file. If you have installed the XFire plug-ins for Eclipse, it is easy to import the WSDL file to generate from WSDL document.
After the WSDL file is imported and the Java files are created, you can use them as normal local Java files and invoke them easily. Below is a code sample for the login invoke:
//
Create the service port
CronosClient
client = new
CronosClient();
CronosPortType service = client.getCronosHttpPort();
//
Create the ObjectFactory instance of the
//
com.webex.webapp.webexronos.bean.ObjectFactory
ObjectFactory
of = new
ObjectFactory();
//
Login to the service
//
Construct the request object
Below is a code sample for the schedule function:
//
Schedule a trigger
//
Create and fill the request object
TimeSchedule schedule = of.createTimeSchedule();
schedule.setCronExpression(of
.createTimeScheduleCronExpression("* 0/15 * * *
?"));
CallBack callBack = of.createCallBack();
callBack.setCallBackType(of.createCallBackCallBackType("HTTP"));
KeyPair pair = of.createKeyPair();
pair.setKey(of.createKeyPairKey("urlString"));
pair.setValue(of.createKeyPairValue("http://www.samples.com"));
ArrayOfKeyPair aok = of.createArrayOfKeyPair();
aok.getKeyPair().add(pair);
callBack.setCallBackParams(of.createCallBackCallBackParams(aok));
// Call the service and
fetch the result
ScheduleResult
result = service.schedule(schedule, callBack, identity);
// Get the return
information from result
String
jobName = result.getJobName().getValue();