Using WCF Services with PHP

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.


NB! This blog is moved to

Click here to go to article


  • Packing arguments into undeclared objects... well, isn't there a better way? If php runs on Windows then I found it much more convenient to generate a proxy class library dll and use that through COM, but that's not always the case, currently I have to make a call from linux and that's how I found your article googling for a solution.

  • Thanks you for your reply. I have to admin that undeclared object is not a best solution. It is really better to create a class for arguments object.

  • Which version of PHP you are using? If it is PHP5, do you use built-in SOAP support? If you can provide me this information it is easier for me to help you.

  • PHP 5, N yes the built in SOAP support

  • Getting this error when calling method "Fatal error: Uncaught SoapFault exception: [HTTP] Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'."

    PHP Version => 5.2.3-1 (failed on both cli and apache)
    PHP Box => ubuntu 6.3
    ISS Box => Vista 64 ult
    Using Soap which is compiled in.

    Any ideas?

  • I think you have problem with SOAP version. Check out what SOAP version uses WCF and which one is used by PHP. Then make sure that they both will use same version.

  • Ok problem solved. Changed binding to basicHttp and it worked with PHP.

    My new problem now is using multiple endpoints. I'd like to have a wsHttp and basicHttp. Trying to workout how now.

  • Yeah that's what I used. The array declaration was gobbled by the url parsing code.

  • Make sure that WCF and PHP app will use same SOAP protocol version.

  • What is WCF? Sorry i am new to web services.


  • WCF stands for Windows Communications Foundation. It is technology to build services and it was shipped with .Net Framework 3.0. Now you can build stand-alone services. Previously you were bind to ASP.NET and Web Service project that offered only SOAP. With WCF you can also use the other standard for web services.

  • But I dont use .net framework. I use windows XP Professional ver 5.1 and use XAMPP for windows version 1.6 and soap client and version are both enabled in my xampp and use php 5.2.5.


  • I really don't understand what and how you are doing and how is this related to WCF :)

  • Hmm.... svc extension points to WCF. Try to change SOAP version in your PHP request. Instead of

    'soap_version' => SOAP_1_1

    try out

    'soap_version' => SOAP_1_2

  • $client->soap_defencoding = 'UTF-8';

  • I see there are some comment about WSHttpBinding but it is not clear how to use it.
    Can you please explain what should I do in order to consume WCF service with WSHttpBinding from PHP

    Is it possible to do it from a computer outside of the domain?


  • For the Banu problem,
    i think it caused of banu put the service url in svc extension.

    For .Net i think its okey buts for PHP,
    it should put .svc/wsdl? after the .svc extension

    Maybe its can solver the problem.

    Buts thank to the blog owner, your blog really teaching me to doin well in my WCF

  • Thanks for good words, Kiemieuk :)

  • hi all,

    i'm pretty new to webservices but i need them for a project to convert a database.
    but since this is new, i first tried to put a simple 'Hello World!' on my screen using WCF.

    now when i tried this code (see below) i got a fatal error. i dont know how to solve it. i've put the folder with my svc into the home folder of my website.
    my code:

    echo $retval;
    my output:
    WCF Test

    Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O warning : failed to load external entity "webservice try 1/webservice try 1/Service1.svc?wsdl" in C:\xampp\htdocs\page\testWCF.php on line 6

    Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'webservice try 1/webservice try 1/Service1.svc?wsdl' : failed to load external entity "webservice try 1/webservice try 1/Service1.svc?wsdl"
    in C:\xampp\htdocs\page\testWCF.php:6
    Stack trace:
    #0 C:\xampp\htdocs\page\testWCF.php(6): SoapClient->SoapClient('webservice try ...')
    #1 {main}
    thrown in C:\xampp\htdocs\page\testWCF.php on line 6


    any help would be welcome

  • ok, seems i copied my url wrong. although i encountered a second problem on line 8. 'Unsupported Media Type'

    does anyone know how i should fix that??

    ty :)



  • Hi,

    I really need your help please

    i keep getting this error don,t know what to do with it

    The SOAP action specified on the message, '', does not match the HTTP SOAP Action


  • the PHP SoapClient class implements the WS-I standard. To resolve the HTTP SOAP action mismatch exception:

    Change the binding of the WCF service in the web.config file from binding="wsHttpBinding" to binding="basicHttpBinding".

    Good luck...

  • Thank you DigiMortal, it's a great post and helped me a lot.

  • Thanks a lot!! Great Article , I was using NuSoap and was difficult consume the wcf service, I can't find actual info about NuSoap, You Rock!

  • Does anyone know how to pass credentials from a PHP client to a WCF service if said service requires a username and password?

  • Riaan Bergh - how did you resolve the issue? I'm having the same problem. The service is not owned by me and I can't "Change the binding of the WCF service in the web.config file from binding="wsHttpBinding" to binding="basicHttpBinding"." I have to somehow set in php/nusoap that we need to USE basicHttpBinding. Is that a setting we can use in nusoap?

  • Can i authenticate using a certificate and nuSoap,
    I need to call a .NET Webservice using the given certificate.
    Can anyone please help, i am new to Webservice and do apologize if my question sounds

  • Thanks a lot!! Great Article! help me solved my problem!

Comments have been disabled for this content.