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. 

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’?

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

-Bob




_______________________________________________
Soap mailing list
[email protected]
https://mail.python.org/mailman/listinfo/soap

Reply via email to