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

Sending complex type from SOAP::Lite client

Expand Messages
  • nate_bowler
    Still stuck on this.... The biggest problem I have is SOAP::Data- type() method ALWAYS messes up. It references a namespace that isn t delared anywere in the
    Message 1 of 3 , Jul 19, 2002
      Still stuck on this....

      The biggest problem I have is SOAP::Data->type() method ALWAYS messes
      up. It references a namespace that isn't delared anywere in the
      message. For example, if the method call inside the body declares
      an "xmlns:namesp2" namespace, type() method will reference an
      undeclared "namesp3" namespace.

      The following is the CLOSEST I have come to a successful call. Please
      notice the bogus parameter element name, and the invalid namespace in
      the xml.

      I have included my Perl code, the incorrect XML, and a XML message
      that does work in hopes it may help.

      Can anybody offer a suggestion that would help me to generate the
      proper XML from my Perl client? Any help would be appreciated.

      Thanks,
      Nate

      //////////////////////////////////////////////////////////
      // Perl client
      #!perl -w
      use SOAP::Lite;

      my $attask_ns = 'http://www.attask.com/api';

      my $api_server = SOAP::Lite
      -> soapversion(1.2)
      -> uri('http://www.attask.com/api')
      -> service('http://63.228.219.51:8080/attask/APIService.wsdl');

      my $sessionID = $api_server->login("admin","testing");
      print "sessionID:$sessionID\n";

      # build the call parameters
      my $uf2 = SOAP::Data->uri('http://www.attask.com/api')->type('User')-
      >name('User' => \SOAP::Data->value(
      SOAP::Data-
      >name('hasError' => SOAP::Data->type(boolean => 0)),
      SOAP::Data-
      >name('state' => 'UT'),
      SOAP::Data-
      >name('zip' => 'null'),
      SOAP::Data-
      >name('primaryContact' => 'null'),
      SOAP::Data-
      >name('city' => 'null'),
      SOAP::Data-
      >name('username' => 'null'),
      SOAP::Data-
      >name('emailAddr' => 'null'),
      SOAP::Data-
      >name('groupID' => -1),
      SOAP::Data-
      >name('address' => 'null'),
      SOAP::Data-
      >name('firstName' => 'null'),
      SOAP::Data-
      >name('password' => 'null'),
      SOAP::Data-
      >name('lastName' => 'null'),
      SOAP::Data-
      >name('companyName' => 'null'),
      SOAP::Data-
      >name('userID' => -1),
      SOAP::Data-
      >name('phoneNumber' => 'null'),
      ),
      );
      my $userlist = $api_server->getUsersByUserFilter($sessionID, $uf2);
      print "\nusername:" . $$userlist[0]->{'username'} . "\n";

      $api_server->logout($sessionID);


      ///////////////////////////////////////////////////////////
      /// Incorrect SOAP::Lite XML
      <?xml version="1.0" encoding="UTF-8" ?>
      <SOAP-ENV:Envelope
      xmlns:namesp4="http://namespaces.soaplite.com/perl" SOAP-
      ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:xsi="http://www.w3.org/2001/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/2001/XMLSchema">
      <SOAP-ENV:Body>
      <namesp2:getUsersByUserFilter
      xmlns:namesp2="http://www.attask.com/api">
      <String_1 xsi:type="xsd:string">92668751141027099192009</String_1>
      <namesp3:User xmlns:namesp3="http://www.attask.com/api"
      xsi:type="namesp4:User">
      <hasError xsi:type="xsd:boolean">false</hasError>
      <state xsi:type="xsd:string">UT</state>
      <zip xsi:type="xsd:string">null</zip>
      <primaryContact xsi:type="xsd:string">null</primaryContact>
      <city xsi:type="xsd:string">null</city>
      <username xsi:type="xsd:string">null</username>
      <emailAddr xsi:type="xsd:string">null</emailAddr>
      <groupID xsi:type="xsd:int">-1</groupID>
      <address xsi:type="xsd:string">null</address>
      <firstName xsi:type="xsd:string">null</firstName>
      <password xsi:type="xsd:string">null</password>
      <lastName xsi:type="xsd:string">null</lastName>
      <companyName xsi:type="xsd:string">null</companyName>
      <userID xsi:type="xsd:int">-1</userID>
      <phoneNumber xsi:type="xsd:string">null</phoneNumber>
      </namesp3:User>
      </namesp2:getUsersByUserFilter>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>



      ///////////////////////////////////////////////////////////////
      // Correct XML (Java client)
      <?xml version="1.0" encoding="UTF-8" ?>
      <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:ns0="http://www.attask.com/api"
      env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <env:Body>
      <ns0:getUsersByUserFilter>
      <String_1 xsi:type="xsd:string">92668751111027098129191</String_1>
      <User_2 href="#ID1" />
      </ns0:getUsersByUserFilter>
      <ns0:User id="ID1" xsi:type="ns0:User">
      <hasError xsi:type="xsd:boolean">false</hasError>
      <state xsi:type="xsd:string">UT</state>
      <zip xsi:type="xsd:string">null</zip>
      <primaryContact xsi:type="xsd:string">null</primaryContact>
      <city xsi:type="xsd:string">null</city>
      <username xsi:type="xsd:string">null</username>
      <emailAddr xsi:type="xsd:string">null</emailAddr>
      <groupID xsi:type="xsd:int">-1</groupID>
      <address xsi:type="xsd:string">null</address>
      <firstName xsi:type="xsd:string">null</firstName>
      <password xsi:type="xsd:string">null</password>
      <lastName xsi:type="xsd:string">null</lastName>
      <companyName xsi:type="xsd:string">null</companyName>
      <userID xsi:type="xsd:int">-1</userID>
      <phoneNumber xsi:type="xsd:string">null</phoneNumber>
      </ns0:User>
      </env:Body>
      </env:Envelope>
    • Duncan Cameron
      ... See this message on the list, and its follow-ups, which is a similar problem to yours: http://groups.yahoo.com/group/soaplite/message/1661 Regards, Duncan
      Message 2 of 3 , Jul 19, 2002
        On 2002-07-19 nate_bowler wrote:
        >Still stuck on this....
        >
        >The biggest problem I have is SOAP::Data->type() method ALWAYS messes
        >up. It references a namespace that isn't delared anywere in the
        >message. For example, if the method call inside the body declares
        >an "xmlns:namesp2" namespace, type() method will reference an
        >undeclared "namesp3" namespace.
        >
        >The following is the CLOSEST I have come to a successful call. Please
        >notice the bogus parameter element name, and the invalid namespace in
        >the xml.
        >
        >I have included my Perl code, the incorrect XML, and a XML message
        >that does work in hopes it may help.
        >
        >Can anybody offer a suggestion that would help me to generate the
        >proper XML from my Perl client? Any help would be appreciated.
        >
        See this message on the list, and its follow-ups, which is a similar problem
        to yours:

        http://groups.yahoo.com/group/soaplite/message/1661


        Regards,
        Duncan Cameron
      • nate_bowler
        I saw this thread earlier and tried its suggestions, but I didn t get it to work. This is my code incorporating the suggestions from that thread. 2 things are
        Message 3 of 3 , Jul 19, 2002
          I saw this thread earlier and tried its suggestions, but I didn't get
          it to work. This is my code incorporating the suggestions from that
          thread.

          2 things are wrong here:

          1. The xsi-type refers to tns:User, but tns is not defined in the
          message.

          2. The User sequence elements are all out of order if I use
          the "bless" convention.

          It is logical that both of these errors are related to the same issue
          of not recognizing the 'User' type, but I'm not sure how to remedy it.

          Also, please note that I am using the WSDL service to call this
          method.

          Nate

          ///////////////////////////////////////
          //Perl Code:
          #!perl -w
          #!d:\perl\bin\perl.exe

          use SOAP::Lite;
          my $api_server = SOAP::Lite
          -> soapversion(1.2)
          -> uri('http://www.attask.com/api')
          -> service('http://63.228.219.51:8080/attask/APIService.wsdl');

          $api_server->serializer->maptype->{User} = 'APIService';

          my $sessionID = $api_server->login("admin","testing");
          print "sessionID:$sessionID\n";

          # build the call parameters
          my $uf2 = bless { 'hasError' => SOAP::Data->type(boolean => 0),
          'state' => 'UT',
          'zip' => 'null',
          'primaryContact' => 'null',
          'city' => 'null',
          'username' => 'null',
          'emailAddr' => 'null',
          'groupID' => -1,
          'address' => 'null',
          'firstName' => 'null',
          'password' => 'null',
          'lastName' => 'null',
          'companyName' => 'null',
          'userID' => -1,
          'phoneNumber' => 'null'} => 'User';


          my $userlist = $api_server->getUsersByUserFilter($sessionID, $uf2);
          print "\nusername:" . $$userlist[0]->{'username'} . "\n";

          $api_server->logout($sessionID);


          /////////////////////////////////////////////////
          // XML output
          <?xml version="1.0" encoding="UTF-8" ?>
          <SOAP-ENV:Envelope xmlns:SOAP-
          ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-
          ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-
          ENV="http://schemas.xmlsoap.org/soap/envelope/"
          xmlns:xsd="http://www.w3.org/2001/XMLSchema">
          <SOAP-ENV:Body>
          <namesp2:getUsersByUserFilter
          xmlns:namesp2="http://www.attask.com/api">
          <String_1 xsi:type="xsd:string">92668751101027106348409</String_1>
          <User_2 xsi:type="tns:User">
          <lastName xsi:type="xsd:string">null</lastName>
          <state xsi:type="xsd:string">UT</state>
          <phoneNumber xsi:type="xsd:string">null</phoneNumber>
          <companyName xsi:type="xsd:string">null</companyName>
          <password xsi:type="xsd:string">null</password>
          <emailAddr xsi:type="xsd:string">null</emailAddr>
          <city xsi:type="xsd:string">null</city>
          <groupID xsi:type="xsd:int">-1</groupID>
          <firstName xsi:type="xsd:string">null</firstName>
          <primaryContact xsi:type="xsd:string">null</primaryContact>
          <address xsi:type="xsd:string">null</address>
          <hasError xsi:type="xsd:boolean">false</hasError>
          <zip xsi:type="xsd:string">null</zip>
          <username xsi:type="xsd:string">null</username>
          <userID xsi:type="xsd:int">-1</userID>
          </User_2>
          </namesp2:getUsersByUserFilter>
          </SOAP-ENV:Body>
          </SOAP-ENV:Envelope>





          --- In soaplite@y..., Duncan Cameron <dcameron@b...> wrote:
          > On 2002-07-19 nate_bowler wrote:
          > >Still stuck on this....
          > >
          > >The biggest problem I have is SOAP::Data->type() method ALWAYS
          messes
          > >up. It references a namespace that isn't delared anywere in the
          > >message. For example, if the method call inside the body declares
          > >an "xmlns:namesp2" namespace, type() method will reference an
          > >undeclared "namesp3" namespace.
          > >
          > >The following is the CLOSEST I have come to a successful call.
          Please
          > >notice the bogus parameter element name, and the invalid namespace
          in
          > >the xml.
          > >
          > >I have included my Perl code, the incorrect XML, and a XML message
          > >that does work in hopes it may help.
          > >
          > >Can anybody offer a suggestion that would help me to generate the
          > >proper XML from my Perl client? Any help would be appreciated.
          > >
          > See this message on the list, and its follow-ups, which is a
          similar problem
          > to yours:
          >
          > http://groups.yahoo.com/group/soaplite/message/1661
          >
          >
          > Regards,
          > Duncan Cameron
        Your message has been successfully submitted and would be delivered to recipients shortly.