f.lorenzo
f.lorenzo

Reputation: 1226

Webservice in PHP with SOAP

I'm trying to get a SOAP web service to run with PHP. But when i am running the file the page shows nothing. I tried to create a client to see if the code runs that way but the function doesn't run. Here is my code:

webservice.php

function hello(){
    echo("hi");
}

$server = new SoapServer(null, array('uri'=>'http://localhost/FutureWB/hello'));
$server->addFunction("hello");
$server->handle();

testweb.php

try{
$client = new SoapClient(null, array(
    'location'=>"http://localhost/FutureWB/functions/webservice.php",
    'uri' => "http://localhost/FutureWB/hello"

));

$result = $client->hello();
echo($result);


}catch(SoapFault $ex){
    $ex->getMessage();
}

Upvotes: 1

Views: 103

Answers (1)

Cups
Cups

Reputation: 6896

Sorry not a great SoapClient user but how about this,

function hello(){
    return "hi";
}

Upvotes: 2

Related Questions