SOAP消息不得包含文档类型声明(DTD)

时间:2013-12-12 17:06:29

标签: java web-services tomcat soap axis2

我正在尝试了解ws-security签名和加密。我跟着this指南。如上所述我已经安装了rampart,已经成功创建了相关的*.aar文件并将其部署在tomcat servlet引擎中,添加了org.bouncycastle.jce.provider.BouncyCastleProvider Bouncy Castle安全提供程序(对于公共密钥加密功能所必需的)示例代码)到JVM安全配置(lib/security/java.security文件),将Bouncy Castle JAR添加到Axis2安装的lib目录和Axis2服务器应用程序的WEB-INF/lib目录中。 (这是运行给定示例的设置)但是在运行所描述的示例时,我收到以下错误

 [java] Connecting to http://localhost:8080/axis2/services/library-signencr
 [java] Exception in thread "main" org.apache.axis2.AxisFault: SOAP message MUST NOT contain a Document Type Declaration(DTD)
 [java]     at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
 [java]     at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:123)
 [java]     at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:67)
 [java]     at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:354)
 [java]     at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
 [java]     at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
 [java]     at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
 [java]     at com.sosnoski.ws.library.adb.LibrarySignencrStub.getBook(LibrarySignencrStub.java:205)
 [java]     at com.sosnoski.ws.library.adb.WebServiceClient.main(WebServiceClient.java:83)
 [java] Caused by: org.apache.axiom.om.OMException: SOAP message MUST NOT contain a Document Type Declaration(DTD)
 [java]     at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createDTD(StAXSOAPModelBuilder.java:455)
 [java]     at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:282)
 [java]     at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:198)
 [java]     at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:154)
 [java]     at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:140)
 [java]     at org.apache.axis2.builder.BuilderUtil.getSOAPBuilder(BuilderUtil.java:686)
 [java]     at org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:197)
 [java]     at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:145)
 [java]     at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:108)
 [java]     ... 7 more
 [java] Java Result: 1

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:7)

我遇到了同样的问题,网络服务一直有效,但昨天。问题出现了,因为在代码中我们等待一个xml响应,但它给出了一个html错误页面。所以DOCUMENT TYPE(html页面)不是我们在代码中所期望的。所有这一切都发生了,因为服务器搬走了!

很抱歉这么晚回答,但我希望我的回答能帮助将来的另一个人^ - ^