Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何用JDOM解析SOAP_Java_Soap_Jdom - Fatal编程技术网

Java 如何用JDOM解析SOAP

Java 如何用JDOM解析SOAP,java,soap,jdom,Java,Soap,Jdom,我有以下SOAP示例消息: <?xml version="1.0"?> <SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Body> <CREATE__CompI

我有以下SOAP示例消息:

     <?xml version="1.0"?>
     <SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
     xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
     <SOAP-ENV:Body>
     <CREATE__CompIntfc__SUPPORT_DOC_TBL>
        <SUPPORT_DOC_ID>POLICE</SUPPORT_DOC_ID>
        <SUPPORT_DOC>
            <DESCR>Police Report</DESCR>
            <DESCRSHORT>Police</DESCRSHORT>
        </SUPPORT_DOC>
    </CREATE__CompIntfc__SUPPORT_DOC_TBL>
</SOAP-ENV:Body>
 </SOAP-ENV:Envelope>

警方
警察报告
警方
我需要解析元素。我正在为此任务编写以下代码,但它不起作用:

                  File inputXML=new                 File("/home/igor/IdeaProjects/jdomtest/src/main/resources/example.xsd");
    SAXBuilder saxBuilder=new SAXBuilder();
    try{
        Document rootElement=saxBuilder.build(inputXML);
        Element element=rootElement.getRootElement();

    Namespace ns=Namespace.getNamespace()
      List<Element> list=element.getChildren("Body");
 System.out.print(list.size());

  for (int i=0;i<list.size();i++){
  Element el = (Element)list.get(i);
    System.out.println(el);
   }

    }catch (Exception exp){
        exp.printStackTrace();
    }
File inputXML=new文件(“/home/igor/IdeaProjects/jdomtest/src/main/resources/example.xsd”);
SAXBuilder SAXBuilder=新SAXBuilder();
试一试{
documentrootelement=saxBuilder.build(inputXML);
Element=rootElement.getRootElement();
Namespace ns=Namespace.getNamespace()
List=element.getChildren(“Body”);
System.out.print(list.size());

对于(int i=0;i主体元素位于
http://schemas.xmlsoap.org/soap/envelope/
namespace,但您使用的是单参数
getChildren
方法,该方法不在任何名称空间中查找元素。您需要向双参数版本的
getChildren
传递适当的
namespace