Skip to content

Commit

Permalink
Zend\Uri: Updated Soap component to use new API
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Jul 21, 2011
1 parent 31aa50c commit 0b9e4fe
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 35 deletions.
16 changes: 5 additions & 11 deletions library/Zend/Soap/AutoDiscover.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@
/**
* \Zend\Soap\AutoDiscover
*
* @uses \Zend\Server\AbstractServer
* @uses \Zend\Server\Server
* @uses \Zend\Server\Reflection
* @uses \Zend\Soap\AutoDiscover\Exception
* @uses \Zend\Soap\Wsdl
* @uses \Zend\Uri\Uri
* @category Zend
* @package Zend_Soap
* @subpackage AutoDiscover
Expand Down Expand Up @@ -88,13 +82,13 @@ class AutoDiscover implements \Zend\Server\Server
*
* @var string
*/
protected $_wsdlClass = '\Zend\Soap\Wsdl';
protected $_wsdlClass = 'Zend\Soap\Wsdl';

/**
* Constructor
*
* @param boolean|string|\Zend\Soap\Wsdl\Strategy $strategy
* @param string|\Zend\Uri\Uri $uri
* @param string|Uri\Uri $uri
* @param string $wsdlClass
*/
public function __construct($strategy = true, $uri=null, $wsdlClass=null)
Expand All @@ -115,7 +109,7 @@ public function __construct($strategy = true, $uri=null, $wsdlClass=null)
* Set the location at which the WSDL file will be availabe.
*
* @throws \Zend\Soap\AutoDiscover\Exception
* @param \Zend\Uri\Uri|string $uri
* @param Uri\Uri|string $uri
* @return \Zend\Soap\AutoDiscover
*/
public function setUri($uri)
Expand All @@ -138,7 +132,7 @@ public function setUri($uri)
/**
* Return the current Uri that the SOAP WSDL Service will be located at.
*
* @return \Zend\Uri\Uri
* @return Uri\Uri
*/
public function getUri()
{
Expand All @@ -148,7 +142,7 @@ public function getUri()
$schema = $this->getSchema();
$host = $this->getHostName();
$scriptName = $this->getRequestUriWithoutParameters();
$uri = new Uri\Url($schema . '://' . $host . $scriptName);
$uri = Uri\UriFactory::factory($schema . '://' . $host . $scriptName);
$this->setUri($uri);
}
return $uri;
Expand Down
34 changes: 14 additions & 20 deletions library/Zend/Soap/Wsdl.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,12 @@
*/
namespace Zend\Soap;

use Zend\Uri\Url;
use DOMDocument,
Zend\Uri\Uri;

