php - Zend SOAP Server SOAP-ERROR:Parsing WSDL: Couldn't load from 'X' : failed to load external entity 'X" -
<soap-env:envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"> <soap-env:body> <soap-env:fault> <faultcode>wsdl</faultcode> <faultstring> soap-error: parsing wsdl: couldn't load 'http://testws.localhost/album/wsdl' : failed load external entity "http://testws.localhost/album/wsdl" </faultstring> </soap-env:fault> </soap-env:body> </soap-env:envelope>
i trying create simple test web service in php using zend framework 2.2.1. using xampp v1.8.2-0. version of php installed 5.4.16. have followed skeleton application tutorial @ http://framework.zend.com/manual/2.0/en/user-guide/skeleton-application.html point have functioning controller.
the wsdl path testws.localhost/album/wsdl or testws.localhost/album?wsdl service located @ testws.localhost/album. 127.0.0.1 in place of testws.localhost makes no difference.
visiting wsdl url returns me appears valid wsdl file, xmlspy loads/validates it. visiting service in browser results in error response above, not give detail why cannot load wsdl.
saving generated wsdl output file , using path that, generating text in php within soap request method generate same error, couldnt load 'x' : failed load external entity 'x'. wsdl file can read in application directory , echoed out.
i have spent multiple days trying resolve , looked @ plenty of similar questions here , on web of them either magically resolve or have no accepted answer, , nothing suggested worked me. code included below, if there other information required let me know, relatively inexperienced zend framework / php / xampp , has me stopped completely.
albumcontroller.php
<?php namespace album\controller; require_once 'soaptest.php'; use zend\mvc\controller\abstractactioncontroller; use zend\view\model\viewmodel; use zend\soap\server; use zend\soap\autodiscover; class albumcontroller extends abstractactioncontroller { private $_wsdl_uri = "http://testws.localhost/album/wsdl"; private $_uri = "http://testws.localhost/album"; public function indexaction() { if(isset($_get['wsdl'])) { $this->handlewsdl(); } else { $this->handlesoap(); } return $this->getresponse(); } public function wsdlaction() { $this->handlewsdl(); return $this->getresponse(); } private function handlewsdl() { $autodiscover = new autodiscover(); $autodiscover->seturi('soaptest'); $autodiscover->setclass($this->_uri); $autodiscover->handle(); } private function handlesoap() { try { $server = new server($this->_wsdl_uri); $server->setclass('soaptest'); $server->handle(); } catch (exception $e) { $e->faultstring->dump("error.wsdl"); } } }
soaptest.php
<?php class soaptest { /** * method returns string * * @param string $value * @return string */ public function hello($value) { return "hi"; } }
in httpd-vhosts.conf
<virtualhost testws.localhost:80> documentroot "c:/xampp/htdocs/ws/zendapp/public" servername testws.localhost serveralias www.testws.localhost setenv application_env "development" <directory "c:/xampp/htdocs/ws/zendapp/public"> directoryindex index.php allowoverride order allow,deny allow </directory> </virtualhost>
hosts file
127.0.0.1 testws.localhost localhost
wsdl xml
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://testws.localhost/album" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" name="soaptest" targetnamespace="http://testws.localhost/album"> <types> <xsd:schema targetnamespace="http://testws.localhost/album"/> </types> <porttype name="soaptestport"> <operation name="hello"> <documentation>this method returns string</documentation> <input message="tns:helloin"/> <output message="tns:helloout"/> </operation> </porttype> <binding name="soaptestbinding" type="tns:soaptestport"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="hello"> <soap:operation soapaction="http://testws.localhost/album#hello"/> <input> <soap:body use="encoded" encodingstyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://testws.localhost/album"/> </input> <output> <soap:body use="encoded" encodingstyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://testws.localhost/album"/> </output> </operation> </binding> <service name="soaptestservice"> <port name="soaptestport" binding="tns:soaptestbinding"> <soap:address location="http://testws.localhost/album"/> </port> </service> <message name="helloin"> <part name="value" type="xsd:string"/> </message> <message name="helloout"> <part name="return" type="xsd:string"/> </message> </definitions>
i think problem in controller, first $_uri
must
$_uri = "http://testws.localhost/album";
(i.e. http schema).
second passing wrong argument autodiscover
, first argument of autodiscover
not url, try replacing handlewsdl
method this:
private function handlewsdl() { $autodiscover = new autodiscover(); $autodiscover->setclass('soaptest') ->seturi($this->_uri); $autodiscover->handle(); }
Comments
Post a Comment