如何在大型xml文件中调用soap webservice作为android java中的参数

时间:2013-02-26 10:35:18

标签: android xml soap ksoap2 uploading

我成功地将字符串和int发送到soap而不是xml SOAPAction:

"iReceiver/XPL-CIMS-iReceiver-RecordIssuesData" 
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <XPL-CIMS-iReceiver-RecordIssuesData xmlns="iReceiver">
      <A_iStaffDId>int</A_iStaffDId>
      <A_strGUID>string</A_strGUID>
      <dsIssues>
        <xsd:schema>schema</xsd:schema>xml</dsIssues>
    </XPL-CIMS-iReceiver-RecordIssuesData>
  </soap:Body>
</soap:Envelope>

我是stackoverflow的新手。请帮助我提前谢谢

1 个答案:

答案 0 :(得分:0)

使用以下方法将其转换为xml并以这种方式调用它: 文档文档= XMLfromString(Str);

然后以这种方式解析

NodeList node = document.getElementsByTagName(&#34; firsttag&#34;)并发送

public Document XMLfromString(String v){

    Document doc = null;

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    try {

        DocumentBuilder db = dbf.newDocumentBuilder();

        InputSource is = new InputSource();
        is.setCharacterStream(new StringReader(v));
        doc = db.parse(is);

    } catch (ParserConfigurationException e) {
        e.printStackTrace();
    } catch (SAXException e) {
        System.out.println("Wrong XML file structure: " + e.getMessage());
        return null;
    } catch (IOException e) {
        e.printStackTrace();
    }

    return doc;

}