vijay

welcome Netizen

welcome Netizen
Hi folks this site Share Basic Knowledge in .NET, DotNet, C#,DOT NET CODE, ASP.NET, VB.NET, DOT NET TRICKS,Dotnetcode,Android and Latest Technology Articles in VB,Android and ASP.NET

Wednesday, June 27, 2012

Tutorial to Connect dotnet web service in android application


Introduction:
It’s very interesting to a talk about web service, here I will explain to connect simple type dot net web service using android application. By using a web service we can easily get the desired data by sending request.
Before I start the topic we discuss, what are the files needed to start to access the web service.
Steps to follow:
1.       Make sure you have added the Ksopa2 jar file on your directory, if you need help to add the file refer the below link, download and follow the steps to add ksoap2 jar file.

http://www.dotnetcode.in/2012/06/adding-ksoap2-jar-file-or-using-soap.html

2.       Add the below code on androidManifest.xml file, below code permit the application to connect on intenet. Add the code outside the application tag in androidManifest.xml file

<uses-permission android:name="android.permission.INTERNET"/>

In a dotnet web service we must know about these things i.e.

1. Methods name-Here I call the methods name as MobileLogin
2. Namespace-Here I call namespace name as http://mobileapp.com
4. Passing parameter name-here I used usrname and password

So you before workout your project collect all the details about web service.

Use the below code
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.app.Activity;
import android.os.Bundle;
public class webActivity extends Activity {
                /** Called when the activity is first created. */
                HttpTransportSE androidHttpTransport;
                String NAMESPACE = "http://mobileapp.com";
                String METHOD_NAME = "MobileLogin";
                String SOAP_ACTION = "http://mobileapp.com/MobileLogin";
                String URL = "http://132.121.21.77:8080/MobileService.asmx?";
                @Override
                public void onCreate(Bundle savedInstanceState) {
                                super.onCreate(savedInstanceState);
                                setContentView(R.layout.main);

                                SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
                                SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                                                                SoapEnvelope.VER11);

                                request.addProperty("usrname ", "xxxxx@gmail.com");
                                request.addProperty("password ", "abcdefg");
//**********www.dotnetcode.in*********************
                                envelope.setOutputSoapObject(request);
                                envelope.implicitTypes = true;
                                envelope.dotNet = true;
                                int Timeout1 = 20000;
                                androidHttpTransport = new HttpTransportSE(URL, Timeout1);
                                androidHttpTransport.debug = true;
                                try {
                                                androidHttpTransport.call(SOAP_ACTION, envelope);
                                                Object response = envelope.getResponse();
                                                String rslt;
                                                //Finally you get the result from web service
                                                rslt=response.toString();
                                } catch (Exception e) {
                                                //**********www.dotnetcode.in*********************
                                                // TODO: handle exception
                                }
                }
}


That’s it above code works perfectly …Incase if you need the source code put your commnets with your email id…I will forward the source code.
Happy coding…keep reading

Tuesday, June 26, 2012

Start to use IPV6 Networks are here today


IP Address:
Ip address just like a phone number or address used to communicate with another phone or address.
IP stands for Internet Protocol it’s provided to your computer so it can communicate to internet service and other device.
IPv4 and IPv6:
IPv4 is the current version of the Internet Protocol. This system assigns a series of four numbers (each ranging from 0 to 255) to each device. IPv4 only allows for about 4 billion addresses and the Internet needs more room than that.
IPv6 is the new version of the Internet Protocol and expands the number of available addresses to a virtually limitless amount–340 trillion addresses.
Structure of IPv4 and IPV6
192.0.2.1 (for IPv4) and 2001:db8::1234:ace:6006:1e (for IPv6).
Launch:
IPv6 launched on june 6 2012
Reason to go for IPv6:
Due to usage of large number of device ipv4 address has not been enough to give the address to all device, so now they need some new format could support large environment system i.e. IPV6
Clearly the internet need to more ip address, so the current IPV4 is totally exhausted.
IPV6
Many enterprises start to use ipv6 environment .In IPV6 have more features than IPV4
Now Google start to monitoring the world wide IPV6 usage on internet, day by day they update the statistic on internet .Refer the links to see the percentage


