arskom / spyne Goto Github PK
View Code? Open in Web Editor NEWA transport agnostic sync/async RPC library that focuses on exposing services with a well-defined API using popular protocols.
Home Page: http://spyne.io
License: Other
A transport agnostic sync/async RPC library that focuses on exposing services with a well-defined API using popular protocols.
Home Page: http://spyne.io
License: Other
When you look through the code you can see lots of: "import rpclib". IMHO This should be avoided at all costs. Many of these imports are actually only for namespace inclusion. This can be changed by:
This may not be an issue now, but it came up whilst playing with rpclib 1.1
I'll try to make a patch and create pull request if I have the time.
Hi
I am getting the following error while trying to import soapmethod in soaplib-0.9.2-alpha2.
from SoapService import SoapFolder, soapmethod, String, Integer, Array
ImportError: cannot import name soapmethod
has your library http://www.w3schools.com/schema/schema_complex_mixed.asp support?
when defining multiple soap applications, inside the same python process, the soaplib.nsmap and friends get crowded fast. it's best for every soap application to have its own nsmap and prefmap.
In the library, conversion of double (float is the same in fact) to xml is not exact. If you send a double and than receive the same double back the result is not exactly the same.
The problem is that str() function is used for float serialization. Python does not guaranty that float(str(x)) == x. One has to use repr() insted, which is guarantied to be roundtrip invariant for IEEE 754.
Consider the following example:
float(str(1./3.)) == (1./3.)
And:
float(repr(1./3.)) == (1./3.)
The XmlObject serializer is the basis for SOAP serializer. But the serializer itself is not working. It can be used to serialize to xml without the soap cruft.
The following code would fail:
class X(ClassSerializer):
x = Integer(max_occurs="unbounded")
class Y(X):
y = String
class Service(DefinitionBase):
@rpc(Y)
def test(self, Y):
# whatsoever
The problem in in ClassSerializer.from_xml. At the moment this is handled as follows:
if mo == 'unbounded' or mo > 1:
value = getattr(inst, key, None)
if value is None:
value = []
But for derived classes the x (in my example) is set to Integer and not to None. You could for example check if:
not(isinstance(value, types.TypeType)) and hasattr(value, "class")
The last "hasattr" check is only necessary for old style classes.
there is no http://www.w3schools.com/Schema/el_choice.asp support
the tests should be brought in line with the new api.
I've noticed that the documentation is written around soaplib v0.8.1dev.
I've already begun work on this. But, since soaplib no longer includes a client should the client/calling the service portion of the examples be included? If we need a client is everybody ok with suds being used since it is relatively simple and quick to use.
I can mistake, but I concluded that:
By default wsgi.Application uses target namespace as namespace for Fault:
s0:Faults0:faultcodeClient/s0:faultcodes0:faultstringpatients_patient.last_name may not be NULL/s0:faultstrings0:detail/s0:detail/s0:Fault
But Fault declared in http://schemas.xmlsoap.org/soap/envelope/ and SOAP must be:
"senv:Fault< faultcode>Client< /faultcode>< faultstring>patients_patient.last_name may not be NULL< /faultstring>< detail>< /detail>/senv:Fault"
Adding method name to faultcode is wrong too (wsgi.py, Application.__handle_soap_request, line 565):
except Exception, e:
if method_name:
fault_code = '%sFault' % method_name
else:
fault_code = 'Server'
See http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383507,
and next paragraph: http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383510
the problem is in impossible to return isolated fault soap-response. as i can see the every call 'make_soap_fault' with the 'detail' parameter contains the stacktrace data. could it be configurable for suppress the debug info (that is partially private, i think)?
There are failing tests in the test suite, mostly due to lagging behind api changes.
there are also a few tests failing with "Test something!" exceptions.
currently, 7 out of 49 tests fail.
so that we can do, e.g.
from soaplib import ClassSerializer
instead of
from soaplib.model.clazz import ClassSerializer
failing because of lack of proper asserts.
currently, soaplib offers wrapped responses. e.g.
<senv:Body>
<s6:get_daemon_uuidResponse>
<s6:get_daemon_uuidResult xsi:type="xs:string">6a3a1506-c9e5-11df-9794-00304892b05a</s6:get_daemon_uuidResult>
</s6:get_daemon_uuidResponse>
</senv:Body>
it can be desirable to offer unwrapped responses. e.g.
<senv:Body>
<s6:get_daemon_uuidResult xsi:type="xs:string">6a3a1506-c9e5-11df-9794-00304892b05a</s6:get_daemon_uuidResult>
</senv:Body>
an option can be introduced to control that.
there is no way to create
<xs:simpleType name="mytype">
<xs:restriction base="xs:int">
<xs:totalDigits value="5"/>
/xs:restriction
/xs:simpleType
in order to validate the whole message, some magic in setup.py is required to include soap schemas inside the source distribution
e.g.
http://schemas.xmlsoap.org/soap/encoding/
http://schemas.xmlsoap.org/soap/envelope/
sometimes, it's convenient to have all the objects inside the service's namespace. currently, all objects must have explicit namespace assignments using the __namespace__
class variable.
this was the default behaviour in soaplib-0.8, but in later branches this was changed to automatically inherit module names.
some users have expressed concerns towards lxml usage. it's a c module that's not trivial to deploy.
offering a pure-python xml backend support would increase soaplib adoption.
it also must be made clear that this will cause a performance penalty.
failing because of lack of proper asserts.
When running this file, I get this assertion error:
Traceback (most recent call last): File "tests.py", line 88, in server = make_server('localhost', 7789, Application([UserManager], 'tns')) File "/usr/local/lib/python2.6/dist-packages/soaplib-1.0.0_beta6-py2.6.egg/soaplib/wsgi.py", line 90, in __init__ self.build_schema() File "/usr/local/lib/python2.6/dist-packages/soaplib-1.0.0_beta6-py2.6.egg/soaplib/wsgi.py", line 186, in build_schema schema_entries = inst.add_schema(schema_entries) File "/usr/local/lib/python2.6/dist-packages/soaplib-1.0.0_beta6-py2.6.egg/soaplib/service.py", line 417, in add_schema method.in_message.add_to_schema(schema_entries) File "/usr/local/lib/python2.6/dist-packages/soaplib-1.0.0_beta6-py2.6.egg/soaplib/serializers/clazz.py", line 259, in add_to_schema v.add_to_schema(schema_entries) File "/usr/local/lib/python2.6/dist-packages/soaplib-1.0.0_beta6-py2.6.egg/soaplib/serializers/clazz.py", line 236, in add_to_schema if not schema_entries.has_class(cls): File "/usr/local/lib/python2.6/dist-packages/soaplib-1.0.0_beta6-py2.6.egg/soaplib/service.py", line 162, in has_class ns_prefix = cls.get_namespace_prefix() File "/usr/local/lib/python2.6/dist-packages/soaplib-1.0.0_beta6-py2.6.egg/soaplib/serializers/base.py", line 72, in get_namespace_prefix retval = soaplib.get_namespace_prefix(ns) File "/usr/local/lib/python2.6/dist-packages/soaplib-1.0.0_beta6-py2.6.egg/soaplib/__init__.py", line 58, in get_namespace_prefix assert ns != "__main__" AssertionError
It is because of naming class "Integer".
I add new serializer "Int" in clazz.py (copy of Integer) and use it in @rpc decorator - it works better.
Integer derived from Decimal, and VS code generator use String type to store it.
In http://www.w3.org/2001/XMLSchema "int" and "integer" is different types, so both must present in soaplib, isn't it?
Also .NET XmlSerializer can't parse compound types in SOAP from soaplib.
Do you know reason of this behaviour?
failing because of lack of proper asserts.
It can be helpful to have a kind of anyType that would try to transform to known types. This is not difficult after all, but you have to now the internals of soaplib. For a trivial use it may be to involved to write it yourself. Here is a small example how it could look like:
def fromAny(self, element):
"""
Converts anyType from etree to known types.
Parameters
----------
element : etree instance (lxml class)
"""
# if no children => empty
if len(element) == 0:
return None
res = None
#first see if we have type info in the element
givenType = element.get(xsi_qname, '')
givenType = givenType.split(':')[-1]
if givenType in globals() and .... (check that it inherits ClassSerializer):
clazz = globals()[givenType]
try:
return clazz.from_xml(element)
except Exception:
return None
The soaplib.primitive.Duration
class in currently maps to duration class in soaplib.util.duration
. It should rather map to the datetime.timedelta
class from python.
However, the spec of the duration class is a mess. i think we should force the 3.2.6.4 Totally ordered durations.
the serialize_soap returns an etree structure whereas the deserialize_soap accepts a string.
an example can be seen here:
http://github.com/arskom/soaplib/blob/master/src/soaplib/client/_base.py
this line is wrong:
egrep -r 'soaplib.wsgi' --exclude-dir=.svn . -l | xargs -n1 sed -i 's/soaplib.wsgi/soaplib.server.wsgi/g'
becuase soaplib.Application and soaplib.server.wsgi.Application are not interchangeable.
integration with caching solutions like memcached should be looked at.
As a general precaution against dos attacks, support for various upper limits should be added.
The two that come to mind is:
Soaplib 0.8 had support for async soap services with callbacks. Now that the soaplib soap client is reimplemented, it's time to fix it.
as the declarative schema definition engine would be of interest to the python xml community in general, it'd be interesting to separate that functionality from soaplib.
primitives.py, line 197:
match = _date_pattern.match(text)
_date_pattern is string (not a re object)
Fix by adding _date_re = re.compile(_date_pattern)
it's impossible to parse or return HUGE soap responses with soaplib, as the etree and string representations of both the request and response must be in memory before returning a response.
it'd be nice to adopt a custom xml (de)serializer that'll yield small chunks of code to the output stream instead of returning one big chunk.
I am getting this error
from soaplib.soap import make_soap_envelope, make_soap_fault, from_soap
ImportError: cannot import name make_soap_fault
Has this function been deprecated from 0.9.x.?
Is there some other function that can be used instead?
converting request formats like json-rpc, rest, xml-rpc to soap calls would be an interesting feature.
how compatible are the 1.1 vs 1.2 / 2.0 versions of the soap/wsdl spec? can they coexist inside the same code base?
does anybody need this?
I've opened a ticket over on the suds trac account https://fedorahosted.org/suds/ticket/339 relating to this issue also, not sure if the problem is with the client or the server but hopefully someone from one of the projects can work it out.
Using soaplib-0.9.2-alpha4 helloworld.py
Using suds-0.4 sudsclient.py (https://fedorahosted.org/suds/attachment/ticket/339/sudsclient.py) https://fedorahosted.org/releases/s/u/suds/python-suds-0.4.tar.gz
2010-08-14 22:33:49,578 [WARNING] append_attribute() @typed.py:118 attribute (type) type, not-found
Suds ( https://fedorahosted.org/suds/ ) version: 0.4 (beta) build: R685-20100513
Service ( Application ) tns="tns"
Prefixes (1)
ns0 = "tns"
Ports (1):
(Application)
Methods (1):
say_hello(xs:string name, xs:integer times, )
Types (3):
say_hello say_helloResponse stringArray
(stringArray){
_type = "s0:stringArray" string[] =
"Hello, Dave", "Hello, Dave", "Hello, Dave", "Hello, Dave", "Hello, Dave",
}
Most examples use still wsg_soap module and SimpleWSGIApp, confusing readers.
not much rational argument for this, as the service instantiations shouldn't be expensive anyway.
it's just that the code would feel cleaner.
Traceback (most recent call last):
File "/usr/lib64/python2.6/wsgiref/handlers.py", line 93, in run
self.result = application(self.environ, self.start_response)
File "/usr/lib64/python2.6/wsgiref/validate.py", line 176, in lint_app
iterator = application(environ, start_response_wrapper)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/wsgi.py", line 88, in call
return self.__handle_soap_request(req_env, start_response)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/wsgi.py", line 157, in __handle_soap_request
result_str = self.serialize_soap(service, result_raw)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/_base.py", line 320, in serialize_soap
result_message, self.get_tns(), soap_body)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/serializers/base.py", line 29, in wrapper
func(cls, value, tns, parent_elt, _args, *_kwargs)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/serializers/clazz.py", line 181, in to_xml
cls.get_members(inst, element)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/serializers/clazz.py", line 168, in get_members
v.to_xml(subvalue, cls.get_namespace(), parent, k)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/serializers/base.py", line 29, in wrapper
func(cls, value, tns, parent_elt, _args, *_kwargs)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/serializers/clazz.py", line 181, in to_xml
cls.get_members(inst, element)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/serializers/clazz.py", line 156, in get_members
parent_cls.get_members(inst, parent)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/serializers/clazz.py", line 168, in get_members
v.to_xml(subvalue, cls.get_namespace(), parent, k)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/serializers/base.py", line 29, in wrapper
func(cls, value, tns, parent_elt, _args, *_kwargs)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/serializers/clazz.py", line 181, in to_xml
cls.get_members(inst, element)
File "/home/plq/src/github/arskom/soaplib/src/soaplib/serializers/clazz.py", line 164, in get_members
for sv in subvalue:
TypeError: 'ClassSerializerMeta' object is not iterable
there is no http://www.w3.org/TR/xmlschema-2/#rf-totalDigits support
in order to support transport mechanisms other than wsgi, the application logic must be separated from the wsgi logic.
Hi,
IMHO all imports in soaplib should be converted to absolute. Relative imports are discouraged and are not supported in newer python versions.
Thanks
failing because of lack of proper asserts.
see here for a use case: pletoss/soaplib.client@2968c73
I'm testing my application that uses soaplib 0.8.1 and I'm getting syntax errors in soaplib that show it doesn't support Python 2.4.3:
SyntaxError at /
invalid syntax (xml.py, line 36)
If we can still break backward compatibility for the 2.0 release, I think we should reconsider the from_xml and to_xml methods. Their names imply they are the reverse of each other, that they should have some kind of symmetry...but they don't. So maybe they should be renamed.
to_xml should be named something like attach_child, since that is what it does. That name would clearly indicate side effects to the objects in the parameters. (I don't like these kinds of side effects but the effort of changing this to use return values is probably too high).
from_xml seems to be about extracting text values from element objects. Why not rename that to str?
normally, the array types in wsdl and soap should extend {http://schemas.xmlsoap.org/soap/encoding/}Array type.
see here:
http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383522
this is not the case with current soaplib. it currently follows an XML schema compatible way:
Having what was formally the serializer renamed/placed in the type package may cause confusion with the python built-in and is probably not the most descriptive name.
It seems that they are closer to a active record style model. I propose we rename the package to something akin to 'model'
Please comment and let me know what you think.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.