On 06/19/14 03:40, Robert Barcklay wrote:
>
> I am trying to generate an XML element for a SOAP *header* using Spyne
> 2.10.10 that looks like this:
>
> <ns1:Action ns2:must_understand="1">MyAction</ns1:action>
>
> I cannot figure out how to define my Class in Spyne get this output
> when the response is generated. I've tried many approaches for both
> defining the class and then setting the values.
>
> Can it be done with a subclass of Unicode?
>
> class Action(Unicode):
> must_understand = XMLAttribute(Unicode)
>
>
>
> This doesn't seem to work.
it won't.
>
> When I use ComplexModel as the superclass, I get an element name of
> 'string' which is not right.
>
> class Action (ComplexModel):
> __type_name__ = "Action"
> __namespace__ = NAMESPACE_ADDRESSING
> data = XmlData(Unicode)
> must_understand = XmlAttribute(Unicode)
> ...
>
> Action.__call__(data ='myAction', must_understand="1")
>
>
>
> Results (in bold):
>
> <senv:Header>
> * <xs:string must_understand="1">myAction</xs:string>*
> ...
> </senv:Header>
>
>
>
> Why is this coming out as 'string' and not 'Action' ? How can I put a
> different namespace in front of 'must_understand'?
class Action (ComplexModel):
class Attributes(ComplexModel.Attributes):
sub_ns = "SOME_NS"
sub_name = "Action"
data = XmlData(Unicode)
must_understand = XmlAttribute(Unicode)
see:
https://github.com/arskom/spyne/blob/d0f7cc4167c6ccef0390dc5095c23112f14a5254/spyne/test/protocol/test_xml.py#L674
>
> Any suggestions greatly appreciated. There is an open Stackoverflow
> question on this topic:
>
> http://stackoverflow.com/questions/22016045/setting-xml-element-text-nodes-in-spyne
>
I answered it, but that's not the same case as your issue. There was a
bug about your case which prevented sub_ns and sub_name working when the
class at hand is not serialized as a child of a ComplexModel subclass.
I hope this helps.
Best,
Burak
_______________________________________________
Soap mailing list
[email protected]
https://mail.python.org/mailman/listinfo/soap