在receiveing​​字节[]从麻烦WCF ksoap2到Android [英] trouble in receiveing byte [] from wcf ksoap2 to android

查看:127
本文介绍了在receiveing​​字节[]从麻烦WCF ksoap2到Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从发送WCF ksoap2图像到Android。在WCF一边,我已经转换所有图像成字节数组,并存储它们的ArrayList。在Android的身边,我试图填补了的ArrayList<&字节GT;阵列; 但其不充盈,但它仍然是空的。
这里是我的code

I am trying to send images from wcf ksoap2 to android. At wcf side I have converted all images into byte array and stored them in an ArrayList. At android side I trying fill the ArrayList<Byte> arrays; but its not filling, it remains empty. Here is my code

WCF:

        List<byte[]> list;
        public List<byte[]> loadImages()
        {
            DirectoryInfo directoryInfo = new DirectoryInfo(@"C:\Users\User\Desktop\abc");
            arr1 = new ArrayList();
            foreach (FileInfo fi in directoryInfo.GetFiles())
                arr1.Add(fi.FullName);



            list = new List<byte[]>();
            for (int i = 0; i < arr1.Count; i++)
            {
                img = Image.FromFile(arr1[i].ToString());
                ms = new MemoryStream();
                img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                list.Add(ms.ToArray());
                //                objbyte = (byte[])ms.ToArray();
            }

            return list;
        }

机器人:

            SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
            SoapSerializationEnvelope soapEnvelop;
            soapEnvelop = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            soapEnvelop.dotNet = true;
            soapEnvelop.setOutputSoapObject(Request);
            HttpTransportSE htps = new HttpTransportSE(URL);

            htps.call(SOAP_ACTION, soapEnvelop);
            response = (SoapObject) soapEnvelop.getResponse();    
            ar = new String[response.getPropertyCount()];

            arrays = new ArrayList<Byte>();

            if (response != null) {

                if (response.getPropertyCount() > 0) {                  

                    for (int i = 0; i < response.getPropertyCount(); i++) {

                        arrays.add( (Byte) response.getProperty(i)); 
                    }
                }
            }

有关循环执行正常,但阵列保持为空

for loop executes properly but arrays remains empty

我想一次发送10-15图像。
在此先感谢

I want to send 10-15 images at a time. Thanks in advance

推荐答案

这里的code:

SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
            SoapSerializationEnvelope soapEnvelop;
            soapEnvelop = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            soapEnvelop.dotNet = true;
            soapEnvelop.setOutputSoapObject(Request);
            HttpTransportSE htps = new HttpTransportSE(URL);

            htps.call(SOAP_ACTION, soapEnvelop);
            response = (SoapObject) soapEnvelop.getResponse();    
            ar = new String[response.getPropertyCount()];

            arrays = new ArrayList<Byte>();

            if (response != null) {

                if (response.getPropertyCount() > 0) {                  

                    for (int i = 0; i < response.getPropertyCount(); i++) {

                        arrays.add( (Byte) response.getProperty(i)); 
                    }
                }
            }

这篇关于在receiveing​​字节[]从麻烦WCF ksoap2到Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