Tuesday, November 8, 2011

Step 10 : Android client saves data to WCF REST


CREATE TABLE [dbo].[Users](
[UserName] [varchar](100) NOT NULL,
[Name] [varchar](100) NOT NULL,
[EMail] [varchar](100) NOT NULL,
[Password] [varchar](100) NOT NULL

Friday, November 4, 2011

Wednesday, November 2, 2011

Die Internet Explorer , Die !

Is Internet Explorer Dying? | ZDNet

In October 2011, according to NetMarketShare, IE is barely above the 50% mark of desktop browsers with 52.63%.
That only tells part of the story though.
On the smartphone/tablet market, IE is a total non-player with IE and Microsoft Pocket IE combined having only 0.17% of the market.
Put the total Web browser markets together, and you’ll see IE has finally dropped below the 50% mark.
IE now has only 49.58% of the total market.

Android Log.i LogCat


Log.i can be used to log to LogCat Window in Eclipse :
Log.d can be used in debugging ;
Windows -> Show View -> Other -> Android -> LogCat

Debugging in Android using Eclipse

Android Essentials: Application Logging

WTF - What a Terrible Failure : 
Log.e() method is used to log errors.
Log.w() method is used to log warnings.
Log.i() method is used to log informational messages.
Log.d() method is used to log debug messages.
Log.v() method is used to log verbose messages.
Log.wtf() method is used to log terrible failures that should never happen. 

Step 9 : Android Client reading JSON WCF RESTful Web Service

Step 9 : Android Client reading JSON data from a WCF RESTful Web Service

Google Code of raw JSON data displayed on a Toast from the WebService: 

Parsing JSON with JSONObject and JSONArray :

And finally JSON data from the WCF RESTful WebService 
displayed in a SimpleList

ListView GraphicalLayout :


Android JSON Parser Example

JSON in Android - Tutorial

Tuesday, November 1, 2011

How to format blog source code



There is WordPress plug-in Google Syntax Highlighter for WordPress, and convenient for WordPress users to integrate to your WordPress blog site. The plug-in author may be wrong here, because the true Google Code highlight tool is Google Code Prettify.


Step 8 : WCF RESTful GET JSON List with FIDDLER


In Step 3 there was a sample of transforming a SOAP Web Service into a WCF RESTful one
with "application/xml" Content-Type ;

In step 7 - there are all the details about the full source code

To be accessed from a Android Client the sample must switch from XML to JSON data-content ;

Let's consider that the webservice is installed on the IP : :

The code behind the above link : 

        [WebInvoke(Method = "GET",
            ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "json/getallpersons")]
        PersonData[] getJsonPersons();

        public PersonData[] getJsonPersons()
            return getAllPersons();

        public PersonData[] getAllPersons()
            SqlConnection dbConn = new SqlConnection(connStr);
            string sqlSelect = "select * from users ";
            SqlDataAdapter da = new SqlDataAdapter(sqlSelect, dbConn);
            DataTable dt = new DataTable();
            SqlCommand dbCommand = new SqlCommand(sqlSelect, dbConn);
            List list = new List();
            foreach (DataRow row in dt.Rows)
                // Person target = Activator.CreateInstance();
                PersonData target = new PersonData();
                target.Name = row["Name"].ToString();
                target.User = row["UserName"].ToString();
                target.Email = row["EMail"].ToString();
                target.Password = row["Password"].ToString();
                // DataColumnAttribute.Bind(row,target);
            return list.ToArray();

Pictures about what the code does ;
FIDDLER gets from the webservice all the persons from the database in JSON format :