Index: Soap/AutoDiscover.php
===================================================================
--- Soap/AutoDiscover.php	(revision 11332)
+++ Soap/AutoDiscover.php	(working copy)
@@ -54,6 +54,16 @@
     private $_extractComplexTypes;
     
     /**
+     * @var Zend_Uri
+     */
+    private $_targetNamespace = null;
+    
+    /**
+     * @var Zend_Uri
+     */
+    private $_endpoint = null;
+    
+    /**
      * Constructor
      * 
      * @param boolean $extractComplexTypes
@@ -65,6 +75,72 @@
     }
     
     /**
+     * Set the target namespace
+     *
+     * @param string|Zend_Uri $uri
+     * @return Zend_Soap_AutoDiscover
+     */
+    public function setTargetNamespace($uri)
+    {
+        if (is_string($uri))
+            $uri = Zend_Uri::factory($uri);
+
+        $this->_targetNamespace = $uri;
+
+        return $this;
+    }
+
+    /**
+     * Get the target namespace
+     *
+     * @return Zend_Uri
+     */
+    public function getTargetNamespace()
+    {
+        if (!$this->_targetNamespace instanceof Zend_Uri) {
+            $this->setTargetNamespace($this->getEndpoint());
+        }
+        
+        return $this->_targetNamespace;
+    }
+    
+    /**
+     * Set the soap endpoint
+     *
+     * @param string|Zend_Uri $uri
+     * @return Zend_Soap_AutoDiscover
+     */
+    public function setEndpoint($uri)
+    {
+        if (is_string($uri))
+            $uri = Zend_Uri::factory($uri);
+
+        $this->_endpoint = $uri;
+
+        return $this;
+    }
+
+    /**
+     * Get the soap endpoint
+     *
+     * @return Zend_Uri
+     */
+    public function getEndpoint()
+    {
+        if (!$this->_endpoint instanceof Zend_Uri) {
+            
+            if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
+                $schema = 'https';
+            } else {
+                $schema = 'http';
+            }
+            $this->setUri(Zend_Uri::factory($schema . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']));
+        }
+        
+        return $this->_endpoint;
+    }    
+        
+    /**
      * Set the Class the SOAP server will use
      *
      * @param string $class Class Name
@@ -73,15 +149,17 @@
      */
     public function setClass($class, $namespace = '', $argv = null)
     {
-        $uri = Zend_Uri::factory('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']);
+        $targetNamespace = $this->getTargetNamespace();
 
-        $wsdl = new Zend_Soap_Wsdl($class, $uri, $this->_extractComplexTypes);
+        $wsdl = new Zend_Soap_Wsdl($class, $targetNamespace, $this->_extractComplexTypes);
         
         $port = $wsdl->addPortType($class . 'Port');
         $binding = $wsdl->addBinding($class . 'Binding', 'tns:' .$class. 'Port');
         
+        $endpoint = $this->getEndpoint();
+        
         $wsdl->addSoapBinding($binding, 'rpc');
-        $wsdl->addService($class . 'Service', $class . 'Port', 'tns:' . $class . 'Binding', $uri);
+        $wsdl->addService($class . 'Service', $class . 'Port', 'tns:' . $class . 'Binding', $endpoint);
         foreach ($this->_reflection->reflectClass($class)->getMethods() as $method) {
             /* <wsdl:portType>'s */
             $portOperation = $wsdl->addPortOperation($port, $method->getName(), 'tns:' .$method->getName(). 'Request', 'tns:' .$method->getName(). 'Response');
@@ -109,7 +187,7 @@
 
                 /* <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->addSoapOperation($binding, $endpoint->getUri() . '#' .$method->getName());
                 /* </wsdl:binding>'s */
             }
         }

