Exemple #1
1
$loader = Zend_Loader_Autoloader::getInstance();
$loader->setFallbackAutoloader(true);
$loader->suppressNotFoundWarnings(false);
require_once "Zend/Soap/Wsdl.php";
require_once "Zend/Soap/Server.php";
require_once "Zend/Soap/AutoDiscover.php";
require_once '../library/Shift8.php';
/**
 * While trying to develop the Soap extension for Shift8, I needed a way to debug
 * the events occuring to the remote asterisk, thus the Debug Listener and the 
 * Syslog debug listener
 */
require_once '../library/Debug/Listener/Syslog.php';
if (isset($_GET['wsdl'])) {
    $autodiscover = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex');
    $autodiscover->setOperationBodyStyle(array('use' => 'literal', 'namespace' => 'http://' . $_SERVER['HTTP_HOST']));
    /*	
     * Does not work with PHP Soap Client. Might be required for .NET clients
     *
    $autodiscover->setBindingStyle(
    	array(
    		'style'		=> 'document',
    		'transport' 	=> 'http://schemas.xmlsoap.org/soap/http'
    	)
    );
    */
    $autodiscover->setClass('Shift8');
    $autodiscover->handle();
} else {
    session_start();
    $wsdl = sprintf('http://%s%s?wsdl', $_SERVER['HTTP_HOST'], $_SERVER['SCRIPT_NAME']);
<?php

ini_set("soap.wsdl_cache_enabled", 0);
ini_set("soap.wsdl_cache_dir", "/tmp");
ini_set("soap.wsdl_cache_ttl", 86400);
if (isset($_GET['wsdl'])) {
    $autodiscover = new Zend_Soap_AutoDiscover();
    $autodiscover->setBindingStyle(array('style' => 'rpc'));
    $autodiscover->setOperationBodyStyle(array('use' => 'literal'));
    $autodiscover->setClass('ProviderWebServiceSyncUnits');
    $data = file_get_contents('php://input');
    $autodiscover->handle($data);
} else {
    $server = new Zend_Soap_Server(__URLSERVERAPP__ . '/webservices/unidades/server.php?wsdl', array('cache_wsdl' => false));
    $server->setClass('ProviderWebServiceSyncUnits');
    $server->setPersistence(SOAP_PERSISTENCE_REQUEST);
    $data = file_get_contents('php://input');
    $server->handle($data);
}
Exemple #3
0
 function testAddFunctionSimpleWithDifferentStyle()
 {
     $scriptUri = 'http://localhost/my_script.php';
     $server = new Zend_Soap_AutoDiscover();
     $server->setBindingStyle(array('style' => 'document', 'transport' => 'http://framework.zend.com'));
     $server->setOperationBodyStyle(array('use' => 'literal', 'namespace' => 'http://framework.zend.com'));
     $server->addFunction('Zend_Soap_AutoDiscover_TestFunc');
     $dom = new DOMDocument();
     ob_start();
     $server->handle();
     $dom->loadXML(ob_get_clean());
     $dom->save(dirname(__FILE__) . '/_files/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="Zend_Soap_AutoDiscover_TestFunc"><xsd:complexType><xsd:sequence><xsd:element name="who" type="xsd:string"/></xsd:sequence></xsd:complexType></xsd:element>' . '<xsd:element name="Zend_Soap_AutoDiscover_TestFuncResponse"><xsd:complexType><xsd:sequence><xsd:element name="Zend_Soap_AutoDiscover_TestFuncResult" type="xsd:string"/></xsd:sequence></xsd:complexType></xsd:element>' . '</xsd:schema>' . '</types>' . '<portType name="' . $name . 'Port">' . '<operation name="Zend_Soap_AutoDiscover_TestFunc"><documentation>Test Function</documentation><input message="tns:Zend_Soap_AutoDiscover_TestFuncIn"/><output message="tns:Zend_Soap_AutoDiscover_TestFuncOut"/></operation>' . '</portType>' . '<binding name="' . $name . 'Binding" type="tns:' . $name . 'Port">' . '<soap:binding style="document" transport="http://framework.zend.com"/>' . '<operation name="Zend_Soap_AutoDiscover_TestFunc">' . '<soap:operation soapAction="' . $scriptUri . '#Zend_Soap_AutoDiscover_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="Zend_Soap_AutoDiscover_TestFuncIn"><part name="parameters" element="tns:Zend_Soap_AutoDiscover_TestFunc"/></message>' . '<message name="Zend_Soap_AutoDiscover_TestFuncOut"><part name="parameters" element="tns:Zend_Soap_AutoDiscover_TestFuncResponse"/></message>' . '</definitions>';
     $this->assertEquals($wsdl, $this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), "Bad WSDL generated");
     $this->assertTrue($dom->schemaValidate(dirname(__FILE__) . '/schemas/wsdl.xsd'), "WSDL Did not validate");
     unlink(dirname(__FILE__) . '/_files/addfunction.wsdl');
 }