I was trying to expose some methods on a Seam component as web services using the @WebMethod annotations as per the JBoss WS documentation. It almost worked, except that the web service called a non-instantiated class, so all the seam stuff didn't work. Which makes sense. (It's my first time making a web service).
At any rate, I then tried using the following code:
Class[] args1 = new Class[2];
args1[0] = String.class;
args1[1] = String.class;
String[] zipsArray = new String[2];
zipsArray[0] = pZip1;
zipsArray[1] = pZip2;
Component comp = Seam.componentForName("carbonCalculator");
Double cost = 0.0;
try {
cost = (Double) comp.callComponentMethod(comp, CarbonCalculator.class.getMethod("calculateCost", args1),
(Object[]) zipsArray);
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchMethodException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return cost;