Help

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

Prerequisites: seam and cxf are configured and running.

Now to add seam support to a cxf webservice in tomcat:

Add the org.jboss.seam.webservice.SOAPRequestHandler in the cxf-servlet.xml spring config file:

   <jaxws:endpoint
            id="myWS"
            implementor="com.MyWSImpl"
            wsdlLocation="classpath:MyWS.wsdl"
            address="/myWS">
        <jaxws:handlers>
            <bean id="seamHandler" class="org.jboss.seam.webservice.SOAPRequestHandler"/>
        </jaxws:handlers>
    </jaxws:endpoint>

Then follow the strategy suggested in the seam documentation and build a conversation facade:

@Name(value = "conversationFacade")
@Scope(value = ScopeType.CONVERSATION)
@AutoCreate
public class ConversationFacade
{
    @In
    EntityManager entityManager;

    @Begin(join = true)
    public void invoke()
    {
        //
    }

    @SuppressWarnings({"unchecked"})
    @Transactional
    public <T> List<T> getResultList(String query, Object... params)
    {
        Query query1 = entityManager.createQuery(query);
        for (int i = 0; i < params.length; i++)
        {
            Object param = params[i];
            query1.setParameter(i + 1, param);
        }
        return query1.getResultList();
    }
    ....
}

and reference it in your webservice implementation like this:

    private ConversationFacade getConversationFacade()
    {
        ConversationFacade conversationFacade = (ConversationFacade) Component.getInstance(ConversationFacade.class, true);
        conversationFacade.invoke();
        return conversationFacade;
    }

Be sure to put all your business logic inside the ConversationFacade:

public doSomethingMsgReply doSomething(@WebParam(partName = "doSomethingMsg", name = "doSomethingMsg", targetNamespace = "http://www.myCompany.com/myWS") doSomethingMsg doSomethingMsg) throws MyFault
{
    doSomethingMsgReply doSomethingMsgReply = getConversationFacade().doSomethingMsgReply(doSomethingMsg);

    return doSomethingMsgReply;  
}

with doSomethingMsgReply(doSomethingMsg) something like this:

@Transactional
public doSomethingMsgReply(doSomethingMsg)
{
  ....
}