Web Services .NET Grid: Create SOAP Server



Web Services PHP - Grid .NET Step By Step Tutorial - Part 3: Our database and WSDL document are ready. Now, we create SOAP server to serve transmit data. All data will be convert to single line of string.

Create a file named "library_server.php" within www/test/wsdl. Enter following code:

<?php
if(!extension_loaded("soap")){
  dl("php_soap.dll");
}

ini_set("soap.wsdl_cache_enabled","0");
$server = new SoapServer("library.wsdl");

function doLibrary($name=''){
 // connect to database
 mysql_connect('localhost','root','admin');
 mysql_select_db('test');
 
 // query for retrieve data from books table
 $sql = "select * from books";
 $q	  = mysql_query($sql);
 
 while($r	  = mysql_fetch_array($q)){
   // convert to a line
   $str .= $r['id']."|".$r['title'].'|'.$r['author'];
   // row be separated with #
   $str .= '#';
 }

 // return a line of string
 return $str;
   
}

// register method
$server->AddFunction("doLibrary");
$server->handle();
?>


Series this article:
Web Services .NET Grid: Create WSDL Document
Web Services .NET Grid: Preparing Database
Web Services .NET Grid: Create SOAP Server
Web Services .NET Grid: Testing with SOAP client
Web Services .NET Grid: Creating User Interface for VB.NET
Web Services .NET Grid: Retrieve Data and Show to Data Grid


Tag: web services, .net, wsdl, soap, vb.net Category: PHP Framework Post : April 15th 2008 Read: 1,608 Bookmark and Share

blog comments powered by Disqus