On 03/21/12 00:29, Alex wrote:
Burak,
In parallel with writing the documentation for input validation in
rpclib, I am trying to apply rpclib to solve the problem that brought
me to this list in the first place.
I began creating my custom types and I ran into some cases which don't
seem to be straightforward.
One of the types looks like this
<xs:complexType name="DigestAlgAndValueType">
<xs:sequence>
<xs:element name="DigestMethod" type="ds:DigestMethodType"
minOccurs="0"/>
<xs:element name="DigestValue" type="ds:DigestValueType"/>
</xs:sequence>
</xs:complexType>
ds:DigestMethodType is in another namespace, the link to which is
given in the beginning of the WSDL file. If I understand things
correctly, I have to create a custom class for DigestMethodType and
override its __namespace__ = 'ds'. Can you confirm that?
no, ds is just the prefix. you need to find the xmlns:ds attribute and
use its value as the value of the __namespace__ attribute. Here's how
the above would look like:
class DigestValueType(ComplexModel):
__namespace__ = "some_ns"
class DigestMethodTypeComplexModel):
__namespace__ = "some_ns"
class DigestAlgAndValueType(ComplexModel):
DigestMethod = DigestMethodType
DigestValue = DigestValueType.customize(min_occurs=1)
(1) It is also necessary to modify the top of the generated WSDL file
and include a link to the document that defines the 'ds' namespace.
How to do that? I supposed I could also override the namespace with a
URL to the XML file itself, but is that a good practice?
Ah. Rpclib does not support that directly. But I've just committed
support for the 'document_built' event in the InterfaceBase. so if you
register an event for that and make the desired changes to the generated
wsdl document directly, you can do that.
https://github.com/plq/rpclib/commit/f93b44ffe81ad5bc8b7441b95f58b99fa49a4e7e
DigestMethodType itself is a tricky beast, this is the definition:
http://xml.fmi.fi/namespace/woml/swo/2011/11/15/index790.html
<complexType name="DigestMethodType" mixed="true">
<sequence>
<any namespace="##other" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
</sequence>
<attribute name="Algorithm" type="anyURI" use="required"/>
</complexType>
(2) how does rpclib handle 'namespace="##other"'? My understanding is
that it means I can add an arbitrary number of elements of any type.
The closest match I could find is AnyXml or AnyDict (declared in
primitive.py). However, I am not sure how to use it; test_primitive.py
doesn't cover these two classes.
Rpclib can't generate this schema, you'd have to come up with a patch to
the xml schema implementation that actually emits an <any/> tag.
(3) 'use="required"' - the 'use' attribute is not declared in the
AnyUri class, neither in Unicode or SimpleModels (the classes from
which it was derived). It seems to be a basic attribute; was I unable
to find it? Or is it really not there?
No, it isn't there. I actually didn't know about this. Why not just use
min_occurs=1 ?
(4) 'mixed' is another attribute that I didn't find declared in the
base class of the ComplexType class? Does one really need it? I mean,
maybe it is assumed that all the ComplexType children are mixed by
default?
That isn't supported either. XML Schema specification should say the
default value in case of abscence.
There's another data type with the poetic name 'DataType' :-)
<xs:complexType name="DataType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="MimeType" type="xs:string"
use="optional"/>
<xs:attribute name="Encoding" type="xs:string"
use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
I've seen how to declare elements and attributes in a custom type, but
this is something new to me. It feels like some kind of inheritance,
so:
(5) How to declare such a type?
You can't. Rpclib only supports simpleType extension via restrictions,
not attributes.
I guess this wasn't much of help but what can I say, patches are welcome...
Best Regards,
Burak
_______________________________________________
Soap mailing list
[email protected]
http://mail.python.org/mailman/listinfo/soap