Pregunta

I am trying to make a webservice controller for a Zend framework in PHP. I'm using non-WSDL mode (though I suppose if it comes down to it, I can build a WSDL file).

class WebserviceController extends Zend_Controller_Action
{
    public function soapAction()
    {
        $this->getHelper('viewRenderer')->setNoRender(true);

        $soap_options = array('uri'=>$_SERVER['DOCUMENT_ROOT'] . 'webservice/soap/');
        echo $soap_options;
        $server = new Zend_Soap_Server( null, $soap_options );
        $server->setClass('WebserviceAPI');
        $server->handle();
    }
}

WebserviceAPI is a plain-old object:

class WebserviceAPI
{
    public function returnblah($one, $two)
    {
        return $one . ", " . $two . ": blah!";
    }
}

I'm attempting to test this just to see if I can make it connect:

$options = array('login'    => '***',
    'password' => '********',
    'location' => 'https://localhost:8888/webservice/soap',
    'uri' => 'https://localhost:8888/',
    'trace' => 1);

$soap = new SoapClient(null, $options);
echo $soap->returnblah("a-one", "a-two");

It's not connecting. Fact is, I'm not sure what the correct location and uri for a Zend SOAP server should be, when it's built in non-WSDL mode. The documentation isn't clear on how to connect to a Zend SOAP server built this way.

ETA: I've included login and password in case authentication is the reason it's not connecting (though I suspect it's not even getting that far).

ETA2: Here's the actual error message:

Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in /Users/sabrina/Documents/testws2.php:28

where line 28 is the actual call to $soap->returnblah(). (My code posted here omits a lot of crap I've commented out in trying to solve this.)

I'm beginning to suspect my actual connection problem may be that the SOAP client is trying to send an https request over http, so I'm trying to work that out, but it would still be helpful to know if I am using the right location and uri parameters.

Thanks in advance!

¿Fue útil?

Solución

According to the Zend documentation for Zend_Soap_Server and the SoapClient documentation, the 'uri' option specifies the SOAP uri namespace in both cases. Make sure that both 'uri' options are set to the same value in your server and client, which is not the case in your example.

The 'location' option in SoapClient should be set to the URL on which your php application is configured in your web server.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top