Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7608243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:52:01+00:00 2026-05-31T00:52:01+00:00

I am retrieving an image from my SQLite table and converting it to a

  • 0

I am retrieving an image from my SQLite table and converting it to a byte array using this code :

byte[] imageByteArray = cImage.getBlob(cImage.getColumnIndex("ImageData")); 

which works fine (I have proven this by decoding it back to the original image like this :

ByteArrayInputStream imageStream = new ByteArrayInputStream(imageByteArray);
Bitmap theImage = BitmapFactory.decodeStream(imageStream);

The problem I have is I need to serialise the image data and send it via .net web services, then decode it at the other end.

I am using this code to encode the byte[] to a Base64 string :

String sImageData = Base64.encode(imageByteArray);

Then adding it as a property to my service call.

The call takes a while to complete which indicates it is sending the data – although I get the exception “Value cannot be null” when I do this in the web service :

byte[] baImageData = Convert.FromBase64String(sImageData);

I’m not sure how I can debug this any further – am I missing something obvious?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:52:03+00:00Added an answer on May 31, 2026 at 12:52 am

    it works fine, but if you send a long picture, it crash.

    in Android:

    private static final String NAMESPACE = "http://tempuri.org/";
    private static String URL="http://XXX.XX.113.79/Sincro_Mobile/Sincro.asmx";
    ws_btn_Enviar_foto.setOnClickListener(new View.OnClickListener() {
    
                public void onClick(View v) {
    
                    final String METHOD_NAME = "FOTO_and";
                    final String SOAP_ACTION ="http://tempuri.org/FOTO_and";
    
                    ws_resultado.setText("");
                    request = new SoapObject(NAMESPACE, METHOD_NAME);
                    Bitmap imagen_decodificar = BitmapFactory.decodeFile (Environment.getExternalStorageDirectory().getAbsolutePath()+
                            "/"+Globales.fotos_sgi+"/tomafoto1_resize_70.jpg");   
                    ByteArrayOutputStream out = new ByteArrayOutputStream();     
                    imagen_decodificar.compress(CompressFormat.JPEG, 70, out);     
                    byte[] imagebyte = out.toByteArray(); 
                    String strBase64 = Base64.encodeBytes(imagebyte); 
                    request.addProperty("user", "ap"); 
                    request.addProperty("pass", "qwerty"); 
                    request.addProperty("x", contrasena); 
                    request.addProperty("buffer",strBase64);
                    request.addProperty("filename","primer_foto.jpg");
                    //request.addProperty("Fecha_MOVIMIENTOS_y_FOTOS",dia_de_hoy.toString());
                    envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
                    envelope.dotNet = true; //se asigna true para el caso de que el WS sea de dotNet
                    envelope.setOutputSoapObject(request);
                    HttpTransportSE transporte = new HttpTransportSE(URL);
    
                    try {
                        transporte.call(SOAP_ACTION, envelope);
                        resultsRequestSOAP = (SoapPrimitive)envelope.getResponse();
                        ws_resultado.setText(resultsRequestSOAP.toString()) ;
                        } 
                    catch (IOException e) {
                        ws_resultado.setText(e.toString());;
                        }
                     catch (XmlPullParserException e) {
                         ws_resultado.setText(e.toString());;
                        }
    
                  }
            });
    

    In .net Webservice:

     <WebMethod()> Public Function FOTO_and(ByVal user As String, ByVal pass As String, _
        ByVal x As String, ByVal buffer As Byte(), ByVal filename As String) As String
    
            Dim Log As String = Validacion_User_EMEI(user, pass, x)
    
            If Log <> Estados_Sincro.OK Then
                Return Log
            End If
    
            '--VERIFICA QUE EXISTA LA CARPETA PARA ALMACENAR LA FOTO
    
            Dim Path_Fotos As String
    
            Path_Fotos = AppSettings.GetValues("Fotos")(0) + Now.ToString("yyMMdd")
            If Directory.Exists(Path_Fotos) = False Then
                Directory.CreateDirectory(Path_Fotos)
            End If
    
            '---VERIFICA QUE LA FOTO NO EXISTA
    
            If File.Exists(Path_Fotos + "\" + filename) Then
                Kill(Path_Fotos + "\" + filename)
            End If
    
            '--GUARDA LA FOTO
    
            Dim binWriter As New BinaryWriter(File.Open(Path_Fotos + "\" + filename, _
            FileMode.CreateNew, FileAccess.ReadWrite))
            binWriter.Write(buffer)
            binWriter.Close()
    
            Return Estados_Sincro.OK
    
        End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When retrieving a lookup code value from a table, some folks do this... Dim
I am retrieving an image from the SQL database into Byte() variable in VB.NET.
I am converting images to byte array and storing in a text file using
I'm retrieving image from DB using Stream. Need someone to help me to convert
I am using this to get image bytes from the database cmd.CommandText = select
I am retrieving facebook album images from facebook.I have calculating the image size using
I am retrieving results from twitter using jQuery using the following code: $(document).ready(function(){ var
I am retrieving an image(as a Bitmap) from res/drawable folder and displaying it using
When retrieving objects from an NSMutableArray in cocoa-touch is the below code ok? Should
I have a sqlite db from where i am retrieving images. I have to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.