我試圖瞭解ws-security簽名和加密。我遵循this指南。正如前面提到的我已經安裝了壘,已經成功創建了相關的*.aar
文件,並將其部署到tomcat servlet引擎中,並將Bouncy Castle安全提供程序(對示例代碼中使用的公鑰加密功能必需的)org.bouncycastle.jce.provider.BouncyCastleProvider
添加到JVM安全配置(lib/security/java.security
文件),將Bouncy Castle JAR添加到Axis2安裝的lib目錄和Axis2服務器應用程序的目錄WEB-INF/lib
中。 (這是運行在給定的樣本設置),但在運行中描述的例子時,我收到以下錯誤SOAP消息不得包含文檔類型聲明(DTD)
[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
我怎麼能解決這個問題?
而當你打開此http://本地主機:8080 /的Axis2 /服務/在瀏覽器鏈接,什麼你有看到? – divanov