Eris Posted December 3, 2008 Share Posted December 3, 2008 Hi. I've got 2 classes that provide services and 1 wsdl file for both of them, 1 SoapServer and 1 SoapClient. When I do $server->setClass("Class1"); $server->handle(); I can call functions from Class1 in the SoapClient. But if I do $server->setClass("Class1"); $server->setClass("Class2"); $server->handle(); then I am able only to call the functions from Class2, the ones from Class1 disappear. I suppose the problem can be solved if I correctly use namespaces, but don't know how. Here's the php file for the server - server.php: $server = new SoapServer("bla.wsdl"); $server->setClass("Class1"); $server->setClass("Class2"); $server->handle(); class Class1 { public function pow2($a) { return $a * $a; } public function pow3($a) { return $a * $a * $a; } } class Class2 { public function pow4($a) { return $a * $a * $a * $a; } } client.php: $client = new SoapClient("bla.wsdl"); echo "2 ^ 2 = " . $client->pow2(2) . "\n"; echo "2 ^ 3 = " . $client->pow3(2) . "\n"; echo "2 ^ 4 = " . $client->pow4(2) . "\n"; and the wsdl file - bla.wsdl <?xml version ='1.0' encoding ='UTF-8' ?> <definitions xmlns:class1Ns='http://example.org/Class1' xmlns:class2Ns='http://example.org/Class2' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/' xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/' xmlns='http://schemas.xmlsoap.org/wsdl/'> <message name='pow2Request'> <part name='number' type='xsd:float'/> </message> <message name='pow2Response'> <part name='result' type='xsd:float'/> </message> <message name='pow3Request'> <part name='number' type='xsd:float'/> </message> <message name='pow3Response'> <part name='result' type='xsd:float'/> </message> <message name='pow4Request'> <part name='number' type='xsd:float'/> </message> <message name='pow4Response'> <part name='result' type='xsd:float'/> </message> <portType name='Class1PortType'> <operation name='pow2'> <input message='class1Ns:pow2Request'/> <output message='class1Ns:pow2Response'/> </operation> <operation name='pow3'> <input message='class1Ns:pow3Request'/> <output message='class1Ns:pow3Response'/> </operation> </portType> <portType name='Class2PortType'> <operation name='pow4'> <input message='class2Ns:pow4Request'/> <output message='class2Ns:pow4Response'/> </operation> </portType> <binding name='Class1Binding' type='class1Ns:Class1PortType'> <soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/> <operation name='pow2'> <soap:operation soapAction='urn:pow2'/> <input> <soap:body use='literal'/> </input> <output> <soap:body use='literal'/> </output> </operation> <operation name='pow3'> <soap:operation soapAction='urn:pow3'/> <input> <soap:body use='literal'/> </input> <output> <soap:body use='literal'/> </output> </operation> </binding> <binding name='Class2Binding' type='class2Ns:Class2PortType'> <soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/> <operation name='pow4'> <soap:operation soapAction='urn:pow4'/> <input> <soap:body use='literal'/> </input> <output> <soap:body use='literal'/> </output> </operation> </binding> <service name='Class1AndClass2Service'> <port name='Class1Port' binding='class1Ns:Class1Binding'> <soap:address location='http://localhost/collision/server.php'/> </port> <port name='Class2Port' binding='class2Ns:Class2Binding'> <soap:address location='http://localhost/collision/server.php'/> </port> </service> </definitions> If you comment the $server->setClass("Class2"); line in server.php the first two calls in the client: echo "2 ^ 2 = " . $client->pow2(2) . "\n"; echo "2 ^ 3 = " . $client->pow3(2) . "\n"; will work. I've read loads of tutorials and documentation, but couldn't find any solution. So PLEASE help me with this. You're my only hope : ) Quote Link to comment Share on other sites More sharing options...
flyhoney Posted December 3, 2008 Share Posted December 3, 2008 I dont understand the problem. Can you not just combine the functions in the two classes in to one class, or just make sure that you do setClass() with the appropriate class before calling functions? Quote Link to comment Share on other sites More sharing options...
Eris Posted December 3, 2008 Author Share Posted December 3, 2008 No. The thing is that there are not 2 classes in the real code, there're more that 10 classes and I want the SoapServer to provide services from all of them at once... Quote Link to comment Share on other sites More sharing options...
flyhoney Posted December 3, 2008 Share Posted December 3, 2008 Ah, yeah I see what you are getting at. My SOAP is a little rusty or I could provide better help Quote Link to comment Share on other sites More sharing options...
Eris Posted December 3, 2008 Author Share Posted December 3, 2008 Well, thx anyways for attention. At least you lifted this topic up the queue for a while : ) Quote Link to comment Share on other sites More sharing options...
Eris Posted December 4, 2008 Author Share Posted December 4, 2008 Hey, isn't there anybody who knows SOAP? I really need your help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.