Made the demo work with suds
This commit is contained in:
parent
446d1489d7
commit
a08a53a1c4
@ -2,5 +2,6 @@ from suds.client import Client
|
|||||||
|
|
||||||
url = 'http://127.0.0.1:8989/api.wsdl'
|
url = 'http://127.0.0.1:8989/api.wsdl'
|
||||||
|
|
||||||
client = Client(url)
|
client = Client(url, cache=None)
|
||||||
|
|
||||||
|
print client
|
||||||
|
@ -18,6 +18,8 @@ import wsme.restjson
|
|||||||
import wsme.restxml
|
import wsme.restxml
|
||||||
import wsme.soap
|
import wsme.soap
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
class Person(object):
|
class Person(object):
|
||||||
id = int
|
id = int
|
||||||
@ -48,5 +50,8 @@ def app_factory(global_config, **local_conf):
|
|||||||
soap = wsme.soap.SoapProtocol(
|
soap = wsme.soap.SoapProtocol(
|
||||||
tns='http://example.com/demo',
|
tns='http://example.com/demo',
|
||||||
typenamespace='http://example.com/demo/types',
|
typenamespace='http://example.com/demo/types',
|
||||||
|
baseURL='http://127.0.0.1:8989/',
|
||||||
)
|
)
|
||||||
return wsgify(DemoRoot([soap])._handle_request)
|
return wsgify(DemoRoot([soap])._handle_request)
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
@ -147,10 +147,13 @@ class WSRoot(object):
|
|||||||
return self._api
|
return self._api
|
||||||
|
|
||||||
def _select_protocol(self, request):
|
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
|
protocol = None
|
||||||
if 'wsmeproto' in request.params:
|
if 'wsmeproto' in request.params:
|
||||||
protocol = self.protocols[request.params['wsmeproto']]
|
protocol = self.protocols[request.params['wsmeproto']]
|
||||||
else:
|
else:
|
||||||
|
|
||||||
for p in self.protocols.values():
|
for p in self.protocols.values():
|
||||||
if p.accept(request):
|
if p.accept(request):
|
||||||
protocol = p
|
protocol = p
|
||||||
|
@ -7,6 +7,7 @@ import pkg_resources
|
|||||||
import datetime
|
import datetime
|
||||||
import decimal
|
import decimal
|
||||||
import base64
|
import base64
|
||||||
|
import logging
|
||||||
|
|
||||||
from simplegeneric import generic
|
from simplegeneric import generic
|
||||||
|
|
||||||
@ -22,6 +23,7 @@ import wsme.types
|
|||||||
from wsme import exc
|
from wsme import exc
|
||||||
from wsme.utils import *
|
from wsme.utils import *
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
xsi_ns = 'http://www.w3.org/2001/XMLSchema-instance'
|
xsi_ns = 'http://www.w3.org/2001/XMLSchema-instance'
|
||||||
type_qn = '{%s}type' % xsi_ns
|
type_qn = '{%s}type' % xsi_ns
|
||||||
@ -147,6 +149,7 @@ class SoapProtocol(object):
|
|||||||
self.tns = tns
|
self.tns = tns
|
||||||
self.typenamespace = typenamespace
|
self.typenamespace = typenamespace
|
||||||
self.servicename = 'MyApp'
|
self.servicename = 'MyApp'
|
||||||
|
self.baseURL = baseURL
|
||||||
self._name_mapping = {}
|
self._name_mapping = {}
|
||||||
|
|
||||||
def get_name_mapping(self, service=None):
|
def get_name_mapping(self, service=None):
|
||||||
@ -165,6 +168,8 @@ class SoapProtocol(object):
|
|||||||
for ct in self.content_types:
|
for ct in self.content_types:
|
||||||
if req.headers['Content-Type'].startswith(ct):
|
if req.headers['Content-Type'].startswith(ct):
|
||||||
return True
|
return True
|
||||||
|
if req.headers.get("Soapaction"):
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def extract_path(self, request):
|
def extract_path(self, request):
|
||||||
@ -245,7 +250,7 @@ class SoapProtocol(object):
|
|||||||
funclist = self.root.getapi(),
|
funclist = self.root.getapi(),
|
||||||
arrays = [],
|
arrays = [],
|
||||||
list_attributes = wsme.types.list_attributes,
|
list_attributes = wsme.types.list_attributes,
|
||||||
baseURL = service,
|
baseURL = self.baseURL,
|
||||||
soap_type = self.soap_type,
|
soap_type = self.soap_type,
|
||||||
soap_fname = self.soap_fname,
|
soap_fname = self.soap_fname,
|
||||||
)
|
)
|
||||||
|
@ -95,7 +95,7 @@
|
|||||||
<wsdl:documentation>WSDL File for ${service_name}</wsdl:documentation>
|
<wsdl:documentation>WSDL File for ${service_name}</wsdl:documentation>
|
||||||
<wsdl:port binding="tns:${service_name}_Binding" name="${service_name}_PortType">
|
<wsdl:port binding="tns:${service_name}_Binding" name="${service_name}_PortType">
|
||||||
<soap:address
|
<soap:address
|
||||||
location="${baseURL}/"/>
|
location="${baseURL}"/>
|
||||||
</wsdl:port>
|
</wsdl:port>
|
||||||
</wsdl:service>
|
</wsdl:service>
|
||||||
</wsdl:definitions>
|
</wsdl:definitions>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user