Made the demo work with suds

This commit is contained in:
Christophe de Vienne 2011-09-26 10:42:22 +02:00
parent 446d1489d7
commit a08a53a1c4
5 changed files with 17 additions and 3 deletions

View File

@ -2,5 +2,6 @@ from suds.client import Client
url = 'http://127.0.0.1:8989/api.wsdl'
client = Client(url)
client = Client(url, cache=None)
print client

View File

@ -18,6 +18,8 @@ import wsme.restjson
import wsme.restxml
import wsme.soap
import logging
class Person(object):
id = int
@ -48,5 +50,8 @@ def app_factory(global_config, **local_conf):
soap = wsme.soap.SoapProtocol(
tns='http://example.com/demo',
typenamespace='http://example.com/demo/types',
baseURL='http://127.0.0.1:8989/',
)
return wsgify(DemoRoot([soap])._handle_request)
logging.basicConfig(level=logging.DEBUG)

View File

@ -147,10 +147,13 @@ class WSRoot(object):
return self._api
def _select_protocol(self, request):
log.debug("Selecting a protocol for the following request :\n"
"headers: %s\nbody: %s", request.headers, request.body)
protocol = None
if 'wsmeproto' in request.params:
protocol = self.protocols[request.params['wsmeproto']]
else:
for p in self.protocols.values():
if p.accept(request):
protocol = p

View File

@ -7,6 +7,7 @@ import pkg_resources
import datetime
import decimal
import base64
import logging
from simplegeneric import generic
@ -22,6 +23,7 @@ import wsme.types
from wsme import exc
from wsme.utils import *
log = logging.getLogger(__name__)
xsi_ns = 'http://www.w3.org/2001/XMLSchema-instance'
type_qn = '{%s}type' % xsi_ns
@ -147,6 +149,7 @@ class SoapProtocol(object):
self.tns = tns
self.typenamespace = typenamespace
self.servicename = 'MyApp'
self.baseURL = baseURL
self._name_mapping = {}
def get_name_mapping(self, service=None):
@ -165,6 +168,8 @@ class SoapProtocol(object):
for ct in self.content_types:
if req.headers['Content-Type'].startswith(ct):
return True
if req.headers.get("Soapaction"):
return True
return False
def extract_path(self, request):
@ -245,7 +250,7 @@ class SoapProtocol(object):
funclist = self.root.getapi(),
arrays = [],
list_attributes = wsme.types.list_attributes,
baseURL = service,
baseURL = self.baseURL,
soap_type = self.soap_type,
soap_fname = self.soap_fname,
)

View File

@ -95,7 +95,7 @@
<wsdl:documentation>WSDL File for ${service_name}</wsdl:documentation>
<wsdl:port binding="tns:${service_name}_Binding" name="${service_name}_PortType">
<soap:address
location="${baseURL}/"/>
location="${baseURL}"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>