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

Re: [soaplite] Need paid consult to solve SOAP::Lite complex parameter issue

Expand Messages
  • Paul Gallagher
    just saw your message ncbjd; here s something that may help. I can t test it of course, but I think it is generating the structure you d indicated is
    Message 1 of 2 , Feb 9, 2009
    • 0 Attachment
      just saw your message ncbjd; here's something that may help. I can't test it of course, but I think it is generating the structure you'd indicated is 'correct'..

      Regards,
      Paul
      http://tardate.blogspot.com


      #!/usr/bin/perl -w
      # $Id$
      # see: http://tech.groups.yahoo.com/group/soaplite/message/6283
      #
      use strict;
      use SOAP::Lite +trace => 'debug';
      use Data::Dumper; $Data::Dumper::Terse = 1; $Data::Dumper::Indent = 1;


      $ENV{HTTPS_KEY_FILE}="/root/KeyStoreFinal20081222.x509";
      $ENV{HTTPS_CERT_FILE}="/root/SignedCert20081222.crt";
      $ENV{HTTPS_DEBUG}=1;

      my $uri ='https://198.136.211.18:8448/axis/services';
      my $proxy ='https://198.136.211.18:8448/axis/services/TPGSecureLink';
      my $serviceNs = 'http://types.secureLink.touchnet.com';


      # define the soap object
      my $soap = SOAP::Lite
        -> uri ( $uri )
        -> proxy ( $proxy );

      # define the ticketName structure
      my $ticketName=SOAP::Data->name("ticketName" => "Test Ticket");

      # define one of the nameValuePairs on its own
      my $nameValuePair1=
        \SOAP::Data->value(
              SOAP::Data->name("name" => "AMT"),
              SOAP::Data->name("value" => "45.00")->type("xsd:string")
          );

      # define the nameValuePairs structure, using two techniques    
      my $nameValuePairs =
        SOAP::Data->value(
            SOAP::Data->name("nameValuePairs" => $nameValuePair1 ),
            SOAP::Data->name("nameValuePairs" =>
                \SOAP::Data->value(
                    SOAP::Data->name("name" => "ID"),
                    SOAP::Data->name("value" => "123")->type("xsd:string")
                )
            )
        );
       
      # debug/inspect a structure
      print Dumper $nameValuePairs;

         
      # make the call and get the request
      my $som = $soap->call(
          SOAP::Data
          ->name('generateSecureLinkTicketRequest')->attr({xmlns => $serviceNs})
          => $ticketName
          => $nameValuePairs
      );

      # cool for debugging. see http://tech.groups.yahoo.com/group/soaplite/message/5946
      print $soap->transport->http_request->content();

      1;


      __END__
      # notes and comments

      <request as generated by this script ncbjd_soapProblem.pl>

      <?xml version="1.0" encoding="UTF-8"?>
      <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <SOAP-ENV:Body>
      <generateSecureLinkTicketRequest xmlns="http://types.secureLink.touchnet.com">
      <ticketName xsi:type="xsd:string">Test Ticket</ticketName>
      <nameValuePairs>
      <name xsi:type="xsd:string">AMT</name>
      <value xsi:type="xsd:string">45.00</value>
      </nameValuePairs>
      <nameValuePairs>
      <name xsi:type="xsd:string">ID</name>
      <value xsi:type="xsd:string">123</value>
      </nameValuePairs>
      </generateSecureLinkTicketRequest>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>

      </request as generated by this script ncbjd_soapProblem.pl>

      On Wed, Feb 4, 2009 at 2:28 AM, ncbjd@... <ncbjd@...> wrote:
      At this point, I am looking for someone to hire to help solve what may
      be a simple problem of serializing a slightly complex parameter sent
      with a SOAP method call. Thank you for your help in solving the
      problem directly, or passing me a pointer to someone who can.

      Below, I have included
      0. the form of the desired xml request
      1. my script,
      2. the relevant parts of the wsdl file, and
      3. the SOAP error message:

      Overview:


      I need to pass a single string (wsdl defined "ticketNumber" of type
      "string") + a [complex] data item (of type "nameValuePairs")
      consisting of two (or more) elements, each a "nameValuePair" (wsdl
      defined as string "name" + string "value"). The resulting XML needs to
      look like this:

      #----------------------------------------------
      #----------------------------------------------

      <correct request xml>

      <?xml version="1.0" encoding="UTF-8"?>
      <soapenv:Envelope
      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                       xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
       <soapenv:Body>
         <generateSecureLinkTicketRequest
      xmlns="http://types.secureLink.touchnet.com">
           <ticketName>Test Ticket</ticketName>
           <nameValuePairs>
             <name>AMT</name>
             <value>45.00</value>
           </nameValuePairs>
           <nameValuePairs>
             <name>ID</name>
             <value>123</value>
           </nameValuePairs>
         </generateSecureLinkTicketRequest>
       </soapenv:Body>
      </soapenv:Envelope>

      </correct request xml>

      #------------------------------------------
      #------------------------------------------
      <script>


      #!/usr/bin/perl
      use strict;
      use warnings;
      use SOAP::Lite + trace=>'debug';

      $ENV{HTTPS_KEY_FILE}="/root/KeyStoreFinal20081222.x509";
      $ENV{HTTPS_CERT_FILE}="/root/SignedCert20081222.crt";
      $ENV{HTTPS_DEBUG}=1;

      my $uri   ='https://198.136.211.18:8448/axis/services';
      my $proxy ='https://198.136.211.18:8448/axis/services/TPGSecureLink';

      my
      $params=SOAP::Data->name("aRequest")->type("SecureLinkTicketRequest")=>SOAP::Data->name("ticketName"
      => "PY13579"),
      SOAP::Data->name("nameValuePairs")->type("secureLinkTypes:nameValuePair")
      => {SOAP::Data->name("AMT"=>"45.00"),
      SOAP::Data->name("BILL_NAME"=>"Luigi Barzoni") };
      my $response =
      SOAP::Lite->uri($uri)->proxy($proxy)->generateSecureLinkTicket($params)->result;

      my @out=$response->paramsout;
      my $out_1=$out[1];
      my $out_2=$out[2];
      my $out_3=$out[3];

      if ($response) {

      print "$out_1\n";
      print "$out_2\n";} else {print"NoJoy";}

      </script>


      #----------------------------------------------
      #----------------------------------------------

      <wsdl>

           <complexType name="nameValuePair" >
             <sequence>
               <element name="name"               type="xsd:string" />
               <element name="value"              type="xsd:string" />
             </sequence>
           </complexType>




          <complexType name="GenerateSecureLinkTicketRequest">
             <sequence>
               <element name="ticketName"         type="xsd:string" />
               <element name="nameValuePairs"
      type="secureLinkTypes:nameValuePair" minOccurs="0"
      maxOccurs="unbounded" />
             </sequence>
           </complexType>

      </wsdl>

      #----------------------------------------------
      #----------------------------------------------

      <fault message>


      <?kml version="1.0" encoding="utf-8"?>
      <soapenv:Envelope
      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                       xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <soapenv:Body>
           <soapenv:Fault>
              <faultcode>
                 soapenv:Server.userException
              </faultcode>
              <faultstring>org.xml.sax.SAXException:
                    Invalid element in
      com.touchnet.secureLink.types.GenerateSecureLinkTicketRequest - aRequest
              </faultstring>
              <detail>
                    <ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">
                         TNETREADY2
                    </ns1:hostname>
              </detail>
           </soapenv:Fault>
        </soapenv:Body>
      </soapenv:Envelope>

      </fault message>



      ------------------------------------

      Yahoo! Groups Links

      <*> To visit your group on the web, go to:
         http://groups.yahoo.com/group/soaplite/

      <*> Your email settings:
         Individual Email | Traditional

      <*> To change settings online go to:
         http://groups.yahoo.com/group/soaplite/join
         (Yahoo! ID required)

      <*> To change settings via email:
         mailto:soaplite-digest@yahoogroups.com
         mailto:soaplite-fullfeatured@yahoogroups.com

      <*> To unsubscribe from this group, send an email to:
         soaplite-unsubscribe@yahoogroups.com

      <*> Your use of Yahoo! Groups is subject to:
         http://docs.yahoo.com/info/terms/


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