简体   繁体   中英

Exposing SOAP Webservice with spring-boot and Weblogic

I am writing a spring-boot application which I want to deploy in a Weblogic 12C. The application exposes a SOAP Webservice. When running the application in standalone mode (spring-boot runs it by using an embedded tomcat) everything works fine and I can access the wsdl by

http://localhost:8081/ws/springbootwstest.wsdl

But if I deploy the application-war-file in the Weblogic, the Webservice is not available while the application itself is deployed successfully.

I cannot access the wsdl. I already followed the instructions on http://docs.spring.io/spring-boot/docs/1.2.2.BUILD-SNAPSHOT/reference/htmlsingle/#howto-weblogic but still same result.

All sources can be found here: https://github.com/iljahell/springbootwstest.git

java version "1.7.0_67"

spring-boot 1.2.0.RELEASE

Weblogic 12.1.3.0.0

I've solved this today after much frustration with weblogic 12c. Weblogic still requires you to define the spring ws message dispatcher servlet in your web.xml like this. Make sure you add the spring boot legacy dependency to your pom too.

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-legacy</artifactId>
        <version>1.0.2.RELEASE</version>
    </dependency>

Also, make sure you exclude the embedded tomcat from your spring boot ws dependency:

 <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web-services</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.apache.tomcat.embed</groupId>
                <artifactId>tomcat-embed-websocket</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

Then

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>au.gov.qld.ambulance.mtaworkflow.webservices.SpringWsApplication</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener</listener-class>
</listener>

<servlet>
    <servlet-name>spring-ws</servlet-name>
    <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
    <init-param>
        <param-name>transformWsdlLocations</param-name>
        <param-value>true</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>spring-ws</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

</web-app>

Then add an empty servlet.xml matching your servlet name ie. spring-ws-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd">

</beans>

Finally, add a weblogic.xml with the following:

<wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-
web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd 
http://xmlns.oracle.com/weblogic/weblogic-web-app 
http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
<wls:weblogic-version>12.1.1</wls:weblogic-version>
<wls:context-root>mtaworkflow</wls:context-root>
<wls:container-descriptor>
    <wls:prefer-application-packages>
        <wls:package-name>org.slf4j.*</wls:package-name>
        <wls:package-name>org.springframework.*</wls:package-name>
        <wls:package-name>javax.websocket.*</wls:package-name>
        <wls:package-name>javax.websocket.server.*</wls:package-name>
    </wls:prefer-application-packages>
</wls:container-descriptor>
</wls:weblogic-web-app>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM