ksoap2-android如何查看正在发送的soap消息?

ksoap2-android how to view soap message being sent?

我通过设置 httpTransport.debug = true 启用了调试模式。但是,httpTransport.requestDump 不显示任何内容。我可以提示一下为什么它不起作用吗?有什么方法可以查看在信封中创建的 soap 消息吗?

非常感谢您的帮助。

final String NAMESPACE = getString(R.string.namespace);
final String METHOD_NAME = getString(R.string.method_name);
final String SOAP_ACTION = getString(R.string.soap_action);
final String SERVICE_URL = getString(R.string.service_url);
final String API_KEY = getString(R.string.api_key);

StringBuilder sb = new StringBuilder();
sb.append("<APIKey>");
sb.append(API_KEY);
sb.append("</APIKey><ISBN>");
sb.append(ean);
sb.append("</ISBN><Modifiers></Modifiers>");
Log.d(TAG, sb.toString());

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
// GetAvailabilityInfoRequest availability = new GetAvailabilityInfoRequest(API_KEY, ean);
request.addProperty("GetAvailabilityInfoRequest", sb.toString());

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = false;
envelope.setOutputSoapObject(request);

HttpTransportSE httpTransport = new HttpTransportSE(SERVICE_URL);
httpTransport.debug = true;
try {
    httpTransport.call(SOAP_ACTION, envelope);
    Log.d(TAG, httpTransport.requestDump);
    Log.d(TAG, httpTransport.responseDump);
} catch (Exception e) {
    Log.e(TAG, "Error ", e);
}

这是我的请求,

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
    xmlns:xsi="w3.org/2001/XMLSchema-instance";
    xmlns:xsd="w3.org/2001/XMLSchema";
    xmlns:soap="schemas.xmlsoap.org/soap/envelope/">; 
    <soap:Body>
        <GetAvailabilityInfoRequest xmlns="nlb.gov.sg/ws/CatalogueService">; 
            <APIKey>****APIKEY***</APIKey>
            <ISBN>9781579124854</ISBN>
            <Modifiers></Modifiers>
        </GetAvailabilityInfoRequest>
    </soap:Body>
</soap:Envelope>

此致, JN

我假设您正在尝试创建如下请求,

<Body>
    <GetAvailabilityInfoRequest>
        <APIKey>key</APIKey>
        <ISBN>ean</ISBN>
        <Modifiers></Modifiers>
    </GetAvailabilityInfoRequest>
</Body>

另外我假设你的 METHOD_NAMEGetAvailabilityInfoRequest

尝试使用以下代码创建请求,

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("APIKey", key);
request.addProperty("ISBN", ean);
request.addProperty("Modifiers", "");

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = false;
envelope.setOutputSoapObject(request);