How to save KSOP2 response to xml in android SD ca

2019-08-16 18:05发布

In my project I am calling a web-service which giving response back as thousands of records from SQL server but as default size of SOAP ENVELOPE is 64KB I am getting only first 15 records in my log-cat and OutOfMemory exception...
Please tell me how to write this response in xml file in SD card.

private static String SOAP_ACTION1 ="http://tempuri.org/DownloadAllMasterDataRelatedToFarmer";
private static String NAMESPACE = "http://tempuri.org/";
private static String METHOD_NAME1 = "DownloadAllMasterDataRelatedToFarmer";
private static String URL = "http://someIP/Tracebaledemo/fieldbook/webservice1.asmxwsdl";

(...)

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME1);
request.addProperty("prefixText",txtFar.getText().toString());
request.addProperty("count",txtCount.getText().toString());
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;

try {
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
    Log.d(TAG, "Entering Try and calling WebService");

    //this is the actual part that will call the webservice
    androidHttpTransport.call(SOAP_ACTION1, envelope);

    // Get the SoapResult from the envelope body.
    Log.d(TAG, "Fetching Results");

    SoapObject result = (SoapObject)envelope.bodyIn;
    Log.d(TAG, "Result from WebService before if block= "+result);
} (...)

1条回答
爷、活的狠高调
2楼-- · 2019-08-16 18:20

You Saving Your xml just to fetch your records if it is not necessary You can do

Why Dont you define a limit to your Activity

Suppose 30 records per hit 

or You can also refine your webService And You can use a Footer showing Loading more in this Way you can see your records

DrawBack- It Will take time to fetch your records as you said u have 10,000 records

Solution- You can refine your webservice By Using 1st Letter of your Search Event I hope u Getting what i am trying to say If no, Please let me know

查看更多
登录 后发表回答