[Python-de] Aufruf eines Wegservices aus Python

Christopher Arndt chris.arndt at web.de
Mo Nov 19 16:41:49 CET 2007


Philipp Walderdorff schrieb:
> Wie kann ich im Python ein Webservice aufrufen?
> Mit wsdl2py ?
> 
> Als Neuling in Python bin ich auf der Suche nach Dokumentation zu dem Thema.

Was für einen Webservice? Über SOAP? Xml-RPC? REST/HTTP?

Für SOAP schau dir mal SOAPpy an.

Unter debian/Ubuntu gibt es dazu das Paket "python-soappy".

Wenn du die URL des Webservices und die Namen der aufzurufenden Methoden
kennst, funktioniert eine SOAP-Aufruf so:

from SOAPpy import SOAPProxy
proxy = SOAPProxy('http://blah.com/ExampleService')
result = proxy.exampleMethod()

Wenn der Webservice eine WSDL-Datei bereitstellt, so:

from SOAPpy.WSDL import Proxy
proxy = Proxy('http://blah.com/ExampleService?WSDL')
result = proxy.exampleMethod()


Für xml-rpc gibt es ein Modul in der Standard Bibliothek:

http://www.python.org/doc/current/lib/module-xmlrpclib.html

Die Doku enthält auch ein Beispiel für einen Client:

http://www.python.org/doc/current/lib/xmlrpc-client-example.html

> Weiss jemand, wie ich das am schnellsten erlernen kann?

Nach "SOAP tutorial" und "SOAP Python" googlen. Ausprobieren.


Hdh, Chris




Mehr Informationen über die Mailingliste python-de