在PySimpleSoap

时间:2015-09-09 07:23:22

标签: php python soap wsdl pysimplesoap

鉴于以下PHP返回有效的Soap / XML响应:

$params = new StdClass();
$params->subRequest = new StdClass();
$params->subRequest->endCSN = "0212341234";
$client = new SoapClient($WSDL);
$response = $client->qualifyProduct($params);

我正在尝试用Python实现与这个Web服务的连接,但是我没有走得太远 - 遇到错误(我在PHP中尝试过,只是作为一个完整性检查)。

到目前为止,我已经尝试了许多可能的选项,这些选项似乎在我脑海中有意义,包括:

client = SoapClient(WSDL)
a = type('lambdaobject', (object,), {})()
a.endCSN = "0212341234"
response = client.qualifyProduct(subRequest = a)`

response = client.qualifyProduct({'subRequest':{'endCSN':{'0212121212'}}})

response = client.qualifyProduct(subRequest = {'endCSN':{'0212121212'}})

没有一个工作 - 并且都给我一个PySimpleSoap错误,如:

ValueError: Invalid Args Structure. Errors: [u"Argument key subRequest not in parameter.

PySimpleSoap: How to pass a complexType as a function parameter的答案似乎提供了一线希望,但最终并没有在我的实例中发挥作用。

我确实有其他函数使用给定的WSDL,但没有一个具有ComplexType的方法定义像这样的提取,其中subRequest和anotherSubRequest类型在另一个.xsd文件中定义:

<xsd:complexType name="QualifyProductRequest">
    <xsd:sequence>
        <xsd:choice>
            <xsd:element name="subRequest" type="wsg:subRequest">
                <xsd:annotation>
                    <xsd:documentation xml:lang="en">A complex type capturing required data for a qualification</xsd:documentation>
                </xsd:annotation>
            </xsd:element>
            <xsd:element name="anotherSubRequest" type="wsg:anotherSubRequest">
                <xsd:annotation>
                    <xsd:documentation xml:lang="en">A complex type capturing required data for a different qualification</xsd:documentation>
                </xsd:annotation>
            </xsd:element>
        <! -- SNIPPED -->
        </xsd:choice>
    </xsd:sequence>
</xsd:complexType>

0 个答案:

没有答案