実際にはPHP開発者ではありませんが、PHPホスティングを使用しており、.NETクライアントで使用できるPHP Webサービスを作成したいので、NUSoapでWSDLを使用することを考えています。
また
より現代的な解決策は、私にはわかりませんが、ODataを使用することです。どちらが簡単ですか?
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));
神の愛のために SOAP を使用しないでください。それはひどいとひどいです。
REST (または少なくとも GET と POST) と JSON を使用します。とても簡単です。
SOAP または REST for Web Services を参照してください。
更新: 私はもともと XML に反対していましたが、XML にはその場所があります。ただし、JSON の方が優れています (冗長ではありません)。
このサイトでよく説明されています: http://wso2.org/library/3393