我不知道它是如何可能得到一個SOAP響應體兒的內容時,子標籤,如下所示:獲取SOAP元素在Java中
<sth:x>...</sth:x>
在Oracle文檔我發現如何loop all Elements with a specific name。 但是因此我需要首先創建一個元素來指定我想要搜索的標籤的名稱。
如何創建一個看起來像上面的元素?我知道如何製作這樣的一個:
<sth:id sth="asdf">
但是,這並沒有真正的工作。 這是我嘗試閱讀的服務器響應。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<ns5:loginResponse xmlns:ns5="x">
<ns5:id>Value I am looking for</ns5:id>
<ns5:rc>0</ns5:rc>
</ns5:loginResponse>
</soapenv:Body>
</soapenv:Envelope>
感謝您的幫助:)
我試過,但我得到了以下錯誤: 'org.xml.sax.SAXParseException; lineNumber:1; columnNumber:1;在序言中不允許有內容。' 您是否還知道使用SOAP API讀取答案的方法? –