/**
* \Zend\Soap\Wsdl
*
* @uses DOMDocument
* @uses \Zend\Server\Exception
* @uses \Zend\Soap\WsdlException
* @uses \Zend\Soap\Wsdl\Strategy\AbstractStrategy
* @uses \Zend\Soap\Wsdl\Strategy\AnyType
* @uses \Zend\Soap\Wsdl\Strategy\DefaultComplexType
* @uses \Zend\Soap\Wsdl\Strategy\StrategyInterface
* @category Zend
* @package Zend_Soap
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
Expand Down Expand Up @@ -79,13 +73,13 @@ class Wsdl
* Constructor
*
* @param string $name Name of the Web Service being Described
* @param string|\Zend\URL $uri URI where the WSDL will be available
* @param string|Uri $uri URI where the WSDL will be available
* @param boolean|string|\Zend\Soap\Wsdl\Strategy $strategy
*/
public function __construct($name, $uri, $strategy = true)
{
if ($uri instanceof URL) {
$uri = $uri->generate();
if ($uri instanceof Uri) {
$uri = $uri->toString();
}
$this->_uri = $uri;

Expand All @@ -101,7 +95,7 @@ public function __construct($name, $uri, $strategy = true)
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:soap-enc='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'></definitions>";
$this->_dom = new \DOMDocument();
$this->_dom = new DOMDocument();
if (!$this->_dom->loadXML($wsdl)) {
throw new Exception\RuntimeException('Unable to create DomDocument');
} else {
Expand All @@ -114,13 +108,13 @@ public function __construct($name, $uri, $strategy = true)
/**
* Set a new uri for this WSDL
*
* @param string|\Zend\URL $uri
* @param string|Uri $uri
* @return \Zend\Server\Wsdl
*/
public function setUri($uri)
{
if ($uri instanceof URL) {
$uri = $uri->generate();
if ($uri instanceof Uri) {
$uri = $uri->toString();
}
$oldUri = $this->_uri;
$this->_uri = $uri;
Expand All @@ -129,7 +123,7 @@ public function setUri($uri)
// @todo: This is the worst hack ever, but its needed due to design and non BC issues of WSDL generation
$xml = $this->_dom->saveXML();
$xml = str_replace($oldUri, $uri, $xml);
$this->_dom = new \DOMDocument();
$this->_dom = new DOMDocument();
$this->_dom->loadXML($xml);
}

Expand Down Expand Up @@ -361,8 +355,8 @@ public function addSoapBinding($binding, $style = 'document', $transport = 'http
*/
public function addSoapOperation($binding, $soap_action)
{
if ($soap_action instanceof URL) {
$soap_action = $soap_action->generate();
if ($soap_action instanceof Uri) {
$soap_action = $soap_action->toString();
}
$soap_operation = $this->_dom->createElement('soap:operation');
$soap_operation->setAttribute('soapAction', $soap_action);
Expand All @@ -383,8 +377,8 @@ public function addSoapOperation($binding, $soap_action)
*/
public function addService($name, $port_name, $binding, $location)
{
if ($location instanceof URL) {
$location = $location->generate();
if ($location instanceof Uri) {
$location = $location->toString();
}
$service = $this->_dom->createElement('service');
$service->setAttribute('name', $name);
Expand Down
8 changes: 4 additions & 4 deletions tests/Zend/Soap/AutoDiscoverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -719,28 +719,28 @@ public function testUsingRequestUriWithoutParametersAsDefault()
// Apache
$_SERVER = array('REQUEST_URI' => '/my_script.php?wsdl', 'HTTP_HOST' => 'localhost');
$server = new AutoDiscover();
$uri = $server->getUri()->generate();
$uri = $server->getUri()->toString();
$this->assertNotContains("?wsdl", $uri);
$this->assertEquals("http://localhost/my_script.php", $uri);

// Apache plus SSL
$_SERVER = array('REQUEST_URI' => '/my_script.php?wsdl', 'HTTP_HOST' => 'localhost', 'HTTPS' => 'on');
$server = new AutoDiscover();
$uri = $server->getUri()->generate();
$uri = $server->getUri()->toString();
$this->assertNotContains("?wsdl", $uri);
$this->assertEquals("https://localhost/my_script.php", $uri);

// IIS 5 + PHP as FastCGI
$_SERVER = array('ORIG_PATH_INFO' => '/my_script.php?wsdl', 'SERVER_NAME' => 'localhost');
$server = new AutoDiscover();
$uri = $server->getUri()->generate();
$uri = $server->getUri()->toString();
$this->assertNotContains("?wsdl", $uri);
$this->assertEquals("http://localhost/my_script.php", $uri);

// IIS
$_SERVER = array('HTTP_X_REWRITE_URL' => '/my_script.php?wsdl', 'SERVER_NAME' => 'localhost');
$server = new AutoDiscover();
$uri = $server->getUri()->generate();
$uri = $server->getUri()->toString();
$this->assertNotContains("?wsdl", $uri);
$this->assertEquals("http://localhost/my_script.php", $uri);
}
Expand Down

0 comments on commit 0b9e4fe

Please sign in to comment.