Пример #1
0
 /**
  * Add a Single or Multiple Functions to the WSDL
  *
  * @param string $function Function Name
  * @param string $namespace Function namespace - Not Used
  */
 public function addFunction($function, $namespace = '')
 {
     static $port;
     static $operation;
     static $binding;
     if (!is_array($function)) {
         $function = (array) $function;
     }
     $uri = $this->getUri();
     if (!$this->_wsdl instanceof Zend_Soap_Wsdl) {
         $parts = explode('.', basename($_SERVER['SCRIPT_NAME']));
         $name = $parts[0];
         $wsdl = new Zend_Soap_Wsdl($name, $uri, $this->_strategy);
         $port = $wsdl->addPortType($name . 'Port');
         $binding = $wsdl->addBinding($name . 'Binding', 'tns:' . $name . 'Port');
         $wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']);
         $wsdl->addService($name . 'Service', $name . 'Port', 'tns:' . $name . 'Binding', $uri);
     } else {
         $wsdl = $this->_wsdl;
     }
     foreach ($function as $func) {
         $method = $this->_reflection->reflectFunction($func);
         foreach ($method->getPrototypes() as $prototype) {
             $args = array();
             foreach ($prototype->getParameters() as $param) {
                 $args[$param->getName()] = $wsdl->getType($param->getType());
             }
             $message = $wsdl->addMessage($method->getName() . 'Request', $args);
             $desc = $method->getDescription();
             if (strlen($desc) > 0) {
                 //$wsdl->addDocumentation($message, $desc);
             }
             if ($prototype->getReturnType() != "void") {
                 $returnName = "return";
                 $message = $wsdl->addMessage($method->getName() . 'Response', array($returnName => $wsdl->getType($prototype->getReturnType())));
             }
             /* <wsdl:portType>'s */
             $portOperation = $wsdl->addPortOperation($port, $method->getName(), 'tns:' . $method->getName() . 'Request', 'tns:' . $method->getName() . 'Response');
             if (strlen($desc) > 0) {
                 //$wsdl->addDocumentation($portOperation, $desc);
             }
             /* </wsdl:portType>'s */
             /* <wsdl:binding>'s */
             $operation = $wsdl->addBindingOperation($binding, $method->getName(), $this->_operationBodyStyle, $this->_operationBodyStyle);
             $wsdl->addSoapOperation($operation, $uri . '#' . $method->getName());
             /* </wsdl:binding>'s */
             $this->_functions[] = $method->getName();
             // We will only add one prototype
             break;
         }
     }
     $this->_wsdl = $wsdl;
 }
Пример #2
0
 function testAddDocumentation()
 {
     $wsdl = new Zend_Soap_Wsdl('MyService', 'http://localhost/MyService.php');
     
     $portType = $wsdl->addPortType('myPortType');
     
     $wsdl->addDocumentation($portType, 'This is a description for Port Type node.');
     
     $this->assertEquals($wsdl->toXml(), 
                         '<?xml version="1.0"?>' . PHP_EOL .
                         '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" '
                            . 'xmlns:tns="http://localhost/MyService.php" '
                            . '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/" '
                            . 'name="MyService" targetNamespace="http://localhost/MyService.php">'
                            . '<portType name="myPortType">'
                            .   '<documentation>This is a description for Port Type node.</documentation>'
                            . '</portType>'
                       . '</definitions>' . PHP_EOL);
 }
Пример #3
0
 /**
  * Add a Single or Multiple Functions to the WSDL
  *
  * @param string $function Function Name
  * @param string $namespace Function namespace - Not Used
  * @return Zend_Soap_AutoDiscover
  */
 public function addFunction($function, $namespace = '')
 {
     static $port;
     static $operation;
     static $binding;
     if (!is_array($function)) {
         $function = (array) $function;
     }
     $uri = $this->getUri();
     if (!$this->_wsdl instanceof Zend_Soap_Wsdl) {
         $parts = explode('.', basename($_SERVER['SCRIPT_NAME']));
         $name = $parts[0];
         $wsdl = new Zend_Soap_Wsdl($name, $uri, $this->_strategy);
         // The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023)
         $wsdl->addSchemaTypeSection();
         $port = $wsdl->addPortType($name . 'Port');
         $binding = $wsdl->addBinding($name . 'Binding', 'tns:' . $name . 'Port');
         $wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']);
         $wsdl->addService($name . 'Service', $name . 'Port', 'tns:' . $name . 'Binding', $uri);
     } else {
         $wsdl = $this->_wsdl;
     }
     foreach ($function as $func) {
         $method = $this->_reflection->reflectFunction($func);
         $this->_addFunctionToWsdl($method, $wsdl, $port, $binding);
     }
     $this->_wsdl = $wsdl;
     return $this;
 }
Пример #4
0
 /**
  * Add a Single or Multiple Functions to the WSDL
  *
  * @param string $function Function Name
  * @param string $namespace Function namespace - Not Used
  */
 public function addFunction($function, $namespace = '')
 {
     static $port;
     static $operation;
     static $binding;
     if (!is_array($function)) {
         $function = (array) $function;
     }
     $uri = Zend_Uri::factory('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']);
     if (!$this->_wsdl instanceof Zend_Soap_Wsdl) {
         $parts = explode('.', basename($_SERVER['SCRIPT_NAME']));
         $name = $parts[0];
         $wsdl = new Zend_Soap_Wsdl($name, $uri, $this->_extractComplexTypes);
         $port = $wsdl->addPortType($name . 'Port');
         $binding = $wsdl->addBinding($name . 'Binding', 'tns:' . $name . 'Port');
         $wsdl->addSoapBinding($binding, 'rpc');
         $wsdl->addService($name . 'Service', $name . 'Port', 'tns:' . $name . 'Binding', $uri);
     } else {
         $wsdl = $this->_wsdl;
     }
     foreach ($function as $func) {
         $method = $this->_reflection->reflectFunction($func);
         foreach ($method->getPrototypes() as $prototype) {
             $args = array();
             foreach ($prototype->getParameters() as $param) {
                 $args[$param->getName()] = $wsdl->getType($param->getType());
             }
             $message = $wsdl->addMessage($method->getName() . 'Request', $args);
             $desc = $method->getDescription();
             if (strlen($desc) > 0) {
                 //$wsdl->addDocumentation($message, $desc);
             }
             if ($prototype->getReturnType() != "void") {
                 $message = $wsdl->addMessage($method->getName() . 'Response', array($method->getName() . 'Return' => $wsdl->getType($prototype->getReturnType())));
             }
             /* <wsdl:portType>'s */
             $portOperation = $wsdl->addPortOperation($port, $method->getName(), 'tns:' . $method->getName() . 'Request', 'tns:' . $method->getName() . 'Response');
             if (strlen($desc) > 0) {
                 //$wsdl->addDocumentation($portOperation, $desc);
             }
             /* </wsdl:portType>'s */
             /* <wsdl:binding>'s */
             $operation = $wsdl->addBindingOperation($binding, $method->getName(), array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"), array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"));
             $wsdl->addSoapOperation($binding, $uri->getUri() . '#' . $method->getName());
             /* </wsdl:binding>'s */
             $this->_functions[] = $method->getName();
             // We will only add one prototype
             break;
         }
     }
     $this->_wsdl = $wsdl;
 }