menu

Questions & Answers

How to create a PHP SOAP Client for calling a WCF Web service under SSL?

We have a WCF service under an SSL Web Server installed in IIS. The web service was created with .NET 3.5 and WCF 3.0. We can access it with a .NET 3.5 client without problems.

Let's call the URL where the service is published something like:

https://my-server.com/testservice.svc?wsdl

We need to make a proof of concept to check if it's possible to access it with a PHP client. I've tried to use NuSOAP or the standard SoapClient of PHP but in both cases i get an exception. Here is my code:

<?php
  $wsdl = 'https://my-server.com/testservice.svc?wsdl';
  $client = new SoapClient($wsdl);
?>

It returns me an exception with this message:

Error:sendSms: SoapFault exception: [WSDL] SOAP-ERROR: Parsing Schema: can't import schema from 'https://my-server.com/testservice.svc?wsdl' in C:\localhost\test.php:5 Stack trace: #0 C:\localhost\test.php(5): SoapClient->SoapClient('https://my-serv...') #1 {main} "

Any ideas? What am I doing wrong?

Answers(4) :

http://weblogs.asp.net/gunnarpeipman/archive/2007/09/17/using-wcf-services-with-php.aspx

I am currently investigating this as well, hopefully this helps you

everything looks correct and it seems like it would work, certainly that is the point of SOAP to be able to make calls from other languages.

Maybe try using NuSoap or PEAR Soap_Client so you can set a break-point or just dump the raw output from the server? If the server is returning an error, that might give you some clues. If the server seems to be outputting valid SOAP response, it maybe could be that your web service has some complex object types for args or return values that causes PHP to choke?

According to this question you must grant access rights to the IIS_IUSERS for the directory 'C:/Windows/Temp'.

Late to the party here, but make sure when you set up the WCF service with AddServiceEndpoint, you are using BasicHttpBinding not WebHttpBinding.