PHP WDSL Error on new server

I'm loading existing PHP code onto a new server and getting a fatal error with a soap wsdl:  

$this->client = new SoapClient(
      "https://servername.jws?WSDL",
      array("classmap" => $this->classmap,
      "location" => "https://servername.jws",
      "trace" => true,
      "exceptions" => true
      )
);

PHP Fatal error:  SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://servername.jws?WSDL' failed to load external entity 'https://servername.jws?WSDL'

If I test the wsdl in a test page:
$wsdl = "https://servername.jws?WSDL";
echo file_get_contents($wsdl);

I get an ssl error:
Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

A co-worker suggested this:
$arrContextOptions=array
(
    "ssl"=>array
                (
        "verify_peer"=>false,
        "verify_peer_name"=>false,
    ),
);

This works for the test scenario, but I have no idea how to incorporate it into the soap client???
Or is there another avenue to resolve the issue???
Any help would be appreciated!
kevbob650Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
You can pass a stream_context to the SoapClient Constructor like this
// Create the context as you did in your test
$context = stream_context_create(
  array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    )
));
// PASS IT TO THE SoapClient CONSTRUCTOR LIKE THIS
$this->client = new SoapClient(
      "https://servername.jws?WSDL",
      array("classmap" => $this->classmap,
      "location" => "https://servername.jws",
      "trace" => true,
      "exceptions" => true,
      "stream_context" => $context
      )
);

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kevbob650Author Commented:
Thanks so much!  That was it, and I learned something new!
0
Julian HansenCommented:
You are most welcome.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

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.