DJpumps has asked for the wisdom of the Perl Monks concerning the following question:

I want to invoke a method (that is implemented on a SOAP server) from a SOAP client. The method requires as argument a list of some object (server's WSDL calls is myObject[]).

How do I represent an object (with several members) using SOAP::Data? (say, myObj).

Now, how do I represent a list of such objects using SOAP::Data? ( myObjp[])

Thanks.

-- DJpumps

Replies are listed 'Best First'.
Re: SOAP::Data questions
by gellyfish (Monsignor) on Mar 22, 2005 at 10:17 UTC

    It's easier to think of it from the view of the XML that must be in the SOAP envelope's Body. An example of building up the body using SOAP::Data can be seen in Re: SOAP Beginner ... I hate to impose. An alternative to doing it by hand is to use SOAP::Data::Builder. You might get more specific help if you can post the types and messages part of the WSDL.

    /J\

      Thanks. SOAP::Data::Builder doesn't seem to provide a simple solution unless you know your way around the SOAP envelop syntax and semantics. What I want is an example of how an object looks like and how a list of such objects look like (looks like == represented by SOAP::Data).
      -- DJpumps

        The "object" is defined in the <types> element of the WSDL, it will be defined differently depending on the encoding "style" of the SOAP body and the structure of the "object". I have given you a link to an example of how one particular "object" might be represented using SOAP::Data - the OP in that case had given an example of the XML required.

        If you are going to be working with SOAP you should at least be making some attempt to understand it - please review the documentation at http://www.w3.org/TR/2003/REC-soap12-part0-20030624/ at the very least in the first place.

        /J\

Re: SOAP::Data questions
by jhourcle (Prior) on Mar 22, 2005 at 13:08 UTC

    As gellyfish mentioned, it would really help to see what you're trying to end up with after serialization.

    Personally, because of the type of information I typically deal with, I ended up writing a custom serializer, but it took me a few weeks to wrap my head around how SOAP::Lite's SOAP::Serializer worked. (and I had to rewrite many functions, because they were falling functions directly, not as methods, so I had to override all of the functions which called the functions I was trying to replace).

    Anyway, there is a lot of good information about using SOAP::Data at Majordojo.com, which is the personal website of the current maintainer of SOAP::Lite. You'd probably be interested in the entry on arrays of objects

    You can also get a lot done simply by blessing your object to the correct data type. (it won't solve all issues, however, which is why it's necessary to see what you'd want the resulting XML to look like).

      Thanks for the links. Unfortunately, they didn't help me figure it out yet.

      I suppose I need to dig into it more seriousely.

      -- DJpumps
        it would really help to see what you're trying to end up with after serialization.

        If you don't give us more info, we can't help. The XML string that you are trying to pass would be very useful so we know exactly what you are trying to create. At the very least, the WSDL that you're trying to validate against.

        As you said you know WSDL, you would know that there are plenty of ways to represent the same data. SOAP::Lite by default uses RPC/encoded, which may have unwanted information if you're trying to do document/literal, especially if the other end can't properly deserialize references.