PHP Client – WCF Service

I spent the last couple of days working with PHP 5 to connect to a WCF service hosted on a remote server. Its like a proof of concept… After many failed attempts at getting a PHP client to connect it happened. I got the connection and figured out how to pass a parameter to WCF and get a return value. In the process I spent a good bit of time Googling for answers. 

In all my Googling, I never found any meaningful help. It was only through gleaning key pieces of information  across multiple searches that I was able to get PHP to WCF to work. I really need to publish a paper on this subject, and provide some simple code to demonstrate what works. Thats for the future… in the interim here is the PHP code that works on all but my site host's server.

<?php 

    echo "start -> ";

    $wsdl = "https://newt3services.com/Service1.svc?wsdl&quot;;

    echo " set wsdl var -> ";

    $soapclient = new SoapClient($wsdl);echo " created soapclient ->";

    echo $soapclient->GetData(array("value" => "5"))->GetDataResult;

    echo " end ";

?>

Click here to execute the code and get the correct result: execute php

Click here to execute the code and get the incorrect result:execute php

2 thoughts on “PHP Client – WCF Service

Leave a comment