使用Spring Boot和Weblogic公开SOAP Webservice

3
我正在编写一个Spring Boot应用程序,希望在Weblogic 12C上部署。该应用程序公开了一个SOAP Web服务。当以独立模式运行应用程序时(Spring Boot使用嵌入式Tomcat运行),一切都正常工作,我可以通过访问wsdl来访问它。
http://localhost:8081/ws/springbootwstest.wsdl

但是,如果我在Weblogic中部署应用程序war文件,则虽然应用程序本身已成功部署,但Webservice不可用。

我无法访问wsdl。我已经按照以下说明进行操作 http://docs.spring.io/spring-boot/docs/1.2.2.BUILD-SNAPSHOT/reference/htmlsingle/#howto-weblogic 但仍然得到相同的结果。

所有源代码都可以在此处找到: https://github.com/iljahell/springbootwstest.git

java版本“1.7.0_67”

spring-boot 1.2.0.RELEASE

Weblogic 12.1.3.0.0


为什么在pom中将spring-boot-starter-ws标记为提供的呢?这会使该jar包及其依赖项中的类对WebLogic不可用,这几乎肯定不是您想要的。 - Andy Wilkinson
看看这个是否有帮助,关于导航到您的WSDL: http://stackoverflow.com/questions/27902435/what-is-the-full-wsdl-endpoint-url/27931145#27931145 - Display Name is missing
@AndyWilkinson 谢谢,我已经纠正了,但还是不起作用。 - Ilja
@DisplayNameismissing 应用程序的URL为localhost:7001/apiel-9.1.0-SNAPSHOT/。打开此URL会返回403错误。打开服务URL http://localhost:7001/apiel-9.1.0-SNAPSHOT/ws/springbootwstest.wsdl 会返回404错误。 - Ilja
对于那些来到这里的人,https://docs.spring.io/spring-boot/docs/current/reference/html/howto-traditional-deployment.html 可能会有所帮助。我遇到了类似的问题,但是我正在使用古老的Web Logic 10.3.6,并且按照文档中的步骤进行了操作。虽然我可以获取REST和网页,但我仍然无法使SOAP端点正常工作。 - David Bradley
2个回答

5

在使用Weblogic 12c时,我经历了很多挫败后终于解决了这个问题。Weblogic仍然要求您像这样在web.xml中定义spring ws消息调度servlet。确保您也将spring boot遗留依赖项添加到pom中。

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

同样的,确保将内嵌的Tomcat从您的Spring Boot WS依赖项中排除掉:
 <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>

那么

<?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>

然后添加一个与您的servlet名称匹配的空servlet.xml,即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>

最后,添加一个weblogic.xml文件,内容如下:
<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>

0

Mathew的答案确实有效。 请记住,如果您使用SpringBoot 2.X,请使用 spring-boot-legacy 2.1.X


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接