Tuesday, July 15, 2014

Call WCF service using PHP

I have a WCF service used by a .net application. Due to some library issues I have to change .net application in to PHP language. Rather than creating a new web service, there is a simple way of accessing WCF using PHP. But there are few concerns. You cannot use WSHttpBinding with PHP. I have to change my bindings in to basicHttpBinding because PHP soap protocols are notsupporting wshttpbindings


<?php
$client = new SoapClient('http://188.188.188.188:8980/CalService/Service/?wsdl');
$params = new StdClass;
$params->value = 2;
$retval = $client->GetData($params);
echo $retval-> GetDataResult;
?>
// In echo $retval you need to mention your method name first and then Result.
//My service method
[OperationContract]
string GetData(int value);
// endpoint
<endpoint address="" binding="basicHttpBinding" contract=" ICalService">
view raw gistfile1.php hosted with ❤ by GitHub