空 SOAP 响应 - 使用 JBoss 4.2、Jaxb2、Java 1.6
我正在尝试在 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>
在搜索谷歌后,我发现要添加以下代码:
<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
I am trying to deploy a spring-ws SOAP webservice in JBoss 4.2 (JDK 1.6, spring 3.0, spring-ws 2.0). I am using JAXB2 as O/X binding. Setup is fine, beans found and wired, requests can be sent and responses are generated. However, I am getting empty responses. It neither is in a SOAP envelope nor contains my simple UserDetails any content that is assembled on the server.
The correct response would be:
<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>
But I just get something like:
<Envelope>
<Header/>
<Body>
<ns2:UserDetails xmlns:ns2="http://a.dol.com/schemas"/>
</Body>
</Envelope>
After searching google, I found the following code to be added:
<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>
But this also doesnt help, I get the folloiwng error:
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
Any hints appreciated.
Updated
Updating the run.bat for JBoss with the following does fix the problem, but is this the correct way of doing it??
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将 spring 代码段替换为
您在 messageFactory bean 定义中遗漏了完全限定的类名。
如果没有启动选项,这应该可以工作。
Replace the spring snippet with
You have left out the fully qualified classname in the messageFactory bean definition.
This should work then without the startup options.
使用以下内容更新 JBoss 的 run.bat 确实解决了该问题:
Updating the run.bat for JBoss with the following does fix the problem: