0

我想用 Python 和 zeep 实例化一个在 wsdl 中为肥皂 API 定义的匿名类型。对于非匿名类型,我只需使用这样的工厂

    abcinstance = factory.abc('whatever', part2 = 'goes')

然后把它交给我需要调用的函数

    client.service.doSomethingSpecial(abc = abcinstance)

然而这里

    abcdinstance = factory.abcd(Entries = ['something', key = 'else'])

不起作用,因为最后一个“=”显然是错误的语法。需要一个包含一个位置参数和一个命名参数的列表只会增加我的困惑。我对 Python 很陌生,但一定有一种简单的方法可以解决这个问题,对吧?

编辑:

由于您看不到 zeep 生成的代码。由 wsdl.exe 在 c# 中生成的相关代码部分:

    [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.6.1055.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "qwertz")]
public partial class abc
{

    private abcEntry[] entriesField;

    /// <remarks/>
    [System.Xml.Serialization.XmlArrayItemAttribute("Entry", IsNullable = false)]
    public abcEntry[] Entries
    {
        get
        {
            return this.entriesField;
        }
        set
        {
            this.entriesField = value;
        }
    }
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.6.1055.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "qwertz")]
public partial class abcEntry
{

    private string keyField;

    private string valueField;

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public string key
    {
        get
        {
            return this.keyField;
        }
        set
        {
            this.keyField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlTextAttribute()]
    public string Value
    {
        get
        {
            return this.valueField;
        }
        set
        {
            this.valueField = value;
        }
    }
}

我需要实例化类 abc 以将其提供给函数

zeep 中的结构有点不同: abc 需要以下签名:Entries: {Entry: {xsd:string, key: xsd:string}[]}

4

0 回答 0