Java 如何使用KSOAP2从webservice获取文件的一部分并创建zip?

Java 如何使用KSOAP2从webservice获取文件的一部分并创建zip?,java,android,web-services,zip,ksoap2,Java,Android,Web Services,Zip,Ksoap2,我需要从web服务中获取一个部分文件。web服务为我提供了拆分文件的功能。我发送参数(我需要的部分和字节大小)之前已经知道总共有多少部分以及它们各自的重量 如何使用KSOAP2获取这些零件,然后创建.zip byte[] bytess = SomeDecode(MyMethodWS (10, 1024)); //example Part 10 of 15 我选择了一个基本的解决方案:通过一个“for”向ws请求位和字节来连接和断开连接。考虑到最后要问的部分应该经过很好的计算(numberByt

我需要从web服务中获取一个部分文件。web服务为我提供了拆分文件的功能。我发送参数(我需要的部分和字节大小)之前已经知道总共有多少部分以及它们各自的重量

如何使用KSOAP2获取这些零件,然后创建.zip

byte[] bytess = SomeDecode(MyMethodWS (10, 1024)); //example Part 10 of 15

我选择了一个基本的解决方案:通过一个“for”向ws请求位和字节来连接和断开连接。考虑到最后要问的部分应该经过很好的计算(numberBytes)

FileOutputStream fos=新的FileOutputStream(file,true)//重要的是,这是真的。
整数字节=1024//如果numberBytes<'sizefile',则=sizefile
整数部分=0//
int parts=sizefile/numberBytes;//如果结果为十进制,则必须加+1

对于(intb=0;b我选择了一个基本的解决方案:通过一个“for”请求位和字节连接并断开与ws的连接

FileOutputStream fos=newfileoutputstream(file,true);//注意“true”。
int numberBytes=1024;//如果numberBytes<'sizefile',则=sizefile
整数部分=0//
int parts=sizefile/numberBytes;//如果结果为十进制,则必须加+1
对于(int b=0;b
FileOutputStream fos = new FileOutputStream(file,true); //Important that 'true'.

int numberBytes =  1024; //if numberBytes < 'sizefile' then = sizefile
int numberPart = 0; //

int parts = sizefile/numberBytes; // if the result is decimal must add +1

for(int b=0;b<parts;b++){

    //Calculate the part to be ordered: 0...numberBytes+1 ...n+1 ...n+1
    numberPart = functionCalculate(numberBytes,sizefile,b);

    SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);

    PropertyInfo p1 = new PropertyInfo();
    pi.setName("part");
    pi.setValue(numberPart);
    pi.setType(int.class);
    Request.addProperty(p1);

    PropertyInfo p2 = new PropertyInfo();
    p2.setName("bytess");
    p2.setValue(numberBytes);
    p2.setType(int.class);
    Request.addProperty(p2);

    Blah blah ksoap code…
    Blah blah ksoap code…

    try{

        Blah blah ksoap code…
        Blah blah ksoap code…

        SoapPrimitive response = (SoapPrimitive) envelope.getResponse();                         
        bytes = response.toString().getBytes(“UTF-8”);                      
        fos.write(bytes,0,bytes.length);//It is a zip. no need to build a zip    
    }catch(...
}//end for

close fos