java - 使用 Jdom 读取 xml 文件

标签 java xml web-services soap wsdl

我正在尝试使用 JDOM 浏览 xml 文件。 这里是 xml 文件:

 <?xml version="1.0"  encoding= "UTF-8" ?> 
<definitions name="Web Service Mediation"
targetNamespace="http://these-info.univ-tun.com/Web Service Mediation" 
xmlns="http://these-info.univ-tun.comstem online" >
<binding name="ConnTWS" type="wsdlns:SimplePortType">
<soap:binding   style="rpc"  transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="soap">
<soap:operation soapAction="http://tempuri.org/action/binding.ConnTWS"/>
</operation>
</binding>  
</definitions> 

但是当我运行.java类时,会出现以下错误:

org.jdom.input.JDOMParseException: Error on line 6 of document file:/C:/Users/samsung/Desktop/copie%20de%20workspace/PluginFinal/plugin/eclipsehelio%20avec%20atl%20-%20Copie/workspace/Jdom2/Grammaire.xml: The prefix "soap" for element "soap:binding" is not bound.
    at org.jdom.input.SAXBuilder.build(SAXBuilder.java:465)
    at org.jdom.input.SAXBuilder.build(SAXBuilder.java:810)
    at org.jdom.input.SAXBuilder.build(SAXBuilder.java:789)
    at JDOM.main(JDOM.java:24)
Caused by: org.xml.sax.SAXParseException: The prefix "soap" for element "soap:binding" is not bound.

任何人都可以帮助更正 xml 文件。 非常感谢。

最佳答案

您尚未声明soap命名空间。将 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 添加到您的定义属性中。像这样:

<definitions name="Web Service Mediation"
 targetNamespace="http://these-info.univ-tun.com/Web Service Mediation" 
 xmlns="http://these-info.univ-tun.comstem online" 
 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">

关于java - 使用 Jdom 读取 xml 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29430886/

相关文章:

php - 如何跟踪/调试此错误 SOAP [消息 :protected] => looks like we got no XML document

PHP Soap 服务器响应格式

java - 在 Web 方法、服务层或 DAO 层中创建服务响应?

java - "adapter"放在 MVP(被动 View )中的什么位置?

Java:如何用一个替换多个回车?

java - 如何将参数传递到 Java 文件中?

c# - 在 C# 中为 XML 文档创建父节点

xml - 如何使用 Scala 验证 XML 文件的模式?

java - AES java编码,ruby解码

c++ - 快速信息集或 .net 二进制压缩开源库