gpt4 book ai didi

android - 在何处查看生成的 XML (KSOAP2)

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:22:14 24 4
gpt4 key购买 nike

我很难尝试使用我的 SoapRequest 查看生成的 XML。这是我的代码:

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

PropertyInfo propInfo=new PropertyInfo();
propInfo.setName("arg0");
propInfo.setType(PropertyInfo.STRING_CLASS);
propInfo.setValue(sessionId);

request.addProperty(propInfo);

// Sending the array representing our board:

Fields fieldsVector = new Fields();

for (int i=0; i<65; i++) {

fieldsVector.add(move[i].toString());

}

PropertyInfo fieldsPropertyInfo = new PropertyInfo();
fieldsPropertyInfo.setName("fields");
fieldsPropertyInfo.setValue(fieldsVector);
fieldsPropertyInfo.setType(fieldsVector.getClass());

request.addProperty(fieldsPropertyInfo);

PropertyInfo sessionPropertyInfo = new PropertyInfo();
sessionPropertyInfo.setName("arg0");
sessionPropertyInfo.setType(PropertyInfo.STRING_CLASS);
sessionPropertyInfo.setValue(sessionId);
request.addProperty(sessionPropertyInfo);

envelope.setOutputSoapObject(request);

envelope.addMapping(NAMESPACE, "fields", new Fields().getClass());

HttpTransportSE androidHttpTransport = new HttpTransportSE(WSDL_URL);
// androidHttpTransport.debug = true;


try {
androidHttpTransport.call(SOAP_ACTION, envelope);
} catch (Exception e) {
throw new RuntimeException("Unexpected exception", e);
}

try {
SoapPrimitive resultsRequestSOAP = (SoapPrimitive) envelope.getResponse();
} catch (SoapFault e) {
System.out.println("Error adding move: " + e.faultstring);//można to ładnie jakoś pokazać na ekranie
throw e;
}
}

如您所见,我已尝试设置 Debug模式,但它不起作用。我应该在哪里能够看到输出?

最佳答案

您几乎找到了答案,设置 androidHttpTransport.debug = true 并像这样调用 dump xml:

   androidHttpTransport.debug = true;
androidHttpTransport.call(SOAP_ACTION, envelope);
Log.d("dump Request: " ,androidHttpTransport.requestDump);
Log.d("dump response: " ,androidHttpTransport.responseDump);

关于android - 在何处查看生成的 XML (KSOAP2),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14310004/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com