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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 40

Accepted Solution

Richard Quadling 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

by:Richard Quadling
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Microservice architecture adoption brings many advantages, but can add intricacy. Selecting the right orchestration tool is most important for business specific needs.
This article discusses four methods for overlaying images in a container on a web page
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 dynamically set the form action using jQuery.

735 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