Posts

Showing posts from June, 2011

PHP-SOAP web service with out a WSDL

This article is going to describe how to create a simple web service with php-soap step by step. Requirements     Server to run php (apache, xampp , wamp)     PHP-SOAP extension Steps Let's write a simple web service to find the length of a given string. So here is the code for StringLengthServer.php   <?php # StringLengthServer.php # Copyright (c) 2011 by Lakmali Baminiwatta #     function findLength($string) {            return "Length of the string " . $string . "is : ".strlen($string);     }            $server = new SoapServer(null,               array('uri' => "urn://www.lakmali.lk"));        $server->addFunction("findLength");        $server->handle();  ?> First thing done here is to write a function to perform the action done by the service. So here function findLength($string) takes a string as the argument and prints back the length of it. Then SoapServer is created. First argument

Java Initialization order

When a java class get loaded first all the static fields will be loaded with their default values. Then static inits of the class begins in order, which means static fields will be initialized as given in order. So in the given example code line 1 will load the class LakmaliClass with all its static fields assigning to default values. Then static inits will begin executing line 5, 6 and 7. Then instance inits will begin executing line 2, 3 and 4. Line 2 will load the class Second with all the static fields default values (Here no static fields) Then object will be created with passed values. Line 3 will also do the same. class Initializer{     public static void main(String args[]){         LakmaliClass o=new LakmaliClass(); // line 1            } } class LakmaliClass{     {         System.out.println("Lakmali class instance init"); //line 2         Second s1=new Second(s);             //line 3         Second s2=new Second(number1);             //l