问题
I've spent the last week developing code to connect to a Web Service using the nuSoap library. I just deployed the code to production, but immediately started getting error's that I hadn't seen before. I traced the problem back to a line of code that is trying to instantiate a new soapclient object. It turns out that both libraries have a class named 'soapclient' and the one that's being created in production is from the native Soap library, not the nuSoap library that I'm including. How can I disable the native Soap functionality and stick strictly to nuSoap?
回答1:
With the release of PHP5 there is a soapclient
class included in the php_soap extension. NuSOAP has renamed its class to nusoap_client
. If your copy of NuSOAP is current you should be able to use that. This doesn't disable the php_soap extension, but should allow you to use the NuSOAP class without further conflict.
回答2:
Ah, nevermind. NuSoap 0.7.3 (which I was using) changed the class name to 'nusoap_client' specifically to avoid this conflict. They also included a backward compatibility check that aliased that class with 'soapclient' if the native Soap extension wasn't loaded, which is why I didn't catch that on my development machine.
Ref: http://code.google.com/p/nusoap-for-php5/issues/detail?id=2
回答3:
I don't blame you, the built in soap library for PHP is complete and total embarrassment, especially when compared to python web services.
One option is to remove the extension at compile time:
This extension is only available if PHP was configured with --enable-soap.
Another option is to rename soap-client in nuSoap. Notepad++'s search and replace works well, but you really shouldn't have to do this.
来源:https://stackoverflow.com/questions/2420103/disable-native-soap-class-in-php5-and-use-nusoap