/** * 创建一个服务 */ public function soap($uri, $className, $config = null) { if (isset($_GET['wsdl'])) { $autodiscover = new AutoDiscover(); $autodiscover->setClass($className)->setUri($uri); return $autodiscover->toXml(); } else { $wsdl = strpos($uri, '?') === false ? $uri . '?wsdl' : $uri . '&wsdl'; $server = new SoapServer($wsdl); $obj = $config == null ? new $className() : new $className($config); $server->setObject($obj); $server->handle(); $response = $server->getLastRequest(); if ($response instanceof \SoapFault) { $response = exceptionMsg($response); $this->log($response); } return $response; } }
/** * @group ZF-5736 */ public function testAmpersandInUrlIsCorrectlyEncoded() { $autodiscover = new AutoDiscover(); $autodiscover->setUri("http://example.com/?a=b&b=c"); $autodiscover->setClass('\\ZendTest\\Soap\\TestAsset\\Test'); $wsdl = $autodiscover->toXml(); $this->assertContains("http://example.com/?a=b&b=c", $wsdl); }
/** * @group ZF-8948 * @group ZF-5766 */ public function testRecursiveWsdlDependencies() { $autodiscover = new AutoDiscover('\Zend\Soap\Wsdl\Strategy\ArrayOfTypeComplex'); $autodiscover->setClass('\ZendTest\Soap\TestAsset\Recursion'); $wsdl = $autodiscover->toXml(); // <types> // <xsd:schema targetNamespace="http://localhost/my_script.php"> // <xsd:complexType name="Zend_Soap_AutoDiscover_Recursion"> // <xsd:all> // <xsd:element name="recursion" type="tns:Zend_Soap_AutoDiscover_Recursion"/> $path = '//wsdl:types/xsd:schema/xsd:complexType[@name="ZendTest.Soap.TestAsset.Recursion"]/xsd:all/xsd:element[@name="recursion" and @type="tns:ZendTest.Soap.TestAsset.Recursion"]'; $this->assertWsdlPathExists($wsdl, $path); }