如何将xml转换成KSOAP的请求

以下代码显示XML文件通过SOAP发送到服务器中,那么如何把下面的xml文件转换成KSOAP请求?

<location>
<locationId>132</locationId>
<name>test</name>
<qualifiedCoordinates>
<altitude>10</altitude>
</qualifiedCoordinates>
</location>

1个回答

SoapObject request = new SoapObject(NAMESPACE, METHOD);
    request.addProperty("locationId", 132);
    request.addProperty("name", test);
    request.addProperty("altitude", 10);
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11);
    envelope.dotNet = true;
    envelope.setOutputSoapObject(request);

    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

    try {
        androidHttpTransport.call(SOAP_ACTION, envelope);
        SoapObject result = (SoapObject) envelope.getResponse();}
catch(Exception e) {
        tempText.setText("Error");
        e.printStackTrace();
    }
clcurie_11
clcurie_11 谢谢,但是有一个疑问,altitude是在qualifiedQoordinats里面定义的。因此直接给请求添加属性正确吗?
接近 8 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