2

我正在尝试使用 Django + Spyne 2.11/2.12.x 模拟现有的 Axis 1.4 服务,并且需要具有特定命名空间前缀(wsse / wsu)的 WS-security Timestamp 令牌。我将它与已经正常工作的 suds 数字签名插件(sudssigner)一起使用。

向 spyne 添加动态 SOAP 标头的推荐方法是什么?

如何强制使用具体的命名空间前缀?

更新: WS 响应应尽可能接近以下示例:

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header>
        <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1">
            <wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-15452452">
                <wsu:Created>2016-02-01T10:14:54.517Z</wsu:Created>
                <wsu:Expires>2016-02-01T10:19:54.517Z</wsu:Expires>
            </wsu:Timestamp>
            <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="Signature-2088192064">
                <ds:SignedInfo>
                    <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
                    <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
                    <ds:Reference URI="#Id-1052429873">
                        <ds:Transforms>
                            <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
                        </ds:Transforms>
                        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
                        <ds:DigestValue>...</ds:DigestValue>
                    </ds:Reference>
                    <ds:Reference URI="#Timestamp-15452452">
                        <ds:Transforms>
                            <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
                        </ds:Transforms>
                        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
                        <ds:DigestValue>...</ds:DigestValue>
                    </ds:Reference>
                </ds:SignedInfo>
                <ds:SignatureValue>
...
                </ds:SignatureValue>
                <ds:KeyInfo Id="KeyId-8475839474">
                    <wsse:SecurityTokenReference xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="STRId-680050181">
                        <wsse:KeyIdentifier EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509SubjectKeyIdentifier">...</wsse:KeyIdentifier>
                    </wsse:SecurityTokenReference>
                </ds:KeyInfo>
            </ds:Signature>
        </wsse:Security>
    </soapenv:Header>
    <soapenv:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Id-1052429873">
...
    </soapenv:Body>
</soapenv:Envelope>

提前谢谢。

4

1 回答 1

0

向 spyne 添加动态 SOAP 标头的推荐方法是什么?

Spyne 已经实现了动态 SOAP 标头。如果您想使用 Spyne 向响应中添加 SOAP 标头,请参见此处的示例:

https://github.com/arskom/spyne/blob/dec5286212602fb793db10ea67c5a1bdcad36315/spyne/test/interop/server/_service.py#L144

如何强制使用具体的命名空间前缀?

什么是“具体命名空间前缀”?如果您希望您的对象位于命名空间中(具体与否),请将它们放在一个名称空间中:

class SomeClass(ComplexModel):
    __namespace__ = "https://a.very.concrete/namespace"

    i = Integer
    s = Unicode
    # etc
于 2016-02-01T18:45:28.203 回答