Entwickler-Ecke
Programmiersprachen (Server) - Webservice mit PHP, jquery und jquery.soap
traceurmicha - Do 14.11.13 19:56
Titel: Webservice mit PHP, jquery und jquery.soap
Hallo, ich bin gerade am verzweifeln.
Ich habe einen Webservice mit einer WSDL datei geschrieben. Diesen Webservice will ich über die jQuery erweiterung jquery.soap ansprechen. Aber ich kriege einfach kein Ergebnis.
Was mache ich falsch, bzw. wie mache ich es denn richtig? Ich bekomme andauernd einen 404 Fehler.
Service.php
PHP-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9:
| <?php function add($a, $b){ return $a+$b; }
$server = new SoapServer("math.wsdl"); $server->addFunction("add"); $server->handle(); ?> |
math.wsdl
XML-Daten
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43:
| <?xml version='1.0' encoding='UTF-8' ?> <definitions name='Math' targetNamespace = 'http://localhost/ffwneu/math.wsdl' xmlns:tns = 'http://localhost/ffwneu/math.wsdl' 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='addRequest'> <part name='a' type='xsd:int'/> <part name='b' type='xsd:int'/> </message> <message name='addResponse'> <part name='Result' type='xsd:int'/> </message> <portType name='addPortType'> <operation name='add'> <input message='tns:addRequest'/> <output message='tns:addResponse'/> </operation> </portType> <binding name='addBinding' type='tns:addPortType'> <soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/> <operation name='add'> <soap:operation soapAction='urn:Math#add'/> <input> <soap:body use='encoded' namespace='urn:Math' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> </input> <output> <soap:body use='encoded' namespace='urn:Math' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> </output> </operation> </binding> <service name='addService'> <port name='addPort' binding='addBinding'> <soap:address location='http://localhost/ffwneu/Service.php'/> </port> </service> </definitions> |
javascript aufruf
JavaScript-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19:
| function ShowDiag(){ $.soap({ url: 'http://localhost/ffwneu/math.wsdl/', method: 'add', data: { a: 1, b: 2 },
success: function (soapResponse) { alert("ja"); }, error: function (SOAPResponse) { alert(SOAPResponse.content); } }); } |
Christian S. - Do 14.11.13 21:05
Stimmt das, dass im JavaScript in der URL nach "math.wsdl" noch ein Slash kommt?
traceurmicha - Mo 18.11.13 08:56
Momentan ja, aber es ist egal ob mit oder ohne Slash, ich bekomme immer die selbe Fehlermeldung...
Entwickler-Ecke.de based on phpBB
Copyright 2002 - 2011 by Tino Teuber, Copyright 2011 - 2024 by Christian Stelzmann Alle Rechte vorbehalten.
Alle Beiträge stammen von dritten Personen und dürfen geltendes Recht nicht verletzen.
Entwickler-Ecke und die zugehörigen Webseiten distanzieren sich ausdrücklich von Fremdinhalten jeglicher Art!