Index: settings/soap.ini
===================================================================
--- settings/soap.ini	(revision 21434)
+++ settings/soap.ini	(working copy)
@@ -14,6 +14,11 @@
 EnableSOAP=false
 Logging=disabled # not supported yet.
 
+# If disabled, the instance's default siteaccess will always be used.
+# If enabled, the matched siteaccess (host, port, etc) will be used, allowing
+# the usage of soap when multiple ezpublish websites are hosted on one instance
+UseDefaultAccess=disabled
+
 [ExtensionSettings]
 # Extensions for SOAP functions.
 # SOAP functions must be registered under soap/initialize.php
Index: soap.php
===================================================================
--- soap.php	(revision 21434)
+++ soap.php	(working copy)
@@ -75,8 +75,27 @@
 
 // Activate correct siteaccess
 include_once( "access.php" );
-$access = array( 'name' => $ini->variable( 'SiteSettings', 'DefaultAccess' ),
-                 'type' => EZ_ACCESS_TYPE_DEFAULT );
+$soapINI =& eZINI::instance( 'soap.ini' );
+$useDefaultAccess = $soapINI->variable( 'GeneralSettings', 'UseDefaultAccess' );
+
+// old behaviour: DefaultAccess is always used
+if ( $useDefaultAccess == 'enabled' )
+{
+    $access = array( 'name' => $ini->variable( 'SiteSettings', 'DefaultAccess' ),
+                     'type' => EZ_ACCESS_TYPE_DEFAULT );
+}
+// new behaviour: the siteaccess matched by the URI/host/port is used
+else
+{
+    include_once( "lib/ezutils/classes/ezuri.php" );
+    include_once( "lib/ezutils/classes/ezsys.php" );
+
+    $uri =& eZURI::instance( eZSys::requestURI() );
+    $access = accessType( $uri,
+                          eZSys::hostname(),
+                          eZSys::serverPort(),
+                          eZSys::indexFile() );
+}
 $access = changeAccess( $access );
 // Siteaccess activation end
 
