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 null which means no WSDL used. Second argumen…
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 null which means no WSDL used. Second argumen…