当前位置:Gxlcms > PHP教程 > UsingWCFServiceswithPHP

UsingWCFServiceswithPHP

时间:2021-07-01 10:21:17 帮助过:19人阅读

I recently wrote two postings on the subject of WCF services: WCF Services ? Let's Get Started and WCF and Unit Tests. One could see that creating and testing services was not complicated at all. Let's go on and take some steps nearer to the real world ? our service is used by SOAP clients running on different platforms.

I conducted my first experiment with PHP. PHP is widely used in the world of the Web and in all likelihood there will dawn a day when DT is asked just for such an integration. As PHP4 development and support is soon going to be discontinued, I didn't bother with an example using PHP4 SOAP tools. PHP5 is on the market and it comes with a quick and stable SOAP library. The performance is many times better than in case of similar widgets written for PHP4.

I have Apache and PHP5 running on Windows and for SOAP support I have to use an extension named php_soap.dll. Thus, I have to remove the comment mark in front of the appropriate php.ini line and restart Apache.

As an example I will present a PHP code calling the service's Add() method and writing the result on the screen. An example of WCF code can be found in our blog, in the posting WCF Services ? Let's Get Started.

x = 2.5;$obj->y = 3.5;$retval = $client->Add($obj);echo "2.5 + 3.5 = " . $retval->AddResult;?>

If nothing went wrong, the result should be something like this:

    WCF Test    2.5 + 3.5 = 6

As you can see, using WCF services in PHP is very simple. The SOAP library provided along with PHP5 does a great deal of the work "behind the curtains", leaving us with an easily readable brief code.

人气教程排行