Showing posts with label Programming Technology. Show all posts
Showing posts with label Programming Technology. Show all posts

Wednesday, October 3, 2012

Tutorial of Android Web Service Application with VB .Net

Hello Friends,

Today I am going to discuss with you that how to make web service in .NET and how to call it from android.

You need following tools to develop application.
  • Microsoft Visual Studio 2008 (to develop web methods)
  • Internet Infomation Service (IIS 6 for Windows XP and IIS 7.5 for Win7) (virtual server)
  • Android SDK (Min API Level-7) (to call web methods)
  • Eclipse HELIOS
  • KSOAP-android-2.5.2 jar file (it's a java class file which your have to include in your code.

Step 1 : You need  Microsoft Visual Studio 2008 to develop web-service method. You can download it from here.

Step 2: You can download IIS 7.5 from here.

Step 3: You can download android SDK from here.

Step 4: You can download Eclipse HELIOS from here.

Step 5: You can download KSOAP 2.5.2 jar file from this link

You have to explicitly add external libraries in your project by following step :

Right click on your project and select properties and click on Java Build Path -> Libries(Tab) -> Add External JARs.. (Button) and specify you KSOAP 2.5.2 file path.

Note : You need Dot Net Framework 3.5 to run IIServer on your local computer. You can externally download and install it from here.

Install all above softwares on your local computer and integrate your eclipse with android SDK.

You can show step to create web method from this link.

Step to call web service from android is mentioned in this link.

Monday, October 1, 2012

How to Create Web Service in Microsoft Visual Studio 2008 in Windows7

Here I am going to explain you how to develop web service in Microsoft Visual Studio 2008.

You need Internet Infomation Server (IIS) 7.5 as virtual server to run the web service.

You can download IIS 7.5 from here.
You need Dot Net Framework 3.5 to install IIS 7.5 You can download it from this link.

Now to configure IIS you have to go in control panel - > Programs and Features -> Turn Windows Features on or off.

Click on  Turn Windows Features on or off.

Now check 2 check box listed below :

  • Internet Information Service
  • Internet Information Service Hostable Web Core
Now Click on OK button and Restart your computer.

Now, You can check whether your web server works properly or not by following step :
  • Open your web browser and type localhost
  • If it successfully show you IIS 7 page then your web service will work properly otherwise something goes wrong.
Now Time to implement web method. To develop web method you need to open Microsoft Visual Studio 2008 in Administrative mode. You can right click on Microsoft Visual Studio 2008 and click on Run as Administrator. It will open IDE of Microsoft Visual Studio in Administrator mode.

Now to develop new web-service follow the following steps :

  1. You have to create new project so that go to File Menu -> New -> Website
  2. Select ASP.NET Web Service in Template.
  3. Now following window will be appear.

    3.  Now select HTTP in Location Option form Drop Down box because our method is resides on server and provide name of your web-service in following format : http://localhost/your-application-name.
    4.  Now select Visual Basic in Language Option because here I am going to explain code in VB,
    5.  Now click on Ok button.
    6.  By Default one method named HelloWorld will be created and it will return HelloWorld while one can invoke it.
    7. Define your own method and specify your logic.
    8. Do not forget write <WebMethod()> _  at every beginning of  method because it defines that this method is web method and called by application. If your not specify <WebMethod()> _  then that method will be used as private/local method.
    9. Now your web method will be define successfully.

You can manually run your web service from browser by written as follow :

http://localhost/your-application-name/Service.asmx


Android Code for calling web service method click on this link

Wednesday, April 4, 2012

Why Dynamic Programming Languages Are Slow..??


In a statically typed language, the compiler knows the data-type of a variable and how to represent that.

In a dynamically-typed language, it has to keep flag describing the actual type of the value of the variable, and the program has to perform a data-dependent branch on that value each time it manipulates a variable.  It also has to look up all methods and operators on it.

The knock-on effect of this on branching and data locality is lethal to general purpose run time performance.

That’s why the dynamic language JIT benchmarks emphasise near-C speed on small inner loops but steer clear of large data-structures and data manipulation problems.

These slides by IBM researchers describe (page 3) the performance problems of dynamism:


  • Every variable can be dynamically-typed: Need type checks
  • Every statement can potentially throw exceptions due to type mismatch and so on: Need exception checks
  • Every field and symbol can be added, deleted, and changed at runtime: Need access checks 
  • The type of every object and its class hierarchy can be changed at runtime: Need class hierarchy checks
  • Properties mean assignments may in fact be setters: Need checks for existing values before assignment
  • Properties mean references may in fact be getters: Need checks on values when referencing


    To these I would add a couple of killers:

  • Properties mean assignments may in fact be setters: Need checks for existing values before assignment
  • Properties mean references may in fact be getters: Need checks on values when referencing

With modern dynamic language compilers there are buckets of neat tricks they can do to specialize the hot paths you use.  I’m glad that’s gathering speed as we rediscover or reapply old tricks and learn new ones and they all compose together.

But fundamentally, when its done that, these traces have to inter-operate with as yet not known code-paths.  So all escaped data has to keep its type within reach.  Its at this level where you are nearly at the speed of a classic statically compiled language that I am looking at the difference and pronouncing dynamic languages fundamentally slow:

I really want dynamically-typed languages like Python to be fast.  I’ve tried using Python for classic server programming - the domain of ‘systems languages’ - and really been bitten by lack-luster performance.  I’m contemplating a rewrite of one server in Java right now, sadly. 

Therefore, I spend time thinking about how to actually statically compile Python.  After all, that’d be my dream programming language!  But whenever I think through how to mix dynamic and dynamically-typed code with a statically compiled Python, I run into data representation slow-down problems:

In a dynamic language, typically all elements in an array (or other data structure) can be different types.  Therefore, these could have different representation values.  Therefore, these values must all be stored individually on the heap rather than in-line inside the array.  This means you are performing a data-dependent branch to non-adjacent memory, which puts pressure on cache-lines.

There are some clever tricks using special bits in a variable to pack some primitives like integers into a type that is otherwise a pointer, but that costs registers to track during manipulation so adds overhead.

There are some clever approaches like JITing of hot paths, but if you start putting your values in-line and not-type-taggged rather than as tagged types individually on the heap inter operability with non-JITed code becomes hard and you get a whole can of worms if some other code goes and changes the type of one value in the middle of the array…

I've been thinking a lot about what is and isn’t static in Python.  With SSTA and escape analysis you can determine that a surprising amount of a normal program is static.  Paul Biggar gives me confidence that my guess that 90% of my Python is static is about right.

What about that 10%?  Usually I can get all that static too, or imagine it being specialized for a restricted range of parameter types.  All except the standard pattern in Python web-servers to dispatch to web handlers based on HTTP method (calling the ‘get’ method if you receive a GET request).  That’d need the programmer to rephrase in terms of a switch statement (as in a long chain of elifs).

Robert Harper gave a great explanation of how a dynamic language is implemented in terms of a static language with a single type.  There is one quote I wish he’d expand upon:

Now I am fully aware that “the compiler can optimize this away”, at least in some cases

I believe the “some cases” he allows to are where you have non-escaping things.  You have to be able to determine the type of something that escapes when interacting with later-executing code.

Some dynamic calls are nonpolluting - a compiler can see from inspection that whilst some variable (or method) is dynamic, the dynamic code would not virally infer dynamic status on other variables.  Because the varying type of a variable or the presence/absence of a method/member is restricted to identifiable types (or null), specialism is possible.

But all too often the compiler can’t see that from code inspection.  And as soon as you lose track of where the execution may go, you stop knowing how that code might depend upon or change the value of other static variables.  So all bets are off, all variables have to be truly dynamic again.

I have struggled to find a way to deal with the monkey patching, set, setattr and such efficiently in mythical Python compiler.  Tagging types kills performance.

Fast data structures are very much about memory access patterns and cache locality and minimizing branches and tagging works against each of these.

Thank you for reading.