2

我正在尝试在 JBoss 4.2(JDK 1.6、spring 3.0、spring-ws 2.0)中部署 spring-ws SOAP Web 服务。我使用 JAXB2 作为 O/X 绑定。设置很好,找到并连接了 bean,可以发送请求并生成响应。但是,我得到了空洞的回应。它既不在 SOAP 信封中,也不包含我简单的 UserDetails 在服务器上组装的任何内容。

正确的反应是:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Header/>
    <SOAP-ENV:Body>
       <ns2:UserDetails xmlns:ns2="http://a.dol.com/schemas">
          <ns2:name>John</ns2:name>
          <ns2:lastname>PerX</ns2:lastname>
       </ns2:UserDetails>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

但我只是得到类似的东西:

<Envelope>
    <Header/>
    <Body>
       <ns2:UserDetails xmlns:ns2="http://a.dol.com/schemas"/>
   </Body>
</Envelope>

google了一下,发现要添加如下代码:

<beans>
  <!-- Big magic hack to fix the broken SAAJ in JBoss
   See http://static.springsource.org/spring-ws/sites/1.5/faq.html#saaj-jboss -->
   <bean id="messageFactory">
     <property name="messageFactory">
       <!-- This is the Java 6 variant of this fix! Note the "internal" package missing in the spring-ws FAQ. -->
       <bean class="com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl"/>
     <property>
   <bean/>
</beans>

但这也无济于事,我得到以下错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageFactory' defined in ServletContext resource...

Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError...
    Caused by: java.lang.IllegalArgumentException: com.sun.xml.messaging.saaj.soap.LocalStrings != com.sun.xml.internal.messaging.saaj.soap.LocalStrings

任何提示表示赞赏。

更新

使用以下内容更新 JBoss 的 run.bat 确实可以解决问题,但这是正确的做法吗?

set JAVA_OPTS=%JAVA_OPTS% -Djavax.xml.soap.SOAPConnectionFactory=com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnectionFactory
set JAVA_OPTS=%JAVA_OPTS% -Djavax.xml.soap.MessageFactory=com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl
set JAVA_OPTS=%JAVA_OPTS% -Djavax.xml.soap.SOAPFactory=com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl
4

2 回答 2

2

将弹簧片段替换为

<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
    <property name="messageFactory">
        <bean class="com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl"/>
    </property>
</bean>

您在 messageFactory bean 定义中遗漏了完全限定的类名。这应该可以在没有启动选项的情况下工作。

于 2013-03-19T14:28:00.487 回答
1

使用以下内容更新 JBoss 的 run.bat 确实可以解决问题:

set JAVA_OPTS=%JAVA_OPTS% -Djavax.xml.soap.SOAPConnectionFactory=com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnectionFactory
set JAVA_OPTS=%JAVA_OPTS% -Djavax.xml.soap.MessageFactory=com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl
set JAVA_OPTS=%JAVA_OPTS% -Djavax.xml.soap.SOAPFactory=com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl
于 2012-01-17T16:23:41.650 回答