Thursday, December 29, 2011

Google Web Toolkit Overview




Google Web Toolkit Overview


Google Web Toolkit (GWT) is a development toolkit for building and optimizing complex browser-based applications. Its goal is to enable productive development of high-performance web applications without the developer having to be an expert in browser quirks, XMLHttpRequest, and JavaScript. GWT is used by many products at Google, including Google Wave and the new version of AdWords. It's open source, completely free, and used by thousands of developers around the world.


Wednesday, December 28, 2011

Hardware RAID on DELL servers



Step-by-Step Guide to Configure Hardware RAID on DELL servers with Screenshots


Expanding the capacity of a server by adding new disk drives is a typical activity for administrator. In this article, let us review how to add two new disk drives to the DELL server and create RAID 1 using “Dell PowerEdge Expandable RAID Controller – PERC” configuration utility. This tool is also called as “PERC/CERC Bios Configuration Utility”.

If you are using the latest DELL Servers, please refer to the article that explains
how to create RAID on PERC 6/i Integrated BIOS Configuration Utility.

1. Launch PERC/CERC BIOS Configuration Utility.

2. Go to Configure - View/Add Configuration

3. Status of the new disk drives

4. Make the disk drives online

5. Configure the disk drives

6. Select RAID Level.

Debug certificate expired



Strange Eclipse Error developing an Android application:
<< Debug certificate expired >>
Solution :
Delete debug certificate under ~/.android/debug.keystore (on Linux and Mac OS X); the directory is something like %USERPROFILE%/.androidon Windows.


Wednesday, December 21, 2011

Including multiple Packages to Manifest





How to put two or more packages together into one project under "src" folder 
 - avoiding "R cannot be resolved"



http://stackoverflow.com/questions/3935443/android-including-multiple-java-packages-to-manifest

Friday, November 4, 2011

ToDo : Android WCF adapter class

How to manipulate a  RESTful WCF Web Service in Android


after 9 steps of simple WCF samples 
Step 9 : Android Client reading JSON WCF REST
Step 8 : WCF RESTful GET JSON List with FIDDLER
it's time to incorporate them all in a single class called WCFadapter ... 

On the model of DBAdapter in the article Creating and Using Databases in Android
it's interesting to crate a similar class named WCFadapter ... 


It's also useful these samples : 

Building an Android Application in 6 Steps

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


http://developer.android.com/reference/android/util/Log.html

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: 
CLICK on PICTURES to ZOOM




Parsing JSON with JSONObject and JSONArray :
http://code.google.com/p/jtelmon/source/browse/trunk/AndroidViews/src/net/learn2develop/AndroidViews/GetPersons02.java




And finally JSON data from the WCF RESTful WebService 
http://code.google.com/p/jtelmon/source/browse/trunk/AndroidViews/RestService
displayed in a SimpleList
http://code.google.com/p/jtelmon/source/browse/trunk/AndroidViews/src/net/learn2develop/AndroidViews/GetPersons03.java

ListView GraphicalLayout :
http://code.google.com/p/jtelmon/source/browse/trunk/AndroidViews/res/layout/listview.xml


http://senior.ceng.metu.edu.tr/2009/praeda/2009/01/11/a-simple-restful-client-at-android/

Android JSON Parser Example

JSON in Android - Tutorial

Tuesday, November 1, 2011

How to format blog source code


http://libg.org/2008/09/11/how-to-format-source-code-in-your-blog/

http://google-code-prettify.googlecode.com/svn/trunk/README.html
http://code.google.com/p/syntaxhighlighter/wiki/Usage

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.


http://www.codeshode.com/2010/06/format-my-source-code-for-blogging.html
http://www.codeshode.com/2011/07/format-source-code-for-blogging-tool.html

Step 8 : WCF RESTful GET JSON List with FIDDLER


http://pantestmb.blogspot.com/2011/10/step-3-from-soap-to-wcf-restful-get.html

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 : 192.168.61.3 :
http://192.168.61.3/RestServicePost/RestServiceImpl.svc/json/getallpersons

The code behind the above link : 

        [OperationContract]
        [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);
            dbConn.Open();
            string sqlSelect = "select * from users ";
            SqlDataAdapter da = new SqlDataAdapter(sqlSelect, dbConn);
            DataTable dt = new DataTable();
            SqlCommand dbCommand = new SqlCommand(sqlSelect, dbConn);
            da.Fill(dt);
            dbConn.Close();
            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);
                list.Add(target);
            }
            return list.ToArray();
        }

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







Monday, October 31, 2011

SUSE : Eclipse INDIGO Subversion - Google.Code


http://pantestmb.blogspot.com/2011/08/eclipse-subversion-subversive.html












SUSE : Eclipse Indigo - Android Development Plugin


http://pantestmb.blogspot.com/2011/08/eclipse-indigo-with-android-development.html



  1. Start Eclipse, then select Help > Install New Software....
  2. Click Add, in the top-right corner.
  3. In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following URL for the Location:
    https://dl-ssl.google.com/android/eclipse/
  4. Click OK Note: If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons).
  5. In the Available Software dialog, select the checkbox next to Developer Tools and click Next.
  6. In the next window, you'll see a list of the tools to be downloaded. Click Next.
  7. Read and accept the license agreements, then click Finish. Note: If you get a security warning saying that the authenticity or validity of the software can't be established, click OK.
  8. When the installation completes, restart Eclipse.












Friday, October 28, 2011

Step 7 : POST data from JSON Android Client to WCF REST WebService

POST JSON data from an Android Client to a WCF RESTful WebService

The full Android.java source code is on Google Code :
http://code.google.com/p/jtelmon/source/browse/trunk/AndroidViews/src/net/learn2develop/AndroidViews/

The full Eclipse Indigo 3.7 - Android  project zipped on Google Docs :
https://docs.google.com/leaf?id=0BzKVfKe--t_cMDU5OTU5MDQtNDQzOC00YjE3LTlhODgtYjE1ZDhmZWFmZjc1&hl=en_GB


All files of the WCF RESTful Web Service are also on Google Code :
http://code.google.com/p/jtelmon/source/browse/trunk/AndroidViews/RestService

The full Visual Web Developer project -  VWD  Express 2010 also on Google Docs :
https://docs.google.com/leaf?id=0BzKVfKe--t_cODIwZWE2M2QtZTUwMy00Yjg1LTljMjUtYTA3MGI4YmM5OGZm&hl=en_GB

First we tried to post XML formatted data to a WCF Web Service with FIDDLER ( step 5 ) :
http://pantestmb.blogspot.com/2011/10/pass-multiple-body-parameters-wcf-rest.html

Then tried to post JSON data to a WCF Web Service with FIDDLER ( step 6 ) :
http://pantestmb.blogspot.com/2011/10/wcf-rest-fiddler-json-request-body.html

Now , knowing that the WCF Web Service responds OK with both XML and JSON ,
we can take our simple sample project to the ANDROID Client Test :


http://code.google.com/p/jtelmon/source/browse/trunk/AndroidViews/src/net/learn2develop/AndroidViews/SavePerson.java

package net.learn2develop.AndroidViews;


import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.util.Log;
import android.widget.EditText;
import android.widget.Toast;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
// import org.json.JSONObject;
import org.json.JSONStringer;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;

public class SavePerson extends Activity {

private final static String SERVICE_URI = "http://192.168.61.3/RestServicePost/RestServiceImpl.svc";

@Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);

       setContentView(R.layout.main);
       // String plate = new String("test");
       // POST request to
            HttpPost request = new HttpPost(SERVICE_URI + "/json/adduser");
            request.setHeader("Accept", "application/json");
            request.setHeader("Content-type", "application/json");
         
            String not = new String(" ");
            try {
            // Build JSON string
            JSONStringer vehicle = new JSONStringer()
                .object()
                    .key("rData")
                        .object()
                            .key("details").value("bar|bob|b@h.us|why")
                        .endObject()
                    .endObject();
         
            StringEntity entity = new StringEntity(vehicle.toString());
         
            Toast.makeText(this, vehicle.toString() + "\n", Toast.LENGTH_LONG).show() ;
         
            request.setEntity(entity);
         
            // Send request to WCF service
            DefaultHttpClient httpClient = new DefaultHttpClient();
            HttpResponse response = httpClient.execute(request);
            // Log.d("WebInvoke", "Saving : " + response.getStatusLine().getStatusCode());
            Toast.makeText(this, response.getStatusLine().getStatusCode() + "\n", Toast.LENGTH_LONG).show() ;
         
            }catch (Exception e) {
            not = "NOT ";
            }
         
            Toast.makeText(this, not + " OK ! " + "\n", Toast.LENGTH_LONG).show() ;
         
         

}  
}


http://code.google.com/p/jtelmon/source/browse/trunk/AndroidViews/RestService/IRestServiceImpl.cs


      [OperationContract]
        [WebInvoke(Method = "POST",
            ResponseFormat = WebMessageFormat.Json,
            RequestFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "json/adduser")]
        PersonData AddJsonUser(RequestData rData);

In our simple example we create a JSONStringer object with "rData" key and "details" sub-key ;
      "rData" is the variable of the function "AddJsonUser" ;
"details" is the single property of the object "RequestData" :
 http://code.google.com/p/jtelmon/source/browse/trunk/AndroidViews/RestService/RequestData.cs


    [DataContract(Namespace = "")]
    public class RequestData
    {
        [DataMember]
        public string details { get; set; }
    }





The string  "bar|bob|b@h.us|why" of the JSONStringer is hard-coded to simplify things ;
After being parsed - it ends up in the SQLS table "Users" : 





http://code.google.com/p/jtelmon/source/browse/trunk/AndroidViews/RestService/RestServiceImpl.svc.cs
AddUser is the function triggered by the POST WCF Webservice
http://192.168.61.3/RestServicePost/RestServiceImpl.svc/json/adduser
with a JSON request body -  JSONStringer vehicle : 


        public PersonData AddUser(RequestData rData)
        {
            bool returnBool = false;

            var data = rData.details.Split('|');
            var response = new PersonData
            {
                Name = data[0],
                User = data[1],
                Email = data[2],
                Password = data[3]
            };

            SqlConnection dbConn = new SqlConnection(connStr);
            string sqlStr = "INSERT INTO users(username,name,email,password)
                          values('" + data[0] + "', '" + data[1] + "', '" + data[2] + "', '" + data[3] + "');";
            SqlCommand dbCommand = new SqlCommand(sqlStr, dbConn);
            try
            {
                dbConn.Open();
                if (dbCommand.ExecuteNonQuery() != 0)
                {
                    returnBool = true;
                }
                dbConn.Close();
            }
            catch
            {
                returnBool = false;
            }
            return response;
        }

        public PersonData AddJsonUser(RequestData rData)
        {
            return AddUser(rData);
        }



~ ~ ~


the SQL Server Database has only one table - Users :

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


Registering ASP.NET on IIS

Registering ASP.NET on IIS after installing the .NET Framework




aspnet_regiis.exe, it is located under %WindowsDir%\Microsoft.NET\Framework\vx.y.zzzz\ and should be called with the -i parameter: aspnet_regiis.exe -i








run aspnet_regiis.exe -i in VS 2010 command prompt.
http://pantestmb.blogspot.com/2011/10/svc-integrated-bad-module.html

Wednesday, October 26, 2011

Step 6 : WCF REST & FIDDLER JSON - request body


WCF REST * FIDDLER JSON - request body , headers and content type : 



  [DataContract(Namespace = "")]
    public class PersonData
    {
        [DataMember]
        public string Name { get; set; }


        [DataMember]
        public string User { get; set; }


        [DataMember]
        public string Email { get; set; }


        [DataMember]
        public string Password { get; set; }
    }




    [OperationContract]
        [WebInvoke(Method = "POST",
            ResponseFormat = WebMessageFormat.Json,
            RequestFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped,
            UriTemplate = "jsontestpersondatapost")]
        PersonData JsonTestPersonDataPost(PersonData pd);





       public PersonData TestPersonDataPost(PersonData pd)
        {
            var response = new PersonData
            {
                Name = pd.Name,
                User = pd.User,
                Email = pd.Email,
                Password = pd.Password
            };
            
            return response;
            // return pd;
        }


        public PersonData JsonTestPersonDataPost(PersonData pd)
        { 
            return TestPersonDataPost(pd);
        }









POST http://192.168.61.3/RestServicePost/RestServiceImpl.svc/jsontestpersondatapost HTTP/1.1
User-Agent: Fiddler
Content-Type: application/json
Host: 192.168.61.3
Content-Length: 86


{ "pd" : { "Email":"bo@se.us" , "Name":"amab" , "Password":"egti" , "User":"brac" } } 










HTTP/1.1 200 OK
Content-Length: 99
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/7.0
X-Powered-By: ASP.NET
Date: Wed, 26 Oct 2011 18:31:54 GMT


{"JsonTestPersonDataPostResult":{"Email":"bo@se.us","Name":"amab","Password":"egti","User":"brac"}}










Tuesday, October 25, 2011

POST JSON from Android using HttpClient




POST JSON from Android using HttpClient




Step 5 : Pass multiple body parameters in wcf rest



How pass multiple body parameters in wcf rest

using webinvoke method(Post or PUT)








Even If you have blank namespace  [DataContract(Namespace = "")] you have to put 
xmlns="" in the request body ... ( see the pictures below )
Whithout xmlns="" in the request body , problems can appear 






  [OperationContract]
        [WebInvoke(Method = "POST",
            ResponseFormat = WebMessageFormat.Xml,
            RequestFormat = WebMessageFormat.Xml,
            BodyStyle = WebMessageBodyStyle.Bare,
            UriTemplate = "testpersondatapost")]
        PersonData TestPersonDataPost(PersonData pd);


  [DataContract(Namespace = "")]
    public class PersonData
    {
        [DataMember]
        public string Name { get; set; }

        [DataMember]
        public string User { get; set; }

        [DataMember]
        public string Email { get; set; }

        [DataMember]
        public string Password { get; set; }
    }


       public PersonData TestPersonDataPost(PersonData pd)
        {
            var response = new PersonData
            {
                Name = pd.Name,
                User = pd.User,
                Email = pd.Email,
                Password = pd.Password
            };
            
            return response;
            // return pd;
        }