29 * |
29 * |
30 * @category Zend |
30 * @category Zend |
31 * @package Zend_Soap |
31 * @package Zend_Soap |
32 * @subpackage Server |
32 * @subpackage Server |
33 * @uses Zend_Server_Interface |
33 * @uses Zend_Server_Interface |
34 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
34 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
35 * @license http://framework.zend.com/license/new-bsd New BSD License |
35 * @license http://framework.zend.com/license/new-bsd New BSD License |
36 * @version $Id: Server.php 22223 2010-05-21 08:06:47Z jan $ |
36 * @version $Id: Server.php 25177 2012-12-22 20:54:18Z rob $ |
37 */ |
37 */ |
38 class Zend_Soap_Server implements Zend_Server_Interface |
38 class Zend_Soap_Server implements Zend_Server_Interface |
39 { |
39 { |
40 /** |
40 /** |
41 * Actor URI |
41 * Actor URI |
251 |
260 |
252 if (null !== $this->_uri) { |
261 if (null !== $this->_uri) { |
253 $options['uri'] = $this->_uri; |
262 $options['uri'] = $this->_uri; |
254 } |
263 } |
255 |
264 |
256 if(null !== $this->_features) { |
265 if (null !== $this->_features) { |
257 $options['features'] = $this->_features; |
266 $options['features'] = $this->_features; |
258 } |
267 } |
259 |
268 |
260 if(null !== $this->_wsdlCache) { |
269 if (null !== $this->_wsdlCache) { |
261 $options['cache_wsdl'] = $this->_wsdlCache; |
270 $options['cache_wsdl'] = $this->_wsdlCache; |
262 } |
271 } |
263 |
272 |
|
273 if (null !== $this->_wsiCompliant) { |
|
274 $options['wsi_compliant'] = $this->_wsiCompliant; |
|
275 } |
|
276 |
264 return $options; |
277 return $options; |
265 } |
278 } |
266 |
279 /** |
|
280 * Set WS-I compliant |
|
281 * |
|
282 * @param boolean $value |
|
283 * @return Zend_Soap_Server |
|
284 */ |
|
285 public function setWsiCompliant($value) |
|
286 { |
|
287 if (is_bool($value)) { |
|
288 $this->_wsiCompliant = $value; |
|
289 } |
|
290 return $this; |
|
291 } |
|
292 /** |
|
293 * Gt WS-I compliant |
|
294 * |
|
295 * @return boolean |
|
296 */ |
|
297 public function getWsiCompliant() |
|
298 { |
|
299 return $this->_wsiCompliant; |
|
300 } |
267 /** |
301 /** |
268 * Set encoding |
302 * Set encoding |
269 * |
303 * |
270 * @param string $encoding |
304 * @param string $encoding |
271 * @return Zend_Soap_Server |
305 * @return Zend_Soap_Server |
593 if(isset($this->_object)) { |
627 if(isset($this->_object)) { |
594 require_once 'Zend/Soap/Server/Exception.php'; |
628 require_once 'Zend/Soap/Server/Exception.php'; |
595 throw new Zend_Soap_Server_Exception('An object has already been registered with this soap server instance'); |
629 throw new Zend_Soap_Server_Exception('An object has already been registered with this soap server instance'); |
596 } |
630 } |
597 |
631 |
598 $this->_object = $object; |
632 if ($this->_wsiCompliant) { |
|
633 require_once 'Zend/Soap/Server/Proxy.php'; |
|
634 $this->_object = new Zend_Soap_Server_Proxy($object); |
|
635 } else { |
|
636 $this->_object = $object; |
|
637 } |
599 |
638 |
600 return $this; |
639 return $this; |
601 } |
640 } |
602 |
641 |
603 /** |
642 /** |
688 $xml = $request->__toString(); |
727 $xml = $request->__toString(); |
689 } else { |
728 } else { |
690 $xml = $request; |
729 $xml = $request; |
691 } |
730 } |
692 |
731 |
|
732 libxml_disable_entity_loader(true); |
693 $dom = new DOMDocument(); |
733 $dom = new DOMDocument(); |
694 if(strlen($xml) == 0 || !$dom->loadXML($xml)) { |
734 if(strlen($xml) == 0 || !$dom->loadXML($xml)) { |
695 require_once 'Zend/Soap/Server/Exception.php'; |
735 require_once 'Zend/Soap/Server/Exception.php'; |
696 throw new Zend_Soap_Server_Exception('Invalid XML'); |
736 throw new Zend_Soap_Server_Exception('Invalid XML'); |
697 } |
737 } |
|
738 foreach ($dom->childNodes as $child) { |
|
739 if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) { |
|
740 require_once 'Zend/Soap/Server/Exception.php'; |
|
741 throw new Zend_Soap_Server_Exception( |
|
742 'Invalid XML: Detected use of illegal DOCTYPE' |
|
743 ); |
|
744 } |
|
745 } |
|
746 libxml_disable_entity_loader(false); |
698 } |
747 } |
699 $this->_request = $xml; |
748 $this->_request = $xml; |
700 return $this; |
749 return $this; |
701 } |
750 } |
702 |
751 |
766 } |
815 } |
767 |
816 |
768 if (!empty($this->_class)) { |
817 if (!empty($this->_class)) { |
769 $args = $this->_classArgs; |
818 $args = $this->_classArgs; |
770 array_unshift($args, $this->_class); |
819 array_unshift($args, $this->_class); |
|
820 if ($this->_wsiCompliant) { |
|
821 require_once 'Zend/Soap/Server/Proxy.php'; |
|
822 array_unshift($args, 'Zend_Soap_Server_Proxy'); |
|
823 } |
771 call_user_func_array(array($server, 'setClass'), $args); |
824 call_user_func_array(array($server, 'setClass'), $args); |
772 } |
825 } |
773 |
826 |
774 if (!empty($this->_object)) { |
827 if (!empty($this->_object)) { |
775 $server->setObject($this->_object); |
828 $server->setObject($this->_object); |
818 try { |
871 try { |
819 $this->_setRequest($request); |
872 $this->_setRequest($request); |
820 } catch (Zend_Soap_Server_Exception $e) { |
873 } catch (Zend_Soap_Server_Exception $e) { |
821 $setRequestException = $e; |
874 $setRequestException = $e; |
822 } |
875 } |
823 |
876 |
824 $soap = $this->_getSoap(); |
877 $soap = $this->_getSoap(); |
825 |
878 |
|
879 $fault = false; |
826 ob_start(); |
880 ob_start(); |
827 if($setRequestException instanceof Exception) { |
881 if ($setRequestException instanceof Exception) { |
828 // Send SOAP fault message if we've catched exception |
882 // Create SOAP fault message if we've caught a request exception |
829 $soap->fault("Sender", $setRequestException->getMessage()); |
883 $fault = $this->fault($setRequestException->getMessage(), 'Sender'); |
830 } else { |
884 } else { |
831 try { |
885 try { |
832 $soap->handle($request); |
886 $soap->handle($this->_request); |
833 } catch (Exception $e) { |
887 } catch (Exception $e) { |
834 $fault = $this->fault($e); |
888 $fault = $this->fault($e); |
835 $soap->fault($fault->faultcode, $fault->faultstring); |
|
836 } |
889 } |
837 } |
890 } |
838 $this->_response = ob_get_clean(); |
891 $this->_response = ob_get_clean(); |
839 |
892 |
840 // Restore original error handler |
893 // Restore original error handler |
841 restore_error_handler(); |
894 restore_error_handler(); |
842 ini_set('display_errors', $displayErrorsOriginalState); |
895 ini_set('display_errors', $displayErrorsOriginalState); |
|
896 |
|
897 // Send a fault, if we have one |
|
898 if ($fault) { |
|
899 $soap->fault($fault->faultcode, $fault->faultstring); |
|
900 } |
843 |
901 |
844 if (!$this->_returnResponse) { |
902 if (!$this->_returnResponse) { |
845 echo $this->_response; |
903 echo $this->_response; |
846 return; |
904 return; |
847 } |
905 } |