我的webservice那边的接受代码是
[WebMethod]
public bool PutImage(byte[] ImgIn)
{
System.IO.MemoryStream ms =
new System.IO.MemoryStream(ImgIn);
System.Drawing.Bitmap b =
(System.Drawing.Bitmap)Image.FromStream(ms); b.Save("C:\\1.png",
System.Drawing.Imaging.ImageFormat.Png); return true;
}然后android那边的链接代码是
private static final String NAMESPACE = "http://tempuri.org/";
private static String URL = "http://192.168.0.32:8081";
private static final String METHOD_NAME = "PutImage";
private static String SOAP_ACTION = "http://tempuri.org/PutImage"; in = new FileInputStream("/sdcard/logo.jpg");
buf = new BufferedInputStream(in,1070); //??? 1070 what for
System.out.println("1..........." + buf);
byte[] bMapArray = new byte[buf.available()];
buf.read(bMapArray);
System.out.println("2..........." + buf.read(bMapArray));
Bitmap bMap = BitmapFactory.decodeByteArray(bMapArray,0,bMapArray.length);
iv.setImageBitmap(bMap);
in.close();
SoapObject rpc = new SoapObject(NAMESPACE, METHOD_NAME);
rpc.addProperty("ImgIn",Base64.decode(bMapArray,Base64.DEFAULT));
AndroidHttpTransport ht = new AndroidHttpTransport(URL);
ht.debug = true;
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.setOutputSoapObject(rpc);
//1
ht.call(SOAP_ACTION,envelope);
//2
SoapObject result = (SoapObject) envelope.bodyIn;
String ret = result.getProperty("PutImageResult").toString();
if(ret.equals("true"))
{
Toast.makeText(this, "发送成功", Toast.LENGTH_LONG).show();
}
else
{
}这个程序的目的是将手机上的图片上传到服务器中,并且保存在服务器上,可是每次运行到//1处就会出现异常,
请问一下,有什么方法 我自已觉得是rpc.addProperty("ImgIn",Base64.decode(bMapArray,Base64.DEFAULT))
这里问题 ,可是却不知道怎么改。我看过在soap1.1中接受的字段类型是 Base64Binary...
....或者有什么其他好的办法 只要实现这个功能就可以
3Q~~~~
[WebMethod]
public bool PutImage(byte[] ImgIn)
{
System.IO.MemoryStream ms =
new System.IO.MemoryStream(ImgIn);
System.Drawing.Bitmap b =
(System.Drawing.Bitmap)Image.FromStream(ms); b.Save("C:\\1.png",
System.Drawing.Imaging.ImageFormat.Png); return true;
}然后android那边的链接代码是
private static final String NAMESPACE = "http://tempuri.org/";
private static String URL = "http://192.168.0.32:8081";
private static final String METHOD_NAME = "PutImage";
private static String SOAP_ACTION = "http://tempuri.org/PutImage"; in = new FileInputStream("/sdcard/logo.jpg");
buf = new BufferedInputStream(in,1070); //??? 1070 what for
System.out.println("1..........." + buf);
byte[] bMapArray = new byte[buf.available()];
buf.read(bMapArray);
System.out.println("2..........." + buf.read(bMapArray));
Bitmap bMap = BitmapFactory.decodeByteArray(bMapArray,0,bMapArray.length);
iv.setImageBitmap(bMap);
in.close();
SoapObject rpc = new SoapObject(NAMESPACE, METHOD_NAME);
rpc.addProperty("ImgIn",Base64.decode(bMapArray,Base64.DEFAULT));
AndroidHttpTransport ht = new AndroidHttpTransport(URL);
ht.debug = true;
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.bodyOut = rpc;
envelope.dotNet = true;
envelope.setOutputSoapObject(rpc);
//1
ht.call(SOAP_ACTION,envelope);
//2
SoapObject result = (SoapObject) envelope.bodyIn;
String ret = result.getProperty("PutImageResult").toString();
if(ret.equals("true"))
{
Toast.makeText(this, "发送成功", Toast.LENGTH_LONG).show();
}
else
{
}这个程序的目的是将手机上的图片上传到服务器中,并且保存在服务器上,可是每次运行到//1处就会出现异常,
请问一下,有什么方法 我自已觉得是rpc.addProperty("ImgIn",Base64.decode(bMapArray,Base64.DEFAULT))
这里问题 ,可是却不知道怎么改。我看过在soap1.1中接受的字段类型是 Base64Binary...
....或者有什么其他好的办法 只要实现这个功能就可以
3Q~~~~
解决方案 »
- 中兴Android面试题目
- 乔布斯走了,面对Android的冲击,苹果未来的命运会如何?
- 关于看了mars 老师的01-18 文件下载的视频 报错求解决 看了网上也有这种错误求大神
- Android下DES加密和J2SE平台下加密结果不一样
- 用Sourcery G++ Lite for ARM EABI(windows版本的)如何编译Android JNI?
- 这段代码运行崩溃
- android的一些问题
- 急!!android opengl上圆柱体绘制问题
- 奇怪:LinearLayout 后续不能追加 View 成员!
- java如何生成jar包,我不需要main函数的,我只是生成架包调用而已
- 关于在模拟器上录像的问题
- android 怎么样通过ListView 的onItemClick方法传送动态数据
http://iharder.sourceforge.net/current/java/base64/
这里有一个公开的类实现base64的编码解码,我换上以后测试成功。多谢。