0

我需要一些帮助来理解如何在 android 应用程序中发送这个 XML。我读过使用 ksoap 库是一种方法。我已经尝试过教程,但它们似乎都不适合我;甚至要下载的样本。任何帮助表示赞赏。

POST /nrc/control_0 HTTP/1.1
User-Agent: Panasonic iOS VR-CP UPnP/2.0
Host: 10.0.1.155:55000
Content-Type: text/xml; charset="utf-8"
SOAPACTION: "urn:panasonic-com:service:p00NetworkControl:1#X_SendKey"
Content-Length: 331

<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" 
s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<s:Body>
<u:X_SendKey xmlns:u="urn:panasonic-com:service:p00NetworkControl:1">
<X_KeyEvent>NRC_MUTE-ONOFF</X_KeyEvent>
</u:X_SendKey>
</s:Body>
</s:Envelope>
4

1 回答 1

0

下面给出的是用于进行 SOAP 调用的代码:

public String callService(String URL, String METHOD_NAME, String NAMESPACE,
        String SOAP_ACTION, String param) {
    String data = "";

    Log.v(webserviceadpater, " \n METHOD_NAME =  ---> " + METHOD_NAME
            + " <--- \n ");

    try {
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        request.addProperty("xml", param);
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                SoapEnvelope.VER11);

        envelope.setOutputSoapObject(request);

        HttpTransportSE transportSE = new HttpTransportSE(URL);
        transportSE.debug = true;

        transportSE.call(SOAP_ACTION, envelope);

        SoapObject result = (SoapObject) envelope.bodyIn;

        for (int i = 0; i < result.getPropertyCount(); i++) {
            data = result.getProperty(i).toString();
            Log.v(webserviceadpater, "result = " + data);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

    return data;
}
于 2013-03-16T13:35:47.710 回答