From e3ea3400bd54336be58caef9efd0d0ac9c189054 Mon Sep 17 00:00:00 2001 From: wei <> Date: Fri, 19 Jan 2007 07:47:59 +0000 Subject: Enforce encoding of wsdl and soap service headers and --- framework/3rdParty/WsdlGen/Wsdl.php | 10 ++++++++-- framework/3rdParty/WsdlGen/WsdlGenerator.php | 10 ++++++---- framework/Web/Services/TSoapService.php | 7 ++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/framework/3rdParty/WsdlGen/Wsdl.php b/framework/3rdParty/WsdlGen/Wsdl.php index eb41049f..eaf95ef1 100644 --- a/framework/3rdParty/WsdlGen/Wsdl.php +++ b/framework/3rdParty/WsdlGen/Wsdl.php @@ -76,13 +76,17 @@ class Wsdl */ private $bindingTransport = 'http://schemas.xmlsoap.org/soap/http'; + private $_encoding=''; + /** * Creates a new Wsdl thing * @param string $name the name of the service. * @param string $serviceUri The URI of the service that handles this WSDL + * @param string character encoding */ - public function __construct($name, $serviceUri='') + public function __construct($name, $serviceUri='', $encoding='') { + $this->_encoding = $encoding; $this->serviceName = $name; if ($serviceUri == '') $serviceUri = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; $this->serviceUri = str_replace('&', '&', $serviceUri); @@ -101,7 +105,9 @@ class Wsdl */ protected function buildWsdl() { - $xml = ' + $encoding = $this->_encoding==='' ? '' : 'encoding="'.$this->_encoding.'"'; + + $xml = ' wsdlDocument = new Wsdl($className, $serviceUri); + $this->wsdlDocument = new Wsdl($className, $serviceUri, $encoding); $classReflect = new ReflectionClass($className); $methods = $classReflect->getMethods(); @@ -116,11 +117,12 @@ class WsdlGenerator * Static method that generates and outputs the generated wsdl * @param string $className The name of the class to export * @param string $serviceUri The URI of the service that handles this WSDL + * @param string $encoding character encoding. */ - public static function generate($className, $serviceUri='') + public static function generate($className, $serviceUri='', $encoding='') { $generator = WsdlGenerator::getInstance(); - $generator->generateWsdl($className, $serviceUri); + $generator->generateWsdl($className, $serviceUri,$encoding); //header('Content-type: text/xml'); return $generator->getWsdl(); //exit(); diff --git a/framework/Web/Services/TSoapService.php b/framework/Web/Services/TSoapService.php index d838217e..087b5664 100644 --- a/framework/Web/Services/TSoapService.php +++ b/framework/Web/Services/TSoapService.php @@ -244,11 +244,12 @@ class TSoapService extends TService { Prado::trace("Running SOAP service",'System.Web.Services.TSoapService'); $server=$this->createServer(); + $this->getResponse()->setContentType('text/xml'); + $this->getResponse()->setCharset($server->getEncoding()); if($this->getIsWsdlRequest()) { // server WSDL file Prado::trace("Generating WSDL",'System.Web.Services.TSoapService'); - $this->getResponse()->setContentType('text/xml'); $this->getResponse()->write($server->getWsdl()); } else @@ -441,14 +442,14 @@ class TSoapServer extends TApplicationComponent if(is_string($wsdl)) return $wsdl; Prado::using('System.3rdParty.WsdlGen.WsdlGenerator'); - $wsdl=WsdlGenerator::generate($providerClass, $this->getUri()); + $wsdl=WsdlGenerator::generate($providerClass, $this->getUri(), $this->getEncoding()); $cache->set(self::WSDL_CACHE_PREFIX.$providerClass,$wsdl); return $wsdl; } else { Prado::using('System.3rdParty.WsdlGen.WsdlGenerator'); - return WsdlGenerator::generate($providerClass, $this->getUri()); + return WsdlGenerator::generate($providerClass, $this->getUri(), $this->getEncoding()); } } else -- cgit v1.2.3