Ich habe folgendes Problem: Ich weiß nicht, wie ich einen Web-Service aufrufen kann...
Service.py:
Code: Alles auswählen
#!/usr/bin/env python
import SOAPpy
def GetString():
string = 'Hello World'
return string
server = SOAPpy.SOAPServer(("localhost", 8081))
server.registerFunction(GetString)
try:
server.serve_forever()
except KeyboardInterrupt:
pass
Code: Alles auswählen
#!/usr/bin/env python
import cherrypy
import SOAPpy as SOAP
from SOAPpy import WSDL
SOAP.Config.debug = 1
class Index(object):
def __init__(self):
self.wsdlFile = 'http://localhost:80/wsdl/GetString.wsdl'
self.server = WSDL.Proxy(self.wsdlFile)
def index(self):
'''Show String'''
formular = '''<form action="showString" method="GET">
<input type="submit"/>
</form>'''
return formular
index.exposed = True
def showString(self):
string = self.server.GetString()
return string
showString.exposed = True
if __name__ == '__main__':
cherrypy.config.update({'server.socketPort' : 8080,
'server.threadPool' : 10,
'server.environment' : 'production'})
cherrypy.root = Index()
cherrypy.server.start()
Code: Alles auswählen
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="GetString"
targetNamespace="http://localhost:80/wsdl/GetString.wsdl"
xmlns:tns="http://localhost:80/wsdl/GetString.wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<message name="GetStringResponse">
<part name="Response" type="xsd:string"/>
</message>
<portType name="GetStringPortType">
<operation name="GetString">
<output message="tns:GetStringResponse"/>
</operation>
</portType>
<binding name="GetStringSoapBinding" type="tns:GetStringPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="GetString">
<soap:operation soapAction="http://localhost:8081/GetString"/>
<!--<input>
<soap:body use="encoded" namespace="GetString"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>-->
<output>
<soap:body use="encoded" namespace="GetString"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="GetStringService">
<documentation>Get a sring</documentation>
<port name="GetString" binding="tns:GetStringSoapBinding">
<soap:address location="http://localhost:8081/GetString"/>
</port>
</service>
</definitions>
Ich weiß leider nicht, od das WSDL-File so stimmt.<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>Method Not Found</faultstring>
<detail xsi:type="xsd:string">GetString:GetString : exceptions.KeyError u'GetString' <traceback object at 0xb7b44aa4></detail>
Vielleicht kann mir ja jemand helfen!
Schon mal vielen Dank dafür, dass ihr bis hier her gelesen habt!
Tschau Tobias