This content has been marked as final.
Show 1 reply
-
1. Re: How to get SOAP message inside a EJB layer
arnowerr Jul 27, 2006 7:26 AM (in response to tallesbrito)Here is my sample of accessing SOAP message body content - Cabin by EJB exposed as a web service
package com.bruno.net.ejb; import javax.annotation.PostConstruct; import javax.ejb.Stateless; import javax.jws.Oneway; import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebResult; import javax.jws.WebService; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import javax.xml.ws.WebServiceRef; import org.apache.log4j.Logger; import com.bruno.net.domain.Cabin; @WebService(name = "TravelAgent", serviceName = "TravelAgentService") @WebServiceRef(name = "service/TravelAgentService") @Stateless public class TravelAgentBean implements TravelAgentRemote { private Logger logger; @PersistenceContext(unitName = "titan") private EntityManager manager; @PostConstruct public void postConstruct() { logger = Logger.getLogger(getClass().getName()); } @WebMethod @Oneway public void createCabin(@WebParam(name = "Cabin") Cabin cabin) { logger.debug("here is my cabin delivered by JAX-WS = " + cabin); logger.debug("cabin name " + cabin.getName()); logger.debug("bed count " + cabin.getBedCount()); manager.persist(cabin); } @WebMethod @WebResult(name = "Cabin") public Cabin findCabin(@WebParam(name = "ID") int pKey) { return manager.find(Cabin.class, pKey); } }
If you need SOAP header you have to create and wire up a message handler to work with SAAJ.
Cheers,
Arno