【发布时间】:2013-04-27 10:50:12
【问题描述】:
我在 VisualBasic .net 中有一个 WebService,它提供了带有以下代码的图片:
<WebMethod()> _
Public Function DevuleveImagen() As Byte()
Dim imagen As Byte()
Dim bm As New Bitmap("C:\Imagen.jpg")
Dim ms As New IO.MemoryStream
bm.Save(ms, Imaging.ImageFormat.Jpeg)
imagen = ms.GetBuffer()
ms.Close()
ms = Nothing
Return imagen
End Function
我尝试从 Android 接收这张图片:
private void PonLogo(){
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME1);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
try {
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION1, envelope);
SoapObject result = (SoapObject)envelope.bodyIn;
if(result != null)
{
Object o = result.getProperty(0);
byte[] b = o.toString().getBytes();
Bitmap bMap = BitmapFactory.decodeByteArray(b, 0, b.length);
imgbannerjuego.setImageBitmap(bMap);
}
else
{
Toast.makeText(getApplicationContext(), "No Response",Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
e.printStackTrace();
}
}
并且调试一切似乎还可以,但是当应用程序启动时,我应该看到图片的地方是白色的。我认为这可能是一个转换问题,但我不知道如何解决。
有人可以帮帮我吗?
【问题讨论】:
-
我也有同样的问题,如果你找到解决方案,我很感激:-)
标签: android .net web-services