|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54074 SoapClient classmap ignores currently set namespace
Submitted: 2011-02-22 19:43 UTC Modified: 2018-03-23 11:51 UTC
Avg. Score:3.8 ± 0.7
Reproduced:5 of 5 (100.0%)
Same Version:2 (40.0%)
Same OS:2 (40.0%)
From: php at jcald dot com Assigned:
Status: Not a bug Package: SOAP related
PHP Version: 5.3.5 OS: Linux 2.6.18-194 (Centos 5.5)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
8 + 38 = ?
Subscribe to this entry?

 [2011-02-22 19:43 UTC] php at jcald dot com
When a class extending SoapClient is defined in a namespace, the classmap ignores the current namespace and maps classes directly to the global namespace.  In order for it to function correctly, the classmap must include the "fully qualified" namespace\classname as the target.

Currently, I'm using a wrapper class for SoapClient that prepends __NAMESPACE__ onto the classmap entries to get around this issue.

Test script:
// This is NOT a fully complete test script, since it requires testing against an actual SOAP server to function.  Plus I couldn't fit that in 20 lines.
//Does not work:
namespace Other;
class OtherService extends \SoapClient {
    private static $classmap = array(
            'session' => 'session',
            'foo'     => 'foo'
    // etc etc

namespace Other;
class OtherService extends \SoapClient {
    private static $classmap = array(
            'session' => 'Other\session',
            'foo'     => 'Other\foo'
    // etc etc

Expected result:
The classmap would obey the current namespace.

Actual result:
PHP Fatal error:  Class 'session' not found in test.php on line XX


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-04-12 00:55 UTC] me at jacobt dot com
You need to define the namespace in the classmap.. eg.

private static $classmap = array(
    'foo' => 'Other\foo',
    'bar' => 'Other\bar'
 [2015-01-23 19:49 UTC] info at cyclical dot ca
This issue is still present in php 5.5 and is confirmed. The workaround is to always specify a full namespace starting from the root \. Unfortunately this can get pretty verbose.
 [2018-03-23 11:51 UTC]
-Status: Open +Status: Not a bug
 [2018-03-23 11:51 UTC]
Class names inside strings are *always* fully qualified. As of PHP 5.5 the ::class syntax can be used to retrieve the canonical class name, that is in your case using session::class and foo::class gives 'Other\session' and 'Other\foo'.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Jul 12 19:01:29 2024 UTC