gpt4 book ai didi

c# - 如何从 wcf ksoap2 响应中填充字典

转载 作者:行者123 更新时间:2023-11-29 05:30:48 25 4
gpt4 key购买 nike

我有一个返回 Dictionary<ArrayList, List<byte[]>> 的 wcf ksoap2 服务.现在在 android 端我想填写我的 Dictionary<String[], ArrayList<Object>> diction;来自 wcf 响应。我是 wcf 和 android/java 的新手,我不知道该怎么做。请给我一些用 wcf 填充字典的更好的例子。

提前致谢

这是我的wcf代码

public Dictionary<ArrayList, List<byte[]>> getImages()
{
Dictionary<ArrayList, List<byte[]>> image_Name = new Dictionary<ArrayList, List<byte[]>>();

DirectoryInfo directoryInfo = new DirectoryInfo(@"C:\Users\Yakhtar\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());
}

image_Name.Add(arr1, list);
//image_Name[arr1 as ArrayList] = [list as byte[]];
return image_Name;
}

最佳答案

嗯,我不确定,但您是否考虑过 JSON 解析而不是 ksoap2??

这是一个tutorial on how to work with array of complex objects with KSOAP .我通过无数小时的调试发现了这一点。希望这能帮上忙

也试试这个

SoapObject countryDetails = (SoapObject)envelope.getResponse();
System.out.println(countryDetails.toString());

ArrayList list = new ArrayList(countryDetails.getPropertyCount());
lv_arr = new String[countryDetails.getPropertyCount()];
for (int i = 0; i < countryDetails.getPropertyCount(); i++) {
Object property = countryDetails.getProperty(i);
if (property instanceof SoapObject) {
SoapObject countryObj = (SoapObject) property;
String countryName = countryObj.getProperty("countryName").toString();
list.add(countryName );
}
}

关于c# - 如何从 wcf ksoap2 响应中填充字典,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21154801/

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