[jboss-user] [JBossWS] - Type mapping trouble with JAX-WS and EJB3

JoPe do-not-reply at jboss.com
Fri Feb 22 06:29:19 EST 2008


I'm trying to write my first own webservice using EJBs (V3) in a JBoss 4.2.2. Building and deploying the webservice bean works fine, but when I try to access a web method with no parameters and no return type like this:
package test.de.laliluna.library;
  | import java.net.URL;
  | import javax.xml.namespace.QName;
  | import javax.xml.rpc.Service;
  | import javax.xml.rpc.ServiceFactory;
  | import de.laliluna.library.BookTestBean;
  |  
  | public class WebServiceTestClient
  | {
  |     public static void main(String[] args) throws Exception
  |     {
  |         URL url = new URL("http://localhost:8080/FirstEjb3Tutorial/BookTestBean?wsdl");
  |         QName qname = new QName("http://library.laliluna.de/", "BookTestBeanService");
  |         ServiceFactory factory = ServiceFactory.newInstance();
  |         Service service = factory.createService(url, qname);
  |         
  |         BookTestBean serviceEndpoint = (BookTestBean)service.getPort(BookTestBean.class);
  |         serviceEndpoint.test();        
  |     }
  | }    
it throws this exception:
Exception in thread "main" org.jboss.ws.WSException: Cannot obtain java type mapping for: {http://library.laliluna.de/}test
  | 	at org.jboss.ws.metadata.builder.jaxrpc.JAXRPCMetaDataBuilder.processDocElement(JAXRPCMetaDataBuilder.java:627)
  | ...
  | 	at test.de.laliluna.library.WebServiceTestClient.main(WebServiceTestClient.java:18)    
where the last line refers to "Service service = factory.createService(url, qname);"
 
My questions are:
1. I thought using JAX-WS and Annotations would take care of all the webservice-configuration-XML-SOAP stuff for me. Do I still need to manually specify a type mapping? How? Where?
2. The web method I try to access has neither parameters nor a return value. How can there be any types to map??
 
If you could make me friends with webservices again, they and I would really appreciate it.
 
 
>From here: Server code.
package de.laliluna.library;
  | import java.rmi.Remote;
  | import java.util.Iterator;
  | import java.util.List;
  | import javax.ejb.Stateless;
  | import javax.jws.Oneway;
  | import javax.jws.WebMethod;
  | import javax.jws.WebService;
  | import javax.persistence.EntityManager;
  | import javax.persistence.PersistenceContext;
  |  
  | @Stateless
  | @WebService
  | public class BookTestBean implements BookTestBeanLocal, BookTestBeanRemote, Remote
  | {
  |     @PersistenceContext
  |     EntityManager em;
  |     public static final String RemoteJNDIName = BookTestBean.class.getSimpleName() + "/remote";
  |     public static final String LocalJNDIName = BookTestBean.class.getSimpleName() + "/local";
  |  
  |     @WebMethod
  |     @Oneway
  |     public void test()
  |     {
  |         Book book = new Book(null, "My first bean book", "Sebastian");
  |         em.persist(book);
  |         Book book2 = new Book(null, "another book", "Paul");
  |         em.persist(book2);
  |         Book book3 = new Book(null, "EJB 3 developer guide, comes soon", "Sebastian");
  |         em.persist(book3);
  |         System.out.println("list some books");
  |         List someBooks = em.createQuery("from Book b where b.author=:name").setParameter("name", "Sebastian")
  |                 .getResultList();
  |         for(Iterator iter = someBooks.iterator(); iter.hasNext()   ;)   
  |         {
  |             Book element = (Book)iter.next();
  |             System.out.println(element);
  |         }
  |         System.out.println("List all books");
  |         List allBooks = em.createQuery("from Book").getResultList();
  |         for(Iterator iter = allBooks.iterator(); iter.hasNext()   ;)   
  |         {
  |             Book element = (Book)iter.next();
  |             System.out.println(element);
  |         }
  |         System.out.println("delete a book");
  |         em.remove(book2);
  |         System.out.println("List all books");
  |         allBooks = em.createQuery("from Book").getResultList();
  |         for(Iterator iter = allBooks.iterator(); iter.hasNext()   ;)   
  |         {
  |             Book element = (Book)iter.next();
  |             System.out.println(element);
  |         }
  |     }
  | }    

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4131354#4131354

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4131354



More information about the jboss-user mailing list