in reply to Using Perl's SOAP::Lite to talk to Python

I have a very vague memory of reading something that made me feel slightly cheated because I couldn't access objects properly over SOAP. I'll see if I can dig it up, but don't hold your breath.

Update: I still haven't been able to find any references to using objects written in a different language. I'm beginning to think that it would be very difficult to write such code, since it would involve, e.g. a Java server translating a Python object reference into a Java reference. For a language without Perl's flexible symbol table it would be quite difficult and messy.

____________________
Jeremy
I didn't believe in evil until I dated it.

  • Comment on Re: Using Perl's SOAP::Lite to talk to Python

Replies are listed 'Best First'.
(jeffa) 2Re: Using Perl's SOAP::Lite to talk to Python
by jeffa (Bishop) on Jul 18, 2002 at 18:50 UTC
    I have coerced Python into talking to a Perl SOAP server in the past (about 1 year ago), but the code is long gone. The main problem i had was with complex Perl structures. The reason i am replying, however, is because i did indeed have troubles coercing Python into dealing with a complex Perl data structure.

    For those who don't already know, a reference/data structure in one language is translated to another language through SOAP via XML elements. For example, here is what a SOAP::Lite string looks like:

    $arg = 'Hello SOAP' <s-gensym3 xsi:type="xsd:string">Hello SOAP</s-gensym3>
    Python's SOAP.py library encodes a string like so:
    <Result xsi:type="xsd:string">Hello SOAP</Result>
    Here is a Perl array (or hash):
    @arg = qw(foo bar baz qux) <s-gensym3 xsi:type="xsd:string">foo</s-gensym3> <s-gensym5 xsi:type="xsd:string">bar</s-gensym5> <s-gensym7 xsi:type="xsd:string">baz</s-gensym7> <s-gensym9 xsi:type="xsd:string">qux</s-gensym9>
    Which is very similar to a Python array:
    <item xsi:type="xsd:string" id="i3" SOAP-ENC:root="0">foo</item> <item xsi:type="xsd:string" id="i4" SOAP-ENC:root="0">bar</item> <item xsi:type="xsd:string" id="i5" SOAP-ENC:root="0">baz</item> <item xsi:type="xsd:string" id="i6" SOAP-ENC:root="0">qux</item>
    But the problem creeps in when you start dealing with references to arrays and hashes:
    $arg = [foo=>bar=>baz=>'qux'] <SOAP-ENC:Array SOAP-ENC:arrayType="xsd:string[4]" xsi:type="SOAP-ENC: +Array"> <item xsi:type="xsd:string">foo</item> <item xsi:type="xsd:string">bar</item> <item xsi:type="xsd:string">baz</item> <item xsi:type="xsd:string">qux</item> </SOAP-ENC:Array> $arg = {foo=>bar=>baz=>'qux'} <s-gensym3 xsi:type="namesp1:SOAPStruct"> <foo xsi:type="xsd:string">bar</foo> <baz xsi:type="xsd:string">qux</baz> </s-gensym3>
    If i recall correctly, Python's SOAP.py module handles these fine, but chokes on nested references, such as:
    $arg = {foo=>{bar=>{baz=>['qux']}},bar=>[bar=>{baz=>'qux'}]} <s-gensym3 xsi:type="namesp2:SOAPStruct"> <foo xsi:type="namesp2:SOAPStruct"> <bar xsi:type="namesp2:SOAPStruct"> <baz SOAP-ENC:arrayType="xsd:string[1]" xsi:type="SOAP-ENC:Array"> <item xsi:type="xsd:string">qux</item> </baz> </bar> </foo> <bar SOAP-ENC:arrayType="xsd:ur-type[2]" xsi:type="SOAP-ENC:Array"> <item xsi:type="xsd:string">bar</item> <item xsi:type="namesp2:SOAPStruct"> <baz xsi:type="xsd:string">qux</baz> </item> </bar> </s-gensym3>
    But, that was a year ago and maybe ZSI is more robust. I have no idea how Java handles such issues. My excitement about SOAP was quelled upon hearing such news reported at nodes like SOAP::Lite and Security (Phrack #58), but now that these security issues have allegedly beed fixed (see Soap::Lite Security Update - Version 0.55 Released), i think i'll start delving back into SOAP. Maybe i'll even have time to write a tutorial on Perl communicating with Java and Python if i am successful. :)

    Oh, i would like to add that working with SOAP::Lite really allowed me to understand Perl Objects. Before, i always thought of objects as containers for methods and attributes. Whenever you slung an object around, it carried its methods and attributes as luggage, so to speak. I was shocked to find out that when you transfer a [Perl] object across the SOAP wire, only the attributes went with it. So, how does a client access an object's methods? It really doesn't - instead it sends a request to the server to access that method, and the server sends the results. This translates to everyday Perl OO when you sling an object reference around, you are only transfering a ref to the attributes - the methods are accessed through the symbol table, not the reference. Likewise, when you observe a Data::Dumper dump of an object. You don't see the methods, just the 'attributes'.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)