NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Using Nusoap to connect to a database


Joined: 09 Jun 2007
Posts: 4
Reply with quote
Hi everyone,

I am a PHP developer but having problems with developing web services using NuSoap. I would like to develop some
simple DB related services for my web based application. Here is an example ..

Client source code

<?php

// Pull in the NuSOAP code
require_once('nusoap.php');

// Create the client instance
$client = new soapclient('http://localhost/WS/DB_server.php');

// Call the SOAP method
$result = $client->call('DB_connect', array('DB_name' => 'lms_db_dsn',
'username' => '',
'password' => '',
'message' => 'Could not connect to DB'));
// Display the result
print_r('Connection ID = ' . $result);

?>

Server source code

<?php

/* Created on: 09/06/2007 */

// include the NuSOAP classes
require_once('nusoap.php');

// instantiate the server object, provided by soap_server classes
$s = new soap_server;

$s->register('DB_connect');

// define function
function DB_connect ($DB_name, $username, $password, $message)
{
return odbc_connect($DB_name, $username, $password) or die('<h4>' . $message . '</h4>');
}

// The final step is to pass any incoming posted data to the SOAP server’s service method.
$s->service($HTTP_RAW_POST_DATA);

?>

THis is my output when running the client: 'Connection ID = Array'

Has anyone got any ideas ?

regards,

Steven M
View user's profileFind all posts by ksmatthewsSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
I'd highly recommend you to check and try samples posted on this forum first.
Then, replace print_r...$result with var_dump($result) and give it one more try Smile

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Using Nusoap to connect to a database
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic