解析soap响应返回null

时间:2019-03-19 18:20:27

标签: java parsing soap

 <env:Body   env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <m:getUserMusicResponse    xmlns:m="http://www.myservicetest.com/Test">
   <myList     soapenc:arrayType="xsd:string[405]">
    <string      xsi:type="xsd:string">abc.mp3</string>
    <string      xsi:type="xsd:string">cdf.mp3</string>
    <string      xsi:type="xsd:string">jap.mp3</string>
    <string      xsi:type="xsd:string">xyz.mp3</string>
    <string      xsi:type="xsd:string">zab.mp3</string>
        ....
   </myList>

我想解析上面的列表,但我不断得到null作为数组。

        ArrayList<String> myList = new ArrayList<>();   
        response = postRequest(soapUrl, requestBody);
        DocumentBuilderFactory dbf =DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        InputSource is = new InputSource(new StringReader(response));
        Document doc = db.parse(is);
        NodeList nodeList = doc.getElementsByTagName("myList");
        for(int i=0;i<nodeList.getLength(); i++) {
            Node x = nodeList.item(i);
            myList.add(x.getNodeValue());             
        }

myList打印[null]

我的代码有什么问题?或如何解析上方列表?

0 个答案:

没有答案