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

Problems using SOAP::Data as method parameters

Expand Messages
  • gtbaddy
    Hi, I have been banging my head against the wall for a few days attempting to get SOAP requests working with this WSDL. I am trying to send a request to a
    Message 1 of 3 , Jan 13, 2011
    • 0 Attachment
      Hi, I have been banging my head against the wall for a few days attempting to get SOAP requests working with this WSDL. I am trying to send a request to a method using SOAP::Data and SOAP::Header objects, but I keep getting a response of

      "String value expected instead of SOAP::Data reference"

      Below is my code -- any ideas what I am doing wrong? I am new to SOAP, so excuse me if I am missing something fundamental.




      #!/usr/bin/perl -w
      use strict;
      use SOAP::Lite;

      # location of the wsdl & namespace
      my $wsdl = 'https://s7sps1apissl.scene7.com/scene7/webservice/IpsApi-2010-01-31.wsdl';
      my $apins = 'http://www.scene7.com/IpsApi/xsd/2010-01-31';

      # authentication request headers
      my @headers = (
      SOAP::Header->name('user')->value('myuser')->uri($apins),
      SOAP::Header->name('password')->value('mypass')->uri($apins),
      SOAP::Header->name('appName')->value('myapp')->uri($apins),
      SOAP::Header->name('appVersion')->value('0.01')->uri($apins)
      );

      # make proxy for the service
      my $soap = SOAP::Lite->service($wsdl);

      # add fault hanlder
      $soap->on_fault(

      sub { # SOAP fault handler
      my $soap = shift;
      my $res = shift;

      # Map faults to exceptions
      if(ref($res) eq '') {
      die($res);
      }
      else {
      die($res->faultstring);
      }

      return new SOAP::SOM;
      }

      );

      # request method
      print $soap->checkLogin( SOAP::Data->name(email => 'testuser'), SOAP::Data->name(password => 'testpassword'), @headers );




      Thanks,
      Patrick
    • Martin Busik
      Hi, ... In this case, SOAP::Lite tries to construct the request itself. use $soap- call( checkLogin ,$SOAP::Data,@headers) instead eventually you have to
      Message 2 of 3 , Jan 14, 2011
      • 0 Attachment
        Hi,

        > Hi, I have been banging my head against the wall for a few
        > days attempting to get SOAP requests working with this WSDL.
        > I am trying to send a request to a method using SOAP::Data
        > and SOAP::Header objects, but I keep getting a response of
        >
        > "String value expected instead of SOAP::Data reference"
        >
        > Below is my code -- any ideas what I am doing wrong? I am new
        > to SOAP, so excuse me if I am missing something fundamental.

        > # location of the wsdl & namespace
        > my $wsdl =
        > 'https://s7sps1apissl.scene7.com/scene7/webservice/IpsApi-2010
        > -01-31.wsdl';
        > my $apins = 'http://www.scene7.com/IpsApi/xsd/2010-01-31';
        >
        > # authentication request headers
        > my @headers = (
        > SOAP::Header->name('user')->value('myuser')->uri($apins),
        > SOAP::Header->name('password')->value('mypass')->uri($apins),
        > SOAP::Header->name('appName')->value('myapp')->uri($apins),
        > SOAP::Header->name('appVersion')->value('0.01')->uri($apins)
        > );
        >
        > # make proxy for the service
        > my $soap = SOAP::Lite->service($wsdl);
        >
        > # request method
        > print $soap->checkLogin( SOAP::Data->name(email =>
        > 'testuser'), SOAP::Data->name(password => 'testpassword'), @headers );

        In this case, SOAP::Lite tries to construct the request itself.

        use $soap->call('checkLogin',$SOAP::Data,@headers) instead

        eventually you have to completely ignore the wsdl and configure the $soap
        object
        manually, e.g.

        $soap = SOAP::Lite->uri(...)->proxy(...)

        Cheers,
        Martin
      • Martin Busik
        Hi, ... with proxy($url) you set the endpoint url, i.e. the url you will find in the wsdl under:
        Message 3 of 3 , Jan 14, 2011
        • 0 Attachment
          Hi,

          > I tried using the call method previously but it would always
          > warn me that no proxy was defined. I was unsure what value to
          > use as a proxy -- is that something that is defined anywhere
          > in the WSDL file? I was looking at the CPAN documentation and


          with proxy($url) you set the endpoint url, i.e. the url you will find in the
          wsdl under:

          <wsdlsoap:address location="$url"

          (typically, near the end of the wsdl)



          > Also, is there a way for me to view the XML I am producing
          > with my SOAP::Data / SOAP::Header objects to debug what I am
          > generating?

          yep.

          use SOAP::Lite (+trace => [qw(transport debug parameters)]);

          Cheers,
          Martin
        Your message has been successfully submitted and would be delivered to recipients shortly.