我在 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();
}
}
而且调试一切似乎没问题,但是当应用程序启动时,我应该看到图片的地方是白色的。我认为这可能是一个转换问题,但我不知道如何解决它。
有人可以帮助我吗?