Tuesday, 14 September 2021

Create xsd.Element with attribute and string value using Zeep

I'm trying to create a custom SOAP header element using Zeep which has both an attribute and a string value. No other child elements. I'm sure I'm missing out on some piece of information on how to make it, and hope someone can point me in the right direction.

What I want is the following:

<wsse:Password Type="StringAttribute">StringPasswordValue</wsse:Password>

What I've tried so far (and I'm just guessing at syntaxes here):

password_header = xsd.Element('{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Password', xsd.ComplexType([
    xsd.String(),
    xsd.Attribute('Type', xsd.String())
    ]))

password_value = password_header('StringPasswordValue', Type='StringAttribute')

I was also perhaps expecting it to be doable without a xsd.ComplexType, just specifying attributes to a xsd.String, but no such luck. I do not want to make this by using a wsse:UsernameToken.



from Create xsd.Element with attribute and string value using Zeep

No comments:

Post a Comment