Not really a PHP developer, but I have PHP hosting and would like to create a PHP Web Service on it to be consumed by a .NET Client, I am thinking of using WSDL with NUSoap.
OR
A more modern solution, which I am not sure would be easier, would be to use OData. Which one would be easier?
The easiest for you c# developers is to develop a soap service with a WSDL. It will be a pain to create the service in php.
A better alternative is to create a REST webservice that communicates using JSON. It will take a bit more code on the client side, but it will be easier to consume on other platforms, and will be snap to develop in php.
Here is an example of a very simple REST-JSON web server in php.
function finder($person)
{
$data = array();
$data['sue']['full_name'] = 'Sue Thompson';
$data['sue']['location']['city'] = 'San Francisco';
$data['sue']['location']['state'] = 'California';
$data['jack']['full_name'] = 'Jack Black';
$data['jack']['location']['city'] = 'San Anselmo';
$data['jack']['location']['state'] = 'California';
if (!isset($data[$person))
{
return $data[$person];
}
else
{
// make sure you document this
return array('error' => "An error has occured");
}
}
// you can take parameters as url query strings or as json.
// if your input is simple, query strings are easier.
$person = $_GET['person'];
echo json_encode(finder($person));