Loading ...
Sorry, an error occurred while loading the content.

Re: [soaplite] sending xsd:complexType in SOAP request

Expand Messages
  • Peter Hartmann
    ... Ok, thanks for clearing this up. For those of you who want to pass complex types to a web service without dealing with the correct namespaces etc. by hand,
    Message 1 of 5 , Feb 5, 2008
    View Source
    • 0 Attachment
      Craig Dunigan wrote:
      > I'm pretty sure stubmaker.pl can't handle complex types.

      Ok, thanks for clearing this up.
      For those of you who want to pass complex types to a web service without
      dealing with the correct namespaces etc. by hand, you might want to try
      out SOAP::WSDL (http://soap-wsdl.sourceforge.net/ and
      http://search.cpan.org/~mkutter/SOAP-WSDL-2.00_29/lib/SOAP/WSDL.pm). It
      is still beta and returned an error when I tried to create code from the
      Amazon WSDL, but it is worth a try.

      Regards,
      Peter


      To pass a
      > complex type, you'll actually have to pass your array as the complex
      > type name required by the method with a value of a ref to a
      > SOAP::Data->value encapsulating your array, and not just a parameter to
      > the method. It's also important to remember that the method name is
      > *not* the name of the complex type required in the request doc. That is,
      > try to think more of the request as a document that you pass to a
      > service name, not as the parameter of a remote method call. The request
      > doc contains a named complex type, and that doc is passed to a named
      > service, and you need both names.
      >
      > It's probably better illustrated as code:
      >
      > my $ds = new AmazonSearchService;
      > my @complextype = (SOAP::Data->name("author" => "Mann"),
      > SOAP::Data->name("page" => "1"),
      > SOAP::Data->name("mode" => "just"),
      > SOAP::Data->name("tag" => "a"),
      > SOAP::Data->name("type" => "try"),
      > SOAP::Data->name("devtag" => "...")
      > );
      > # Amazon's AuthorSearchRequest method accepts a complex type named
      > "AuthorRequest"
      > # which is not the same as the method name "AuthorSearchRequest"
      > $som = $ds->AuthorSearchRequest("AuthorRequest" =>
      > \SOAP::Data->value(@complextype));
      >
      >
      > where ' "AuthorRequest" => \SOAP::Data->value(@complextype) ' is the
      > request document, and ' $ds->AuthorSearchRequest ' is the service name
      > that document is being passed to.
      >
      >
      >
      > I learned this from:
      >
      > http://tardate.blogspot.com/2007/02/complex-soaplite-requests-my-rules-for.html
      >
      >
      > which is the first link on:
      >
      > http://www.soaplite.com/
      >
      > and from a quick search for "AuthorSearchRequest", which turned up a
      > number of links telling me what the format of the request document
      > should be (most especially, the name of the required complex type).
      >
      > And yes, that does mean you have to nest refs if you have a multi-level
      > complex type. Oh, and if the service you're talking to can't handle
      > SOAP::Lite's autotyping (.Net comes to mind), you'll have to explicitly
      > "turn off" autotyping by adding ' type->("") ' to each of your
      > 'SOAP::Data->name' and 'SOAP::Data->value' calls, like this:
      >
      > my @complextype = (SOAP::Data->name("author" => "Mann")->type(""),
      > <snip>
      > $som = $ds->AuthorSearchRequest("AuthorRequest" =>
      > \SOAP::Data->value(@complextype)->type(""));
      >
      >
      > Hope this helps.
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.