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 8103403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:32:24+00:00 2026-06-05T23:32:24+00:00

Sending XML from C# Server and receiving it it in Android Java client This

  • 0

Sending XML from C# Server and receiving it it in Android Java client

This is what the received XML look likes:

<?xml version="1.0" encoding="utf-8"?>.....

This is the c# send code

// convert the class WorkItem to xml
MemoryStream memoryStream = new MemoryStream();
XmlSerializer xs = new XmlSerializer(typeof(WorkItem));
XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);
xs.Serialize(xmlTextWriter, p);

// send the xml version of WorkItem to client
byte[] data = memoryStream.ToArray();
clientStream.Write(data, 0, data.Length);
Console.WriteLine(" send.." + data);
clientStream.Close();

In Java i just do:

in = new DataInputStream(skt.getInputStream());
String XMlString = in.readLine();

Everything is working if i every time remove the 3 first characters from XMlString.
I would really like to do this in a better way if it’s possible

*UPDATE adding the Android java client

@Override
protected String doInBackground(Long... params) {

    textTopInfo.setText("Loading workitems..");

    DataOutputStream out = null;
    DataInputStream in = null;

    try {

        Socket skt = new Socket(Consts.SERVER_URL_1, Consts.SERVER_PORT_1);
        skt.setSoTimeout(10000); //10 sec timout
        out = new DataOutputStream(skt.getOutputStream());
        in = new DataInputStream(skt.getInputStream());

        // check valid user id
        String id = prefs.getString("id", "");

        if(id.equals(""))
            return "Open menu and enter User Id";

        String theString =  Consts.PUSH_GET_WORKITEM + ":" + id ;

        out.write(theString.getBytes());

        BufferedReader d = new BufferedReader
        (new InputStreamReader(skt.getInputStream()));
        String XMlString = d.readLine();

            // here I remove the BOM
        XMlString = XMlString.substring(3);

        Log.d(TAG, "GF");   

        XStream xstream = new XStream();
        xstream.alias("WorkItem", WorkItem.class);
        xstream.alias("OneItem", OneItem.class);
        pl = (WorkItem)xstream.fromXML(XMlString);

    } catch (Exception e) {

        return "cannot connect to server " + e.toString();

    }finally{
        //kill out/in
        try {
            if(out != null)
                out.close();
            if(in!=null)
                in.close(); 
        } catch (IOException e) {

        }
    }
    return "here is the list";
}
  • 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-06-05T23:32:27+00:00Added an answer on June 5, 2026 at 11:32 pm

    the method readLine is deprecated in Java 1.7; from the javadocs:

    readLine()
    Deprecated.
    This method does not properly convert bytes to characters. As of JDK 1.1, the preferred way to read lines of text is via the BufferedReader.readLine() method. Programs that use the DataInputStream class to read lines can be converted to use the BufferedReader class by replacing code of the form:
    DataInputStream d = new DataInputStream(in);

    with:
    BufferedReader d
    = new BufferedReader(new InputStreamReader(in));

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I write a client-server application which will be sending an .xml file from the
I've successfully connected to XMPP server (from android XMPP client), and I can send
I have a client server application that sends XML over TCP/IP from client to
I want to create one simple application for sending request from iphone(client) by using
One desktop application needs to get some services from server. For example sending some
Scenario: Sending XML, generated using php, via cURL to an external server for parsing.
I am parsing an XML coming from a web server and the parsing sometimes
I have a simple question about sending a file (XML file) from my webapp
I am sending a XML to a webserver using PHP, and the server returns
I'm working with Apache mod_dav compiled on my own server. My client is built-from-scratch

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.