How to use Php with Soap and WSDL to connect with a servers https wsdl connection

Posted on 2011-02-28
Last Modified: 2012-05-11
I am trying to connect to an external organizations server with our soap client in php using soap. Our php soap client was working fine in the servers qa environment but is not working in production. Tried using the local_cert option but still the error mentions  Couldn't load from '' : failed to load external entity "

We did the entire testing in qa environment and now when the code has been moved to production by the external organization, we are unable to connect to their wsdl. Also, I am not sure how to retrieve their certificate .The link that they  gave for the certificate i tried to acquire through

openssl s_client -connect> scert.pem

and it gave me the following error

getaddrinfo: Servname not supported for ai_socktype

We can also use Zend if some body can point to a specific Zend framework example. Thank you.
Question by:ezdrt
  • 2
LVL 40

Accepted Solution

RQuadling earned 500 total points
ID: 35005545
Can you try this simple test on your servers?

ini_set('display_errors', 1);
echo file_get_contents('');

Most likely the server without the https capability is missing the necessary elements. Commonly cURL, but openssl too.

On both servers, run ...


and compare the output. Pay special attention to any entries with https in them...

The following is from the command line (on Windows so, the find command is different) ...

[2011/03/01  9:46:48] [D:\Personal Files\Downloads\Software\Programming\PHP\Official Releases\PHP5.x.x\PHP5.3.x\php-5.3.5] [] >php -n -i | find "http"
Registered PHP Streams => php, file, glob, data, http, ftp, zip, compress.zlib, phar
session.cookie_httponly => Off => Off

[2011/03/01  9:46:58] [D:\Personal Files\Downloads\Software\Programming\PHP\Official Releases\PHP5.x.x\PHP5.3.x\php-5.3.5] [] >php -n -i -dextension_dir=.\ext -dextension=php_curl.dll | find "http"
Registered PHP Streams => php, file, glob, data, http, ftp, zip, compress.zlib, phar
Protocols => dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, pop3, pop3s, rtsp, scp, sftp, smtp, smtps, telnet, tftp
session.cookie_httponly => Off => Off

The first set is without loading any additional extensions and relying purely on the built-in extensions.

As you can see, no https at all.

Once you load cURL, the https protocol is ready to use.

In my experience, once this is set, you are ready to go.

As for using the service, you normally don't need to use anything else other than PHP's built in SOAPClient.

I use a wsdl2php converter which takes the wsdl file and creates a set of classes covering the complex types used in the WSDL as well as a sub class of SOAPClient allowing for very easy usage of the soap service.

The protocol handling is all done by SOAPClient.

If you can provide a real URL for the wsdl file, I can give you back the proof of concept work that I use.

You can see other examples of my working in the PHP SOAP mailing list,

Pretty much all the posts I've made here are in response to the question of "How do I use PHP to talk to a web service using a wsdl file?".

For https, you need curl to be loaded. That way curl handles all the ssl aspects and allows the SOAPClient class to simple talk in SOAP terms. The code created by wsdl2php allows you to talk in object terms. You don't need to worry about XML, SOAP, HTTPS.

Well. Mostly.

The only time you have to think about XML is when the service doesn't provide a complex type to handle the response. Some services response types are strings containing XML. I use the Tidy extension to show them, but using the simplexml extension to convert the XML string to an object keeps everything in the object domain. For me that's a level of consistency I like.

I hope this is of use.

If you need more info, specific to your issue or more general stuff, please come back to me.


Expert Comment

by:Vimal DM
ID: 35006661

I have used "nusoap.php" class for the integration of SOAP with PHP


1) Variables to be sent
2) require_once('nusoap.php');
3) $client = new nusoap_client(include the xml file,true)
4) $err = $client->getError();
5) $result = $client->call('WS_NAME',VARIABLES,'urn:WEB_SERVICE_SOAP');

Just search related topic and understand the usage of the "nusoap",it sounds good

LVL 40

Expert Comment

ID: 35007001
Watch out that nusoap is for PHP4.

PHP5 has all that built in and is supported/maintained by The PHP Group.

And please read ...

"NuSOAP for PHP 5 modifies the NuSOAP library so that it doesn't have a class name conflict with the PHP5 soap extension.

NuSOAP's class name is 'soapclient'. PHP5 includes a SOAP extension whose class name is also 'soapclient'. As a result, you effectively can't use NuSOAP with PHP5. NuSOAP for PHP5 simply changes the class name to 'soapclientnusoap'."

Considering PHP natively supports SOAP, there would have to be some compelling reasons to use a nusoap. Using PHP 4 is certainly 1 reason and a perfectly valid one.


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These instructions are based on installing Owncloud on your new raspberry pi connected with a usb HDD. What do you need Part A? A Raspberry Pi, model B. A boot SD card for the Raspberry Pi. A usb HDD An Ethernet cable to connect to the lo…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now