adding in src/main/java/... the bean:
@Stateless
public class RedBean {
public String foo() {
return "foo";
}
}
and updating the webservice like it:
@Stateless
@WebService(
portName = "CalculatorPort",
serviceName = "CalculatorService",
targetNamespace = "http://superbiz.org/wsdl",
endpointInterface = "org.superbiz.calculator.ws.CalculatorWs")
public class Calculator implements CalculatorWs {
@EJB
private RedBean bean;
public int sum(int add1, int add2) {
return add1 + add2;
}
public int multiply(int mul1, int mul2) {
return mul1 * mul2;
}
public String demo() {
return bean.foo();
}
}
and finally updating the test:
public class CalculatorTest {
@BeforeClass
public static void setUp() throws Exception {
Properties properties = new Properties();
properties.setProperty("openejb.embedded.remotable", "true");
// properties.setProperty("httpejbd.print", "true");
// properties.setProperty("httpejbd.indent.xml", "true");
// properties.setProperty("logging.level.OpenEJB.server.http",
"FINE");
EJBContainer.createEJBContainer(properties);
}
@Test
public void test() throws Exception {
Service calculatorService = Service.create(
new URL("
http://127.0.0.1:4204/simple-webservice/Calculator?wsdl"),
new QName("http://superbiz.org/wsdl", "CalculatorService"));
assertNotNull(calculatorService);
CalculatorWs calculator =
calculatorService.getPort(CalculatorWs.class);
assertEquals(10, calculator.sum(4, 6));
assertEquals(12, calculator.multiply(3, 4));
assertEquals("foo", calculator.demo());
}
}
works
- Romain
2012/3/14 slawek <[email protected]>
> Simply incjection doesn't work too - while starting server there is error
> that class .......RedBean is not found. But i can invoke red bean using
> openejb jsp page.
>
> Best Regards
> sw
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/ejb-from-ws-tp4470387p4471542.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>