Question

I've been working with JAX-WS with Weblogic Server, using their Ant tasks to build EAR files that can be deployed on the server. I've gotten basic SOAP calls to work with JAX-WS, but now I'm trying to add some message-level security via WS-Security.

According to the documentation, there are two ways of adding security policies to web services. One is to use annotations on the Java source itself, but means that the policies are set forever. The second method is to add the policy files to the EAR file and then allow the administrator to set the policies for web services post-deployment.

While the documentation mentions where you must put the policy files, it fails to explain how to automatically add these policy files when doing a build with Ant. It would be entirely too laborious in testing to add the policy files manually every time I build/redeploy the EAR. Here's the Ant code I use right now to build the EAR file:

<target name="build-service">
    <jwsc source" srcdir="java" destdir="${ear-dir}">
        <jws file="SoapService.java" type="JAXWS"/>
    </jwsc>
</target>

How can I automatically build EAR with policy files into the right location? I'm most interested in building it into the WEB-INF/policies in the Java WAR file. You can assume I have the policy files on hand and can reference them before building.

Was it helpful?

Solution

For the record, the answer is to use <module> in conjunction with <zipfileset>:

<target name="build-service">
    <jwsc srcdir="java" destdir="${ear-dir}">
        <module>
            <jws file="SoapService.java" type="JAXWS"/>
            <zipfileset dir="." prefix="WEB-INF/policies">
                <include name="mypolicy.xml"/>
            </zipfileset>
        </module>
    </jwsc>
</target>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top