[Soap-Python] SOAPpy and WSDLs with nested urns...

Dieter Maurer dieter at handshake.de
Wed Nov 30 11:26:45 CET 2011


??? wrote at 2011-11-29 22:14 +0800:
>very appreciate for your advices. maybe the kernel problem is the
>complexType ArrayOf_soapenc_string.
>
>part 1: how do you think the xml in the url:
>
><complexType name="ArrayOf_soapenc_string">
><complexContent>
><restriction base="soapenc:Array">
><attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/>
></restriction>
></complexContent>
></complexType>

XML-Schema is quite complex, too complex for me to tell how
the XML should look like for the type definition above.

I hope that "suds" will know how to serialize corresponding objects.

>part 2: in fact, the server is made by Axis, which is a web service
>framework in Java.
>Before i develop the client, there already have a java client for the
>server.
>the code  are below:
>
>if (temp.length % MTINFO_LENGTH != 0) {
>String[] remainBlock = new String[temp.length - jMark];
>for (int i = 0; i < remainBlock.length; i++) {
>remainBlock[i] = temp[jMark];
>jMark++;
>}
>
>mark = lnxss.sendMt(remainBlock);
>
>After read the code,  we know that the the inparams of sendMt is String[].
>In fact, the purpose of senMt() is to send some shotmessage to a mobile
>phone. you can find remobile in the parameters.

You cannot necessarily translate Java code examples literally to Python.
XML-Schema (and SOAP) is made to provide interoperability at the
XML level, not the language level.

As I wrote, "suds" usually uses a factory to create type instances.
For them, it knows how to serialize them. "suds" often allows to
pass simple Python type instances and does the right thing. But,
in your special case, it might not...

>part 3: Besides, the server has some check, which i have add it in the
>newest code.
>
>servicecode: PABB4BEIJING
>passwd: QWERTPABB
>namespace: service.global.v1_0.wsdl.protocol.xxt (you can see it in the url)

Usually, "suds" adds namespaces as directed by the WSDL.

>I have tried  to add the service code and passwd in the code.
> while,  what  still puzzled me is that in suds, how to add the namespace
>to the client.
>how to use the ArrayOf_soapen_string is a problem. in my code, i provide a
>list which contains some string. in my view, i should provide a object like
>your code,
>aoss = client.factory.create('ArrayOf_soapen_string')
>then, what should i do next?  how to assign a value for the parameter of
>aoss?

I do not know.
I have not used "suds" with types of the kind you have shown above.


In my cases, "print obj" has shown me what attributes "obj" has
and I have assigned values to them. That was is.
I do not know how "suds" handles XML-Schema "restriction".
Maybe, you find something in the "suds" documentation?

>part 4:
>
># the newest code :
>import suds
>def test_sms4():
>    import logging
>    logging.basicConfig(level=logging.ERROR)
> ...
>    req = [item1, item2]
>
>    #client.service.sendMt(aoss)
>    output = client.service.sendMt(mtinfo=req)
>    print 'output', output
>
>
>
># output:
> ...
><SOAP-ENV:Envelope xmlns:ns0="service.global.v1_0.wsdl.protocol.xxt"
>xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="
>http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="
>http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="
>http://schemas.xmlsoap.org/soap/encoding/">
>   <SOAP-ENV:Header/>
>   <SOAP-ENV:Body>
>      <ns0:sendMt>
>         <mtInfo xsi:type="ArrayOf_soapenc_string"/>
>      </ns0:sendMt>
As you can see, the parameter has not been serialized correctly.

The reason might be that "suds" does not accept a list as an
"ArrayOf_soapenc_string" (in this case, some fiddling with
a properly constructed instance might help) or that it cannot handle
this type at all (in which case, you would need to contact the author,
maybe via a bug tracker).



--
Dieter


More information about the Soap mailing list