From a08a53a1c499f0ba1395d430dabbca3913b6a7ab Mon Sep 17 00:00:00 2001 From: Christophe de Vienne Date: Mon, 26 Sep 2011 10:42:22 +0200 Subject: [PATCH] Made the demo work with suds --- examples/demo/client.py | 3 ++- examples/demo/demo.py | 5 +++++ wsme/controller.py | 3 +++ wsme/soap.py | 7 ++++++- wsme/templates/wsdl.html | 2 +- 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/examples/demo/client.py b/examples/demo/client.py index 118b13c..7b44f3d 100644 --- a/examples/demo/client.py +++ b/examples/demo/client.py @@ -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 diff --git a/examples/demo/demo.py b/examples/demo/demo.py index 0e0741d..340ee4e 100644 --- a/examples/demo/demo.py +++ b/examples/demo/demo.py @@ -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) diff --git a/wsme/controller.py b/wsme/controller.py index 313300c..1ed618d 100644 --- a/wsme/controller.py +++ b/wsme/controller.py @@ -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 diff --git a/wsme/soap.py b/wsme/soap.py index cbe1869..1d61c61 100644 --- a/wsme/soap.py +++ b/wsme/soap.py @@ -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, ) diff --git a/wsme/templates/wsdl.html b/wsme/templates/wsdl.html index 289d2a7..a995f5b 100644 --- a/wsme/templates/wsdl.html +++ b/wsme/templates/wsdl.html @@ -95,7 +95,7 @@ WSDL File for ${service_name} + location="${baseURL}"/>