Transitions to IPv6 networks, for many enterprises, seem years away. With just 0.51 percent of end users accessing the Internet via IPv6, the traffic is currently low. France has the greatest adoption (4.5 percent), followed by Japan (1.54 percent). And even though IPv4 addresses have been exhausted, But in india they don’t start to use IPv6 environment, but in future it will occupy by more. But it take some times.

Some manufacture company produce the product with IPV6 Environment support, Here is a summary of IPv6 adoption by vendors:

Smartphones and Tablets
Apple iOS (Apple iPhone, iPad) – IPv6 native support with version 4, released June 2010.
Android (Samsung, HTC, Motorola, LG, etc.) – IPv6 support began with version 2.3.4, released in 2011
PCs and Macs
Microsoft Windows – began with XP dual stack in 2001, along with Server 2000 SP1.
Developer code began as early as 1998 with MSRIPv6. Current version Windows Server
2008 and Windows 7 have full native IPv6.
Apple MAC OS X – Mac OS X has shipped support for IPv6 since Mac OS X v10.1, and
enabled it by default since Mac OS X v10.3. Latest version is 10.7.3 released Feb 2012.
Network and Security Infrastructure
Network Switches and Routers – Cisco, Juniper, HP, and Huawei have also supported
IPv6 in their operating systems. Features supported by vendors have changed from year
to year.
Firewalls – Similarly, CheckPoint, Juniper Netscreen, and Cisco Pix have supported IPv6
for years. The key question here is feature parity.
WAN Optimization – Again, feature parity with IPv6 is key. Many vendors claim IPv6
capability, but that claim only applies to a subset of their available features. Blue Coat
is the only WAN optimization vendor that provides all acceleration services over IPv6;
Riverbed and Cisco do not.

Let us see  what features hold IPv6  environment growth..

Monday, June 25, 2012

Adding ksoap2 jar file or Using soap service for android development


Recently i have been working with an android application, so here i share some tutorial about android application development

Now i share about to add KSoap2 android assembly jar file in ecclipse, By connecting  web service to android web application, we must import the following namespace.

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

so before import the namespace we must add the KSoap2 android assembly jar file

Using the below links you can get the jar file
or
you need any  higher version use the below link to get the latest version

Once you download the ksoap jar file, you must add the jar file inside the project folder.

·         Check the libs folder found on your project folder, if it’s not then create a new folder with name libs.
·         And copy ksoap jar file into the libs folder.
·         Right click the ksoap Jar file click Build path --->Add to build path
·         Then the ksoap jar files into android dependencies.

That’s it work has been done. This is the correct way to add the jar file.
Now you can import namespace work with your web service project
Coming post i have explained details about use web service in android application.
Happy coding….Keep Reading

Thursday, June 21, 2012

Redirect from Old URL to New URL link in asp.net


Here i share the code to redirect old URL link to new URL link, i have explained the case with some example

Description:
Take an example as below as old link used in website
www.dotnetcode.in/details.aspx
Now i have deleted the page details.aspx, instead of details.aspx now i am using new page   user.aspx page URL is www.dotnetcode.in/user.aspx
Normally search engine crawl our old link so it always shows our Old link in search engine result. If the user comes to our website using
Old link we have to redirect the user to the correct page i.e. to new link.

To accomplish the above case we have to add the bit of code in Global.asax file
Add the below sub function in Global.asax file
VB.NET Code:

Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
        If System.Web.HttpContext.Current.Request.RawUrl.Contains("details.aspx") Then
            System.Web.HttpContext.Current.Response.Clear()
            System.Web.HttpContext.Current.Response.Status = "301 Moved Permanently"
            System.Web.HttpContext.Current.Response.AddHeader("Location", "http://www.dotnetcode.in/user.aspx")
            System.Web.HttpContext.Current.Response.End()
        End If
    End Sub
  
  
C# Code:

  If (HttpContext.Current.Request.RawUrl.Contains("details.aspx")) Then
    {
        Response.Clear();
        Response.Status = "301 Moved Permanently";
        Response.AddHeader("Location", "http://www.dotnetcode.in/user.aspx");
        Response.End();
    }

Keep Reading. Post your valuable comments

Wednesday, June 20, 2012

Change Your destiny by controlling your thoughts


Thoughts are a double edged sword. they are the foundation for the creative  process and they are also the basis for turning our mindset negative and even destructive. it is the same kind that creates the eternal art of leonardo da vinci,the mathematic genius of albert einstein and also madness of adolf hitler..

It’s now research found that on an average 60,000 thoughts cross over minds everyday. The sad is part is that most of us have no control over our thoughts. Typically all we have good though in our mind it always leads to success.
When you are destruction or distraught, always have an good thought, Positive thought increase our confident energy level.

Everyone have good and bad though in our mind, but most we get sucked into depressive thought.
How does one try to control thought?
One way its old practice to control the anger is to count letter backward from fifty to zero.

Another method is to try to recall the happy moment of your life. Like memories of your childhood, the beautiful sunset that you saw and the last tender moment with your mother. In most of case we spending time alone, whenever you felt down, recall happy moments then smile come on your face.

Your life is not hopeless as there are many things that make life worth living.
The finest logical deduction I have read abut how thoughts shape our destiny is by His Holiness the 14th Dalai Lama. He says:

Take care of your Thought because they become Words.
Take Care of your Words they will become Actions
Take Care of our Action they will become Habits.
Take Care of your Habits they will from your Character.
Take Care of your Character because it will form your Destiny.
And your Destiny will be your Life!




Android EditText control design and properties event



In this article, you will learn to apply design to android edittext control to get the text input from the user by using eclipse.
But before apply the below design you must know the basic knowledge to add xml file in drawable folder
1.     Add edit text control to the layout
<EditText
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10">
    2. Set the water mark text in edit text control
You can also set the watermark text using an attributes
android:hint="@string/enter_your_email"
3.Apply Designs to edittext control
Then you can apply the design using by adding the below xml file in drawable folder.
Steps to follow:
Right Click the Drawable folder ->add new xml file with shape layout and add the below code.
css.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:state_focused="true">
    <shape>
        <solid android:color="#FF8000"/>
        <stroke
            android:width="2.3dp"
            android:color="#FF8000" />
         <corners
            android:radius="15dp" />
    </shape>
</item>
<item android:state_pressed="true" android:state_focused="false">
    <shape>
        <solid android:color="#FF8000"/>
        <stroke
            android:width="2.3dp"
            android:color="#FF8000" />     
        <corners
            android:radius="15dp" />      
    </shape>
</item>
<item android:state_pressed="false" android:state_focused="true">
    <shape>
        <solid android:color="#FFFFFF"/>
        <stroke
            android:width="2.3dp"
            android:color="#FF8001" /> 
        <corners
            android:radius="15dp" />                         
    </shape>
</item>
<item android:state_pressed="false" android:state_focused="false">
    <shape>
        <gradient
            android:startColor="#F2F2F2"
            android:centerColor="#FFFFFF"
            android:endColor="#FFFFFF"
            android:angle="270"
        />
        <stroke
            android:width="0.7dp"               
            android:color="#BDBDBD" />
        <corners
            android:radius="15dp" />           
    </shape>
</item>
<item android:state_enabled="true">
    <shape>
        <padding
                android:left="4dp"
                android:top="4dp"
                android:right="4dp"
                android:bottom="4dp"
            />
    </shape>
</item>
</selector>

Now the main xml layout add the css.xml file in edit text control
  <EditText
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:textColor="#372c24"
        android:hint="@string/enter_your_email"
        android:background="@drawable/css" >
     
    </EditText>


4. Events in EditText control.

Here the list of events used in Edit text control

1.       When a user clicks on the control. In this case, register a listener using the setOnClickListener() method.
2.      When a user long-clicks on the control. In this case, register a listener using the setOnLongClickListener() method.
3.      When a user presses a key within the control. In this case, register a listener using the setOnKeyListener() method.
4.      When a user changes focus to or from the control. In this case, register a listener using the setOnFocusChangedListener() method.

I hope you like this article ..share your comments here