2 Replies Latest reply on Nov 28, 2007 3:53 PM by Quande Ren

    SessionBean as WebService - again complex data structures

    Carsten Rudat Novice

      Hi all,

      I have a SLSB and want it to be accessable through a webservice. So I write

      package com.genloop.ejb.beans.service;
      import javax.ejb.Remote;
      import javax.jws.WebMethod;
      import javax.jws.WebService;
      import javax.jws.soap.SOAPBinding;
      @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
      public interface PartnerWebService extends java.rmi.Remote{
       public String sayHello(String hello);


      package com.genloop.ejb.beans.service;
      import java.util.Date;
      import javax.ejb.Remote;
      import javax.ejb.Stateless;
      import javax.interceptor.Interceptors;
      import javax.jws.WebService;
      import org.jboss.annotation.ejb.RemoteBinding;
      import org.jboss.annotation.security.SecurityDomain;
      import com.genloop.ejb.commons.SecurityInterceptor;
      import com.genloop.ejb.commons.UserInterceptor;
      @Interceptors({UserInterceptor.class, SecurityInterceptor.class})
      @WebService(endpointInterface="com.genloop.ejb.beans.service.PartnerWebService", serviceName="PartnerService")
      public class PartnerWebServiceBean implements PartnerWebService {
       public String sayHello(String hello) {
       return hello;

      My Client works well:

      public class PartnerWSClient {
       public static void main(String[] args) {
       try {
       URL url = new URL("http://localhost:8080/test-ea-test-service/PartnerWebServiceBean?wsdl");
       QName qname = new QName("http://service.beans.ejb.genloop.com/", "PartnerService");
       ServiceFactory factory = ServiceFactory.newInstance();
       Service service = factory.createService(url, qname);
       PartnerWebService partnerService = (PartnerWebService)service.getPort(PartnerWebService.class);
       } catch (MalformedURLException e) {
       } catch (ServiceException e) {

      But now, I add another mehtod:

      public ComplexObject getComplexObject() {
       return new ComplexObject(new Date(), "test");
      public ComplexObject getComplexObject();
      public class ComplexObject implements Serializable {
       protected Date date;
       protected String string;
       public ComplexObject() {

      No, I just get this exception:

      Cannot obtain java/xml type mapping for: {http://service.beans.ejb.genloop.com/}complexObject

      I use JBoss 4.2.1 and updated JBoss Web Services to version 2.0.

      And my question is: What am I doing wrong? Is there any way to get user datastructures work?