Beispiel #1
0
 /**
  * Méthode de génération d'un fichier WSDL à partir d'une classe de définition
  * Les méthodes publics de la classe doivent être commentées par le biais de PHPDocComment décrivant les paramètres (nom & type) ainsi que le format de retour
  *
  * @param string $pServiceName
  * @param string $pNamespace
  * @param string $pSoapLocation
  * @param string $pClassName
  * @return String   XML préformaté par le biais de la classe SimpleXML
  */
 public static function generateWSDLFromClass($pServiceName, $pNamespace, $pSoapLocation, $pClassName)
 {
     $ref = new ReflectionClass($pClassName);
     $methods = $ref->getMethods();
     $callable_methods = array();
     foreach ($methods as $method) {
         $comments = $method->getDocComment();
         if ($method->isPrivate() || $method->isProtected() || $method->isConstructor() || $method->isDestructor() || empty($comments)) {
             continue;
         }
         $callable_methods[$method->name] = self::parseDocComment($comments);
     }
     $operations = array();
     $bindings = array();
     $messages = array();
     foreach ($callable_methods as $name => $context) {
         $op = array('name' => $name, 'input' => array('message' => 'tns:' . $name . 'Request'), 'output' => array('message' => 'tns:' . $name . 'Response'));
         $binding = array('name' => $name, 'soap:operation' => array('soapAction' => "urn:" . $pServiceName . "#" . $name), 'input' => array('soap:body' => array('use' => 'encoded', 'namespace' => $pNamespace, 'encodingStyle' => 'http://schemas.xmlsoap.org/soap/encoding/')), 'output' => array('soap:body' => array('parts' => 'return', 'use' => 'encoded', 'namespace' => $pNamespace, 'encodingStyle' => 'http://schemas.xmlsoap.org/soap/encoding/')));
         $message = array(array('name' => $name . 'Request'), array('name' => $name . 'Response'));
         if (!empty($context['parametersOrder'])) {
             $op['parameterOrder'] = $context['parametersOrder'];
             $binding['input']['soap:body']['parts'] = $context['parametersOrder'];
         }
         foreach ($context["parameters"] as $p) {
             if (!isset($message[0]['part'])) {
                 $message[0]['part'] = array();
             }
             $message[0]['part'][] = array('name' => $p['name'], 'type' => 'xsd:' . $p['type']);
         }
         if (is_array($context['return']) && !empty($context['return'])) {
             $message[1]['part'] = array('name' => 'return', 'type' => 'xsd:' . $context['return']['type']);
         }
         $operations[] = $op;
         $bindings[] = $binding;
         $messages = array_merge($message, $messages);
     }
     $wsdl = array("definitions" => array('xmlns' => 'http://schemas.xmlsoap.org/wsdl/', 'name' => $pServiceName, 'targetNamespace' => $pNamespace, 'xmlns:tns' => $pNamespace, 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema', 'xmlns:soap' => 'http://schemas.xmlsoap.org/wsdl/soap/', 'xmlns:soapenc' => 'http://schemas.xmlsoap.org/soap/encoding/', 'xmlns:wsdl' => 'http://schemas.xmlsoap.org/wsdl/', 'portType' => array('name' => $pServiceName . 'Type', 'operation' => $operations), 'binding' => array('name' => $pServiceName . 'Binding', 'type' => 'tns:' . $pServiceName . 'Type', 'soap:binding' => array('style' => 'rpc', 'transport' => 'http://schemas.xmlsoap.org/soap/http'), 'operation' => $bindings), 'message' => $messages, 'service' => array('name' => $pServiceName . 'Service', 'port' => array('name' => $pServiceName . 'Port', 'binding' => 'tns:' . $pServiceName . 'Binding', 'soap:address' => array('location' => $pSoapLocation)))));
     return SimpleXML::encode($wsdl);
 }
Beispiel #2
0
 /**
  * Renvoi le contenu du flux RSS courant au format XML
  * @return String
  */
 public function toXML()
 {
     return SimpleXML::encode($this->toArray());
 }
Beispiel #3
0
 public function read()
 {
     if ($this->zipHandler->open($this->path) === false) {
         return false;
     }
     $this->data = array();
     $tmp_values = $this->zipHandler->getFromName(self::XML_STRINGS);
     $tmp_values = SimpleXML::decode($tmp_values);
     $string_values = array();
     foreach ($tmp_values["sst"]["si"] as &$v) {
         $string_values[] = $v["t"]["nodeValue"];
     }
     $cells = $this->zipHandler->getFromName(self::XML_CELLS);
     $tmp_data = SimpleXML::decode($cells);
     $range_letters = range("a", "z");
     $columns = 0;
     foreach ($tmp_data["worksheet"]["sheetData"]["row"] as &$r) {
         $cols = array();
         for ($i = 0; $i < $columns; $i++) {
             $cols[] = "";
         }
         foreach ($r["c"] as &$c) {
             if (empty($this->data)) {
                 $columns++;
             }
             if (!isset($c["v"]) || !is_array($c["v"])) {
                 continue;
             }
             $v = $c["v"]["nodeValue"];
             if (empty($c["v"]["nodeValue"])) {
                 $c["v"]["nodeValue"] = 0;
             }
             if (isset($c["t"]) && $c["t"] == "s" && isset($string_values[$c["v"]["nodeValue"]])) {
                 $v = $string_values[$c["v"]["nodeValue"]];
             }
             preg_match("/^([a-z]+)([0-9]+)/i", $c["r"], $matches);
             $l = strtolower($matches[1]);
             $cols[array_search($l, $range_letters)] = $v;
         }
         $this->data[] = $cols;
     }
     $this->zipHandler->close();
     return $this->data;
 }
Beispiel #4
0
 /**
  * Formatte les destinataires au format XML tel que l'attend le webservice MPRemote
  * @return String
  */
 public function getXML()
 {
     $c = array("TOS" => array("TO" => array()));
     foreach ($this->list as &$to) {
         $fields = array();
         foreach ($to[self::PARAMETERS] as $k => $v) {
             $fields[] = array("NAME" => $k, "nodeValue" => $v);
         }
         $c["TOS"]["TO"][] = array("EMAIL" => $to[self::EMAIL], "UNICITY" => array("nodeValue" => $to[self::EMAIL]), "FIELD" => $fields);
     }
     return SimpleXML::encode($c, false);
 }