×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Jun 2009
    Location
    Turkey
    Posts
    9

    Exclamation byte[] data transfer between J2ME and .NET Web Service?

    Hi,

    I want use byte[] data between J2ME and .NET web service.

    data flow >>>> Data = "kadir bla bla" > Compressed with GZipStream (on .net webservice) > service return (this data) > J2ME > this data (base64Binary) convert to byte[] (in J2ME - the problem here) > GZIP.inflate(byte[] (this data)) > Orginal Data > "Kadir bla bla"

    >>>> How Can I use this data in J2ME as byte[] , How I can convert base64Binary data to byte array in J2ME?

    .NET Web Service side:
    <<CODE>>
    public byte[] HelloWorld()
    {
    byte[] buffer = Encoding.ASCII.GetBytes("Kadir");
    byte[] buffer2 = Compress(buffer);
    return buffer2;
    }

    <<RETURN>>
    <?xml version="1.0" encoding="utf-8" ?>
    <base64Binary xmlns="http://tempuri.org/">H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/SvVK1+B0oQiAYBMk2JBAEOzBiM3mkuwdaUcjKasqgcplVmVdZhZAzO2dvPfee++999577733ujudTif33/8/XGZkAWz2zkrayZ4hgKrIHz9+fB8/In6vbFbU/w8hrXEvBQAAAA==</base64Binary>



    >>> J2ME Client Side:

    public static String downloadDataFromHttp(String Url)
    {
    StreamConnection conn;
    int ch;
    StringBuffer data;

    try
    {
    data = new StringBuffer();
    conn = (StreamConnection)Connector.open(Url);
    InputStreamReader r = new InputStreamReader(conn.openInputStream(),"UTF-8");
    while ( (ch=r.read()) > -1 )
    {
    data.append((char)ch);

    }
    conn.close();
    r.close();

    String reply = data.toString();
    return reply;
    }
    catch(Exception e)
    {
    return e.toString();
    }
    }

    after,I choose to pure data with substring()

    H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/SvVK1+B0oQiAYBMk2JBAEOzBiM3mkuwdaUcjKasqgcplVmVdZhZAzO2dvPfee++999577733ujudTif33/8/XGZkAWz2zkrayZ4hgKrIHz9+fB8/In6vbFbU/w8hrXEvBQAAAA== >> data flow >> "kadir" > Compressed with Gzip (on .net webservice) > service return (this data) > J2ME > this data convert byte[] (in J2ME) > GZIP.inflate(byte[] (this data)) > Orginal Data > End


    Best regards,

  2. #2
    Registered User
    Join Date
    Jun 2009
    Location
    Turkey
    Posts
    9

    Thumbs up Re: byte[] data transfer between J2ME and .NET Web Service?

    Hi all,

    I solved the my problem.

    I'm asking the question and I would answer. :P


    String bases64 = "H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/SvVK1+B0oQiAYBMk2JBAEOzBiM3mkuwdaUcjKasqgcplVmVdZhZAzO2dvPfee++999577733ujudTif33/8/XGZkAWz2zkrayZ4hgKrIHz9+fB8/In6vbFbU/w8hrXEvBQAAAA==";

    try {

    byte[] dizi2 = com.java4ever.apime.io.GZIP.inflate(Base64.decode(bases64));

    String sss = new String(dizi2);

    setTitle(sss);

    } catch (IOException ex) {
    ex.printStackTrace();
    }

Similar Threads

  1. Using Compressed data in J2ME (data from .Net Web Service)
    By kadir950 in forum Mobile Java General
    Replies: 3
    Last Post: 2010-04-29, 16:01
  2. Web Services in J2ME?
    By sunil_bhambani123 in forum Mobile Java Networking & Messaging & Security
    Replies: 3
    Last Post: 2009-02-23, 09:26
  3. Calling web service under Symbian
    By tb337 in forum Symbian
    Replies: 0
    Last Post: 2003-11-30, 16:49
  4. .net web service & Nokia Card Phone 2.0
    By kfchong1 in forum PC Suite API and PC Connectivity SDK
    Replies: 1
    Last Post: 2003-02-23, 11:04

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×