コード例 #1
0
ファイル: SoapController.php プロジェクト: ahumadamob/siris
 public function handleWSDL($local)
 {
     header("Content-type: text/xml");
     $autoDiscover = new AutoDiscover(new ArrayOfTypeSequence());
     $autoDiscover->setClass('\\Tesoreria\\Service\\Tesoreria');
     $autoDiscover->setUri(Constants::WSDL_URI_TESORERIA . $local);
     $autoDiscover->setServiceName('Tesoreria');
     $autoDiscover->setOperationBodyStyle(array('use' => 'literal'));
     $wsdl = $autoDiscover->generate();
     $wsdl = $wsdl->toDomDocument();
     echo $wsdl->saveXML();
 }
コード例 #2
0
ファイル: AutoDiscoverTest.php プロジェクト: pnaq57/zf2demo
 public function testAddFunctionSimpleWithDifferentStyle()
 {
     $this->server->setBindingStyle(array('style' => 'document', 'transport' => $this->defaultServiceUri));
     $this->server->setOperationBodyStyle(array('use' => 'literal', 'namespace' => $this->defaultServiceUri));
     $this->server->addFunction('\\ZendTest\\Soap\\TestAsset\\TestFunc');
     $this->bindWsdl($this->server->generate());
     $this->assertSpecificNodeNumberInXPath(1, '//wsdl:types/xsd:schema[@targetNamespace="' . $this->defaultServiceUri . '"]', 'Missing service port definition');
     $this->assertSpecificNodeNumberInXPath(1, '//wsdl:types/xsd:schema[@targetNamespace="' . $this->defaultServiceUri . '"]/xsd:element[@name="TestFunc"]/xsd:complexType/xsd:sequence/' . 'xsd:element[@name="who" and @type="xsd:string"]', 'Missing complex type definition');
     $this->assertSpecificNodeNumberInXPath(1, '//wsdl:types/xsd:schema[@targetNamespace="' . $this->defaultServiceUri . '"]/xsd:element[@name="TestFuncResponse"]/xsd:complexType/xsd:sequence' . '/xsd:element[@name="TestFuncResult" and @type="xsd:string"]', 'Missing complex type definition');
     $this->assertSpecificNodeNumberInXPath(1, '//wsdl:portType[@name="MyServicePort"]/wsdl:operation[@name="TestFunc"]', 'Missing service port definition');
     $this->assertSpecificNodeNumberInXPath(1, '//wsdl:portType[@name="MyServicePort"]/wsdl:operation[@name="TestFunc"]/wsdl:documentation', 'Missing service port definition documentation');
     $this->assertSpecificNodeNumberInXPath(1, '//wsdl:portType[@name="MyServicePort"]/wsdl:operation[@name="TestFunc"]/wsdl:input', 'Missing service port definition input message');
     $this->assertSpecificNodeNumberInXPath(1, '//wsdl:portType[@name="MyServicePort"]/wsdl:operation[@name="TestFunc"]/wsdl:output', 'Missing service port definition input message');
     $this->assertSpecificNodeNumberInXPath(1, '//wsdl:binding[@name="MyServiceBinding" and @type="tns:MyServicePort"]/' . 'wsdl:operation[@name="TestFunc"]', 'Missing service binding definition');
     $this->assertSpecificNodeNumberInXPath(1, '//wsdl:binding[@name="MyServiceBinding" and @type="tns:MyServicePort"]/' . 'soap:binding[@style="document" and @transport="' . $this->defaultServiceUri . '"]', 'Missing service binding transport definition');
     $this->assertSpecificNodeNumberInXPath(1, '//wsdl:binding[@name="MyServiceBinding" and @type="tns:MyServicePort"]/' . 'wsdl:operation[@name="TestFunc"]/soap:operation[@soapAction="' . $this->defaultServiceUri . '#TestFunc"]', 'Missing service operation action definition');
     $this->assertSpecificNodeNumberInXPath(1, '//wsdl:binding[@name="MyServiceBinding" and @type="tns:MyServicePort"]/' . 'wsdl:operation[@name="TestFunc"]/wsdl:input/soap:body[@use="literal" and @namespace="' . $this->defaultServiceUri . '"]', 'Missing operation input body definition');
     $this->assertSpecificNodeNumberInXPath(1, '//wsdl:binding[@name="MyServiceBinding" and @type="tns:MyServicePort"]/' . 'wsdl:operation[@name="TestFunc"]/wsdl:output/soap:body[@use="literal" and @namespace="' . $this->defaultServiceUri . '"]', 'Missing operation input body definition');
     $this->assertSpecificNodeNumberInXPath(1, '//wsdl:service[@name="MyServiceService"]/wsdl:port[@name="MyServicePort"' . ' and @binding="tns:MyServiceBinding"]/soap:address[@location="' . $this->defaultServiceUri . '"]', 'Missing service port definition');
     $this->assertSpecificNodeNumberInXPath(1, '//wsdl:message[@name="TestFuncIn"]/wsdl:part[@name="parameters" and @element="tns:TestFunc"]', 'Missing test testFunc input message definition');
     $this->assertSpecificNodeNumberInXPath(1, '//wsdl:message[@name="TestFuncOut"]/wsdl:part[@name="parameters" and @element="tns:TestFuncResponse"]', 'Missing test testFunc input message definition');
     $this->assertValidWSDL($this->dom);
     $this->testDocumentNodes();
 }
コード例 #3
0
    function testAddFunctionSimpleWithDifferentStyle()
    {
        $scriptUri = 'http://localhost/my_script.php';

        $server = new AutoDiscover();
        $server->setBindingStyle(array('style' => 'document', 'transport' => 'http://framework.zend.com'));
        $server->setOperationBodyStyle(array('use' => 'literal', 'namespace' => 'http://framework.zend.com'));
        $server->addFunction('\ZendTest\Soap\TestAsset\TestFunc');
        $dom = new \DOMDocument();
        ob_start();
        $server->handle();
        $dom->loadXML(ob_get_clean());
        $dom->save(__DIR__.'/TestAsset/addfunction.wsdl');

        $parts = explode('.', basename($_SERVER['SCRIPT_NAME']));
        $name = $parts[0];

        $wsdl = '<?xml version="1.0"?>'.
                '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="' . $scriptUri . '" 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:wsdl="http://schemas.xmlsoap.org/wsdl/" name="' .$name. '" targetNamespace="' . $scriptUri . '">'.
                '<types>'.
                '<xsd:schema targetNamespace="' . $scriptUri . '">'.
                '<xsd:element name="ZendTest.Soap.TestAsset.TestFunc"><xsd:complexType><xsd:sequence><xsd:element name="who" type="xsd:string"/></xsd:sequence></xsd:complexType></xsd:element>'.
                '<xsd:element name="ZendTest.Soap.TestAsset.TestFuncResponse"><xsd:complexType><xsd:sequence><xsd:element name="ZendTest.Soap.TestAsset.TestFuncResult" type="xsd:string"/></xsd:sequence></xsd:complexType></xsd:element>'.
                '</xsd:schema>'.
                '</types>'.
                '<portType name="' .$name. 'Port">'.
                '<operation name="ZendTest.Soap.TestAsset.TestFunc"><documentation>Test Function</documentation><input message="tns:ZendTest.Soap.TestAsset.TestFuncIn"/><output message="tns:ZendTest.Soap.TestAsset.TestFuncOut"/></operation>'.
                '</portType>'.
                '<binding name="' .$name. 'Binding" type="tns:' .$name. 'Port">'.
                '<soap:binding style="document" transport="http://framework.zend.com"/>'.
                '<operation name="ZendTest.Soap.TestAsset.TestFunc">'.
                '<soap:operation soapAction="' . $scriptUri . '#ZendTest.Soap.TestAsset.TestFunc"/>'.
                '<input><soap:body use="literal" namespace="http://framework.zend.com"/></input>'.
                '<output><soap:body use="literal" namespace="http://framework.zend.com"/></output>'.
                '</operation>'.
                '</binding>'.
                '<service name="' .$name. 'Service">'.
                '<port name="' .$name. 'Port" binding="tns:' .$name. 'Binding">'.
                '<soap:address location="' . $scriptUri . '"/>'.
                '</port>'.
                '</service>'.
                '<message name="ZendTest.Soap.TestAsset.TestFuncIn"><part name="parameters" element="tns:ZendTest.Soap.TestAsset.TestFunc"/></message>'.
                '<message name="ZendTest.Soap.TestAsset.TestFuncOut"><part name="parameters" element="tns:ZendTest.Soap.TestAsset.TestFuncResponse"/></message>'.
                '</definitions>';
        $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated");
        $this->assertTrue($dom->schemaValidate(__DIR__ .'/schemas/wsdl.xsd'), "WSDL Did not validate");

        unlink(__DIR__.'/TestAsset/addfunction.wsdl');
    }
コード例 #4
0
ファイル: ServerTest.php プロジェクト: pnaq57/zf2demo
 /**
  * @expectedException \SoapFault
  */
 public function testHandlePhpErrors()
 {
     if (headers_sent()) {
         $this->markTestSkipped('Cannot run ' . __METHOD__ . '() when headers have already been sent; enable output buffering to run this test');
         return;
     }
     $wsdlFilename = __DIR__ . '/TestAsset/testHandlePhpErrors.wsdl';
     $autodiscover = new AutoDiscover();
     $autodiscover->setOperationBodyStyle(array('use' => 'literal'));
     $autodiscover->setBindingStyle(array('style' => 'document', 'transport' => 'http://schemas.xmlsoap.org/soap/http'));
     $autodiscover->setServiceName('ExampleService');
     $autodiscover->setUri('http://example.com');
     $autodiscover->setClass('\\ZendTest\\Soap\\TestAsset\\errorClass');
     $wsdl = $autodiscover->generate();
     $wsdl->dump($wsdlFilename);
     $server = new Server($wsdlFilename);
     $server->setClass('\\ZendTest\\Soap\\TestAsset\\errorClass');
     $client = new \Zend\Soap\Client\Local($server, $wsdlFilename);
     $client->triggerError();
     unlink($wsdlFilename);
 }