Https webservice php

时间:2013-10-14 23:01:28

标签: php web-services soap

继续无法连接到主机这是我拥有的服务器代码

  <?php 
  ini_set('soap.wsdl_cache_enabled',0);
  ini_set('soap.wsdl_cache_ttl',0);

  $soap_server = new SoapServer('Notification.wsdl');
  $soap_server->addFunction('Notify');

  function Notify($message)
  {
      return array('message' => $message);
  }

  $soap_server->handle();


  ?>

这是我的客户端代码,它正在抛出错误。端点是https。 wsdl文件是本地文件。

    <?php


     $context = stream_context_create(array(

      'https' => array(
      'cafile' => 'APX_WS_API1.cer',
      'verify_peer' => true
      )
      ));

     $soap_client = new SoapClient('http://localhost:8888/Receiver/Notification.wsdl', 
      array('stream_context' => $context,'local_cer' => 'APX_WS_API1.cer'));

     try{
     $result = $soap_client->__soapCall('Notify',array('message' => 'Hello World'));
     echo $result;
      }catch(SoapFault $e){
      echo "Error: " . $e->faultstring;
      }


         ?>

有人可以告诉我,我做错了什么。提前致谢

1 个答案:

答案 0 :(得分:1)

您的证书有效吗? 试试这个选项:

$context = stream_context_create(array(
            'ssl' => array(
                'verify_peer' => false,
                'allow_self_signed' => true
            )
        ));

如果有效则意味着您的证书无效。