Veröffentlicht 16. Februar 200619 j Hallo, ich beschäftige mich gerade mit SOAP unter PHP5. Hierzu versuche ich gerade das Beispiel von folgender Seite nachzuvollziehen: http://www.professionelle-softwareentwicklung-mit-php5.de/erste_auflage/programming-php.soap.html Das Beispiel läuft auch soweit, allerdings enden meine Versuche, eine weiter Funktion (nennen wir sie mal zum Test halloHoelle()) immer in Fehlermeldungen... Also bisher habe ich einfach in das gegebene Beispiel folgendes Eingefügt: Datei Bulletin2_server.php <?php class Webdienst { public function halloWelt() { return 'Hallo Welt'; } public function halloHoelle() { return 'Hallo Hölle'; } } try { $server = new SOAPServer('Bulletin2.wsdl'); $server->setClass('Webdienst'); $server->handle(); } catch (SOAPFault $f) { print $f->faultstring; } ?>[/PHP] Datei client.php [PHP]<?php try { $client = new SOAPClient('http://localhost/Bulletin2_server.php?wsdl'); print $client->halloWelt(); print $client->halloHoelle(); } catch (SOAPFault $f) { print $f->faultstring; } ?> und zu guter letzt, meiner Meinung nach der Grund für meine Problemchen: Die WSDL-Datei: <?xml version ="1.0" encoding ="UTF-8" ?> <definitions name="Bulletin2_server" targetNamespace="http://localhost/Bulletin2_server" xmlns:tns=" http://localhost/Bulletin2_server" 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="halloWeltResponse"> <part name="Result" type="xsd:string"/> </message> <portType name="HalloWeltPortType"> <operation name="halloWelt"> <output message="tns:halloWeltResponse"/> </operation> <operation name="halloHoelle"> <output message="tns:halloHoelleResponse"/> </operation> </portType> <binding name="HalloWeltBinding" type="tns:HalloWeltPortType"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="halloWelt"> <soap:operation soapAction="urn:hallowelt#halloWelt"/> <output> <soap:body use="encoded" namespace="urn:hallowelt" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </output> </operation> </binding> <message name="halloHoelleResponse"> <part name="Result" type="xsd:string"/> </message> <binding name="HalloHoelleBinding" type="tns:HalloHoellePortType"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="halloHoelle"> <soap:operation soapAction="urn:hallohoelle#halloHoelle"/> <output> <soap:body use="encoded" namespace="urn:hallohoelle" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </output> </operation> </binding> <service name="HalloWeltService"> <port name="HalloWeltPort" binding="HalloWeltBinding"> <soap:address location="http://localhost/Bulletin2_server.php"/> </port> </service> </definitions> Also ich wäre für jede Hilfe dankbar!! Gruß, Michael
16. Februar 200619 j Meinst Du das 'Hallo Hölle' aus Bulletin2_server.php? Das ist nur ein String, der ausgegeben werden soll, wenn die Funktion HalloHoelle aufgerufen wird. Lieder ist das nicht des Rätsels Lösung... Ich habe so das Gefühl, dass die WSDL-Datei irgendwie nicht korrekt ist, aber ich weiß nicht, was da anders gemacht werde kann...
16. Februar 200619 j Oh, stimmt... Wenn ich jetzt dies hier noch einfüge (ich denke das ist das Service für HalloHoelle), dann geht es allerdings leider immer noch nicht... <service name="HalloHoelleService"> <port name="HalloWeltPort" binding="HalloHoelleBinding"> <soap:address location="http://localhost/Bulletin2_server.php"/> </port> </service> So sieht dann der gesamte Code der WSDL-Datei aus: <?xml version ="1.0" encoding ="UTF-8" ?> <definitions name="Bulletin2_server" targetNamespace="http://localhost/Bulletin2_server" xmlns:tns=" http://localhost/Bulletin2_server" 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="halloWeltResponse"> <part name="Result" type="xsd:string"/> </message> <portType name="HalloWeltPortType"> <operation name="halloWelt"> <output message="tns:halloWeltResponse"/> </operation> <operation name="halloHoelle"> <output message="tns:halloHoelleResponse"/> </operation> </portType> <binding name="HalloWeltBinding" type="tns:HalloWeltPortType"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="halloWelt"> <soap:operation soapAction="urn:hallowelt#halloWelt"/> <output> <soap:body use="encoded" namespace="urn:hallowelt" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </output> </operation> </binding> <message name="halloHoelleResponse"> <part name="Result" type="xsd:string"/> </message> <binding name="HalloHoelleBinding" type="tns:HalloHoellePortType"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="halloHoelle"> <soap:operation soapAction="urn:hallohoelle#halloHoelle"/> <output> <soap:body use="encoded" namespace="urn:hallohoelle" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </output> </operation> </binding> <service name="HalloWeltService"> <port name="HalloWeltPort" binding="HalloWeltBinding"> <soap:address location="http://localhost/Bulletin2_server.php"/> </port> </service> <service name="HalloHoelleService"> <port name="HalloWeltPort" binding="HalloHoelleBinding"> <soap:address location="http://localhost/Bulletin2_server.php"/> </port> </service> </definitions>
16. Februar 200619 j Also im Browser erscheint folgendes: Hallo WeltFunction ("halloHoelle") is not a valid method for this service Das erste ist ja der normale Hallo Welt aufruf, und dann kommt die Fehlermeldung...
Archiv
Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.