PHP SoapClient : failed to open stream: HTTP request failed

Question

I will try to explain my problem as much as I can.

1 - I created Soap server in PHP (ZF1 project:)

class WebServiceAction Extends Zend_Controller_Action
{

  public function soapAction()
  {
    $this->_helper->layout()->disableLayout();
    $this->getHelper('viewRenderer')->setNoRender(true);
    if (isset($_GET['wsdl'])) {
      $this->wsdl();
    }
    $this->handleSOAP();
  }

  protected function handleSOAP()
  {
    ini_set("soap.wsdl_cache_enabled", "0");
    $server = new SoapServer('http://localhost/myproject/webservice/soap?wsdl');
    $server->setClass('Webservice_Model_MyClass');

    $server->handle();
    exit;
  }

  protected function wsdl()
  {
    // set up WSDL auto-discovery
    $wsdl = new Zend_Soap_AutoDiscover();
    // attach SOAP service class
    $wsdl->setClass('Webservice_Model_MyClass');
    $wsdl->handle();
    exit;
  }
}

2 - Web service class :

class Webservice_Model_MyClass
{
    /**
   * Testing the server
   *
   * @return  string
   */
  public function testing() {
    return 'It works bla bla!!!';
  }
}

3 - I created Soap client in PHP (ZF2 project:)

try{
    $soapClient = new \SoapClient(
        'http://localhost/myproject/webservice/soap?wsdl', 
        array(
            'cache_wsdl' => WSDL_CACHE_NONE,
            'soap_version' => SOAP_1_2,
            'trace' =>1
        )
    );

    $result = $soapClient->testing();
    var_dump($result); exit();
}catch(\Exception $e){
    echo $e->getMessage();
}

I am getting an error:

Warning: SoapClient::SoapClient(http://localhost/myproject/webservice/soap?wsdl): 
failed to open stream: HTTP request failed! in ....

Warning: SoapClient::SoapClient(): I/O warning : 
failed to load external entity "http://localhost/myproject/webservice/soap?wsdl" in ....

If i type http://localhost/myproject/webservice/soap?wsdl in browser address bar i get wsdl


Show source
| php   | zend-framework   | soap   2017-01-04 12:01 0 Answers

Answers ( 0 )

◀ Go back