• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1791
  • Last Modified:

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

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 'https://xyz.com/CondBasedMaintWS/SampleResultSendWSService?WSDL' : failed to load external entity "https://xyz.com/CondBasedMaintWS/SampleResultSendWSService?WSDL" 

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 https://xyz.com/monitor.html> 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.
  • 2
1 Solution
Richard QuadlingSenior Software DeveloperCommented:
Can you try this simple test on your servers?

ini_set('display_errors', 1);
echo file_get_contents('https://mail.google.com/mail');

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, http://news.php.net/php.soap.

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.

Vimal DMSenior Software EngineerCommented:

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

Richard QuadlingSenior Software DeveloperCommented:
Watch out that nusoap is for PHP4.

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

And please read http://code.google.com/p/nusoap-for-php5/ ...

"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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

SMB Security Just Got a Layer Stronger

WatchGuard acquires Percipient Networks to extend protection to the DNS layer, further increasing the value of Total Security Suite.  Learn more about what this means for you and how you can improve your security with WatchGuard today!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now