tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laird Nelson <ljnel...@gmail.com>
Subject More webservice woes
Date Mon, 13 Apr 2009 19:02:57 GMT
I finally understand the problem that David brought up several messages ago
(the specification anomaly regarding mixing @Remote and @WebService).

I *hope* that my latest problem has moved on past that.

David had confirmed that on the interface side of the house I can do this:

public interface SayHello {
  public String sayHello();
}

@Remote
public interface SayHelloRemote extends SayHello { }

@WebService(targetNamespace="http://foobar.net/wsdl")
public interface SayHelloWebService extends SayHello { }

...and that that is guaranteed to be portable across containers.

I am thinking that on the class side of the house I should be able,
therefore, to do this:

@WebService(
  portName = "SayHelloPort",
  serviceName = "SayHelloService",
  targetNamespace = "http://foobar.net/wsdl",
  endpointInterface = "net.foobar.SayHelloWebService"
)
@Stateless
public class SayHelloImpl implements SayHelloRemote, SayHelloWebService {

  @Override
  public String sayHello() {
    return "Hello!";
  }

}

...and that such a beast could therefore be exposed as both a stateless
session bean and a web service.

But when I then try to write one test case to exercise both of these
functions, like this:

  @Test
  public void testSLSB() throws Exception {
    assertNotNull(this.context);
    final Object o = this.context.lookup("SayHelloImplRemote");
    assertTrue(o instanceof SayHello);
    final SayHello sh = (SayHello)PortableRemoteObject.narrow(o,
SayHelloLocal.class);
    assertNotNull(sh);
    assertEquals("Hello!", sh.sayHello());
  }

  @Test
  public void testWebService() throws Exception {
    final Service sayHelloService = Service.create(new URL("
http://127.0.0.1:4204/SayHelloImpl?wsdl"), null);
    assertNotNull(sayHelloService);

    final Iterator<QName> ports = sayHelloService.getPorts();
    assertNotNull(ports);
    while (ports.hasNext()) {
      System.out.println(ports.next());
    }

    final SayHello sayHello =
sayHelloService.getPort(SayHelloWebService.class); // KABOOM
    assertNotNull(sayHello);
    assertEquals("Hello!", sayHello.sayHello());
  }

...the second test fails at the line marked KABOOM.  The failure in this
case is:
javax.xml.ws.WebServiceException:
org.apache.cxf.service.factory.ServiceConstructionException: Could not find
definition for service {http://foobar.net/wsdl}SayHelloWebServiceService.

The System.out.println() output is:
{http://jenzabar.net/wsdl}SayHelloPort

...suggesting that the portName attribute of the @WebService annotation is
being used, which is good--so why is OpenEJB trying to look up {
http://foobar.net/wsdl}SayHelloWebServiceService instead?  I've just spun
through the documentation on the website and found nothing relevant.

Thanks (again, as always),
Laird

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message