Search code examples
androidhttpresponsensxmlparserksoap2

org.xmlpull.v1.XmlPullParserException: unexpected type (position:TEXT PK


using this code I try to receive a zip file frm webservice:

    public Object GetComplex() {
    SoapObject request = new SoapObject(Constants.MAIN_URL, METHOD_NAME);
    for (NameValuePair prop : PARAMS) {
        request.addProperty(prop.getName(), prop.getValue());
    }
    SoapSerializationEnvelope envelope = getSoapSerializationEnvelope(request);
    envelope.setOutputSoapObject(request);
    HttpTransportSE androidHttpTransport = getHttpTransportSE(Constants.MAIN_URL+PAGE_NAME);
    Object javab = null;
    try {
        androidHttpTransport.call(Constants.MAIN_URL+METHOD_NAME, envelope);
        javab = (Object)envelope.getResponse();

    } catch (Exception e) {
        if (Constants.DEBUG)Log.i(Constants.LOGTAG,"Exception Async = "+e);
        e.printStackTrace();
    }
    return javab;
}

but when reach line androidHttpTransport.call(Constants.MAIN_URL+METHOD_NAME, envelope); this error happens :

Exception Async = org.xmlpull.v1.XmlPullParserException: unexpected type (position:TEXT PK????????.^Eu...@5:163 in java.io.InputStreamReader@40568c00) 

I know that web service receive my request, check it and then send a zipped file as responce, it can be seen in error : TEXT PK is start of zip file. It sound like ksopa try to open and treat it as XML, so this error happen. I know that this approach is not correct to receive zip file from ksoap, but I don.t have any better idea. Does any one have a solution?


Solution

  • I have changed code so that it recevie file this way :

                FileDownloadManager getUrlFile;
                getUrlFile = new FileDownloadManager(
                        Constants.MAIN_URL+
                        "zip"+File.separator+
                        guid+File.separator+
                        "Temp"+File.separator+
                        Constants.FILEZIP+"?"+
                        UUID.randomUUID().toString(), 
                        Constants.FILEZIP);
                if (getUrlFile.DownloadFromUrl()>0){
                    fillSqlPriceKala(guid);
                }