Search code examples
javaweb-servicesweblogicweblogic12ccontextroot

Multiple web services with same context root


I'm upgrading Web Services that used java EJB's and wer installed in WebLogic 8.1 to JAX-RPC Web Services in WebLogic 12c (WebLogic Server Version: 12.2.1.3.0)

They are several WS in the same project having same context root. So the adress for each is like:

[server]:[port]/services/ws1
[server]:[port]/services/ws2
[server]:[port]/services/ws3
...

In my development i can't set the same context root/path "services" for all Web Services.

Is it possible to have the same context root for all of them? (Like the example above?)

Detailed description: I got a "Weblogic Web Services Project" (Eclipse-> new project ->Oracle->WebLogic->Web Services-> Web Service Project) with multiple Web Services.

The Web Services were made from each WSDL with ANT wsdlc. So I got a "ws.jar" (compiled WSDL) and wsImpl.java (where I put my business code)

So final list of "source files" looks like:

ws1.jar
wsImpl1.java
ws2.jar
wsImpl2.java
ws3.jar
wsImpl3.java
...

Then I try to run ANT jwsc with multiple jws, one for each WS giving them all contextpath="services". When it gets to the second jws i get the error "Context path services for web application my/package/ws2.war is already in use by this application."

<target name="build-service">
    <jwsc srcdir="${src.dir}" destdir="${final.dir}/wars" verbose="true" keepGenerated="false" debug="on" includeantruntime="false">
    <classpath refid="project.class.path.build.services" />

    <jws file="my/package/ws1Impl.java" compiledWsdl="${output.dir}/compiledWsdl/ws1.jar">
        <WLHttpTransport contextpath="services" serviceuri="ws1" portname="ws1Port" />
    </jws>
    <jws file="my/package/ws2Impl.java" compiledWsdl="${output.dir}/compiledWsdl/ws2.jar">
        <WLHttpTransport contextpath="services" serviceuri="ws2" portname="ws2Port" />
    </jws>

        </jwsc>
</target>

Solution

  • Folowing @EmmanuelCollin comment I was able to do a better search and found a solution using

    <module contextPath="services" name="myJar" >
       <jws .../>
       <jws .../>
    </module>
    

    as in: Oracle Help Center "Example 4 Packaging Multiple Web Services Into a Single WAR File"

    Then I packed the generated aplication.xml and .war file to an .ear with ANT:

    <ear destfile="${dist.dir}/${ant.project.name}.ear" appxml="${conf.dir}/application.xml">  
     <metainf dir="${build.dir}/META-INF"/> 
     <fileset dir="${dist.dir}" includes="*.jar,*.war"/>
    </ear>
    

    Finally, deployed the .ear into weblogic 12c server and successfully tested the Web Services response. All under the same contextPath.

    Thank you!