[jboss-user] [EJB 3.0] - SessionBean as WebService - again complex data structures

CarstenRudat do-not-reply at jboss.com
Fri Oct 12 14:33:48 EDT 2007


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;
  | 
  | @WebService
  | @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)   
  | @Remote
  | public interface PartnerWebService extends java.rmi.Remote{
  | 
  | 	@WebMethod
  | 	public String sayHello(String hello);
  | 	
  | }
  | 
  | 

and


  | 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;
  | 
  | @Stateless
  | @Remote(PartnerWebService.class)
  | @SecurityDomain("...")
  | @org.jboss.annotation.ejb.Clustered
  | @RemoteBinding(jndiBinding="test/PartnerWebService/remote")
  | @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 {
  | 
  | 	/**
  | 	 * @param args
  | 	 */
  | 	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);
  | 			
  | 			System.out.println(partnerService.sayHello("test"));
  | 		} catch (MalformedURLException e) {
  | 			e.printStackTrace();
  | 		} catch (ServiceException e) {
  | 			e.printStackTrace();
  | 		}
  | 	}
  | 
  | }
  | 


But now, I add another mehtod:

  |         public ComplexObject getComplexObject() {
  | 		return new ComplexObject(new Date(), "test");
  | 	}
  | 
  |         ...
  | 
  |         @WebMethod
  | 	public ComplexObject getComplexObject();
  | 
  |         ...
  | 
  | public class ComplexObject implements Serializable {
  | 
  | 	/**
  | 	 * 
  | 	 */
  | 	private static final long serialVersionUID = 1L;
  | 
  | 	protected Date date;
  | 	
  | 	protected String string;
  | 
  | 	public ComplexObject() {
  | 	}
  | 
  |         getter/setter
  | }
  | 

No, I just get this exception:

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

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

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



More information about the jboss-user mailing list