HP Integrity NonStop H-Series User Manual

Page 431

Advertising
background image

int choice=scan.nextInt();
if (choice==1 )
{
opts.setAction("urn:insertDetail");
client.setOptions(opts);
client.sendRobust(createPayLoad1());
System.out.println("Request Sent Successfully");
}
else if (choice==2 )
{ opts.setAction("urn:getDetail");
client.setOptions(opts);
OMElement res2 = client.sendReceive(createPayLoad2());
System.out.println(res2);
}
else if (choice==3)
{
opts.setAction("urn:deleteEmployee");
client.setOptions(opts);
OMElement res3 = client.sendReceive(createPayLoad3());
System.out.println(res3);
}
System.out.println("Do You Wish To Continue: Press Y for Yes ");
a = scan.next();
}
while(a.equalsIgnoreCase("Y"));
}
public static OMElement createPayLoad1() {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace(
"http://service.empinfo.hp.com", "com");
OMElement method = fac.createOMElement("insertDetail", omNs);
OMElement element1 = fac.createOMElement("empid", omNs);
Scanner scan=new Scanner(System.in);
System.out.println("Enter Employee Id :");
element1.setText(""+scan.nextInt());
System.out.println("Enter First Name :");
OMElement element2 = fac.createOMElement("firstname", omNs);
element2.setText(scan.next());
System.out.println("Enter Last Name :");
OMElement element3 = fac.createOMElement("lastname", omNs);
element3.setText(scan.next());
System.out.println("Enter Age :");
OMElement element4 = fac.createOMElement("age", omNs);
element4.setText(""+scan.nextInt());
System.out.println("Enter Email :");
OMElement element5 = fac.createOMElement("email", omNs);
element5.setText(scan.next());
method.addChild(element1);
method.addChild(element2);
method.addChild(element3);
method.addChild(element4);
method.addChild(element5);
return method;

}
public static OMElement createPayLoad2() {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace(
"http://service.empinfo.hp.com", "com");

OMElement method = fac.createOMElement("getDetail", omNs);
Scanner scan=new Scanner(System.in);
System.out.println("Enter Employee Id :");
OMElement element = fac.createOMElement("empid", omNs);
element.setText(""+scan.nextInt());
method.addChild(element);

return method;

}
public static OMElement createPayLoad3() {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace(
"http://service.empinfo.hp.com", "com");

OMElement method = fac.createOMElement("deleteEmployee", omNs);
Scanner scan=new Scanner(System.in);
System.out.println("Enter Employee Id :");
OMElement element = fac.createOMElement("empid", omNs);
element.setText(""+scan.nextInt());
method.addChild(element);

return method;

}
}

Example of Integrating Axis2/Java with Spring

431

Advertising
This manual is related to the following products: