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

Re: xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" generates duplications

Expand Messages
  • Graham Irvine
    ... The only way so far i have found to do this is to create my own serializer namespaces like this .
    Message 1 of 6 , Apr 13 8:08 PM
    • 0 Attachment
      --- In soaplite@yahoogroups.com, Cristina Aurrecoechea <aurreco@y...>
      wrote:
      > I have a SOAP::Lite (0.65beta2.1) client using a
      > simple Axis (1.2RC2) service. The service has only one
      > method (getNameList()) and returns an array of 4
      > strings.
      >
      > WHen executing the client, the SOAP response received
      > has a duplicated attribute in the SOAP body generated
      > by Axis in the <getNameListReturn ... >
      > xsi:type="soapenc:Array" xsi:type="soapenc:Array"
      >
      > As a result the parser in client side complains.
      >
      > By using tcpmon I see that at the client side
      > SOAP::Lite generates a SOAP request using in the
      > envelope:
      > xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      > IF I change the XMLSchema above to 2001, the response
      > turns out correct!, with no duplications.
      >
      > My questions are:
      >
      > - can I tell SOAP::Lite to use the 2001 schema instead
      > of the 1999, how?

      The only way so far i have found to do this is to create my own
      serializer namespaces like this .

      $soap->serializer->namespaces({"http://schemas.xmlsoap.org/soap/encoding/"=>"SOAP-ENC",

      "http://schemas.xmlsoap.org/soap/envelope/"=>"SOAP-INV",
      "http://www.w3.org/2001/XMLSchema"=>"xsd",

      "http://www.w3.org/2001/XMLSchema-instance"=>"xsi"});

      However ..

      Your post has just blown my theory that these two xsi's were
      interchangeable :(

      If it will work for you I guess use it. But now i am more than ever
      wanting to know what these namespace attributes affect.


      > - is this because my client is using SOAP1.1 instead
      > of SOAP1.2, and if so how do I tell it to use SOAP1.2?


      I've tried setting this also without any joy using variants of

      $soap->serializer->soapversion(1.2);
      and
      $SOAP::Constant::SOAP_VERSION = 1.2;


      > - is this an interoperability problem between
      > SOAP::Lite and Axis?
      >
      > - SHould I download the latest SOAP::Lite
      > (0.65-beta4)?

      It doesnt change the handling of SOAP::Constants as far as I can see
      over your current version , or the namespace handling but as you are
      running beta anyway I guess you should.

      > Thanks
      > Cristina
    • Byrne Reese
      ... It should be defaulting to 2001 now. Weird that it is not. ... Yes. $soap- soapversion(1.2); ... Only when using attachments, but there is a fix. ... Yes.
      Message 2 of 6 , Apr 14 8:07 AM
      • 0 Attachment
        Cristina Aurrecoechea wrote:

        > - can I tell SOAP::Lite to use the 2001 schema instead
        > of the 1999, how?

        It should be defaulting to 2001 now. Weird that it is not.

        >
        > - is this because my client is using SOAP1.1 instead
        > of SOAP1.2, and if so how do I tell it to use SOAP1.2?

        Yes. $soap->soapversion(1.2);

        >
        > - is this an interoperability problem between
        > SOAP::Lite and Axis?

        Only when using attachments, but there is a fix.

        >
        > - SHould I download the latest SOAP::Lite
        > (0.65-beta4)?


        Yes.

        >
        > Thanks
        > Cristina
        >
        >
        > ------------------------------------------------------------------------
        > *Yahoo! Groups Links*
        >
        > * To visit your group on the web, go to:
        > http://groups.yahoo.com/group/soaplite/
        >
        > * To unsubscribe from this group, send an email to:
        > soaplite-unsubscribe@yahoogroups.com
        > <mailto:soaplite-unsubscribe@yahoogroups.com?subject=Unsubscribe>
        >
        > * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
        > Service <http://docs.yahoo.com/info/terms/>.
        >
        >
      • Cristina Aurrecoechea
        Thanks for the replies. Graham solution works, and I get a good SOAP response. Byrne, changing the SOAP version does not work. Now I have a different problem.
        Message 3 of 6 , Apr 14 12:35 PM
        • 0 Attachment
          Thanks for the replies.
          Graham solution works, and I get a good SOAP response.

          Byrne, changing the SOAP version does not work.

          Now I have a different problem. Any pointers are
          appreciated.

          As I said when I execute:
          $result = $soap->getNameList();
          I get a perfect SOAP response with the four strings in
          the array:
          .........<getNameListReturn
          soapenc:arrayType="soapenc:string[4]"
          xsi:type="soapenc:Array"
          xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"><item
          xsi:type="soapenc:string">Melon</item>.........

          But when I want to print $result; I get an unblessed
          reference ARRAY(0x85780a4)

          If I use an array
          @result=$soap->getNameList();
          print @result;
          I get the number 1 (?).

          I am new to Perl. Thanks in advance.
          Cristina






          --- Graham Irvine <graham@...> wrote:
          >
          > --- In soaplite@yahoogroups.com, Cristina
          > Aurrecoechea <aurreco@y...>
          > wrote:
          > > I have a SOAP::Lite (0.65beta2.1) client using a
          > > simple Axis (1.2RC2) service. The service has only
          > one
          > > method (getNameList()) and returns an array of 4
          > > strings.
          > >
          > > WHen executing the client, the SOAP response
          > received
          > > has a duplicated attribute in the SOAP body
          > generated
          > > by Axis in the <getNameListReturn ... >
          > > xsi:type="soapenc:Array"
          > xsi:type="soapenc:Array"
          > >
          > > As a result the parser in client side complains.
          > >
          > > By using tcpmon I see that at the client side
          > > SOAP::Lite generates a SOAP request using in the
          > > envelope:
          > >
          >
          xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
          > > IF I change the XMLSchema above to 2001, the
          > response
          > > turns out correct!, with no duplications.
          > >
          > > My questions are:
          > >
          > > - can I tell SOAP::Lite to use the 2001 schema
          > instead
          > > of the 1999, how?
          >
          > The only way so far i have found to do this is to
          > create my own
          > serializer namespaces like this .
          >
          >
          $soap->serializer->namespaces({"http://schemas.xmlsoap.org/soap/encoding/"=>"SOAP-ENC",
          >
          >
          "http://schemas.xmlsoap.org/soap/envelope/"=>"SOAP-INV",
          >
          > "http://www.w3.org/2001/XMLSchema"=>"xsd",
          >
          >
          "http://www.w3.org/2001/XMLSchema-instance"=>"xsi"});
          >
          > However ..
          >
          > Your post has just blown my theory that these two
          > xsi's were
          > interchangeable :(
          >
          > If it will work for you I guess use it. But now i am
          > more than ever
          > wanting to know what these namespace attributes
          > affect.
          >
          >
          > > - is this because my client is using SOAP1.1
          > instead
          > > of SOAP1.2, and if so how do I tell it to use
          > SOAP1.2?
          >
          >
          > I've tried setting this also without any joy using
          > variants of
          >
          > $soap->serializer->soapversion(1.2);
          > and
          > $SOAP::Constant::SOAP_VERSION = 1.2;
          >
          >
          > > - is this an interoperability problem between
          > > SOAP::Lite and Axis?
          > >
          > > - SHould I download the latest SOAP::Lite
          > > (0.65-beta4)?
          >
          > It doesnt change the handling of SOAP::Constants as
          > far as I can see
          > over your current version , or the namespace
          > handling but as you are
          > running beta anyway I guess you should.
          >
          > > Thanks
          > > Cristina
          >
          >
          >
          >
        • Graham Irvine
          ... Im not a perl monk so someone might correct me here . But the reason for this is that the $soap call returns a scalar reference to the array .. so it
          Message 4 of 6 , Apr 15 3:24 AM
          • 0 Attachment
            --- In soaplite@yahoogroups.com, Cristina Aurrecoechea <aurreco@y...>
            wrote:
            > Thanks for the replies.
            > Graham solution works, and I get a good SOAP response.
            >
            > Byrne, changing the SOAP version does not work.
            >
            > Now I have a different problem. Any pointers are
            > appreciated.
            >
            > As I said when I execute:
            > $result = $soap->getNameList();
            > I get a perfect SOAP response with the four strings in
            > the array:
            > .........<getNameListReturn
            > soapenc:arrayType="soapenc:string[4]"
            > xsi:type="soapenc:Array"
            > xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"><item
            > xsi:type="soapenc:string">Melon</item>.........
            >
            > But when I want to print $result; I get an unblessed
            > reference ARRAY(0x85780a4)
            >
            > If I use an array
            > @result=$soap->getNameList();
            > print @result;
            > I get the number 1 (?).
            >

            Im not a "perl monk" so someone might correct me here . But the reason
            for this is that the $soap call returns a scalar reference to the
            array .. so it returns 1 when you try to print it as above.

            what you need to do depends on the data coming back . I suggest
            turning tracing on to help you here whilst you get it working.

            so use SOAP::Lite +trace => all;

            then after

            $result = $soap->getNamelist();

            you should do something like this

            while (@$result) {
            $item = shift @$result;
            print "$item\n";
            }

            NB: If $item is a hash print "$item->{elementname}\n";

            If the $result is nested which in the case of an arraytype i think it
            might be , you can get down to the actual array of returned values
            using a variant of this to get to the top xml element you want.

            The trace output of the response will be invaluable here to determine
            what you need to do.

            $returns = $result->valueof('//GetNameListResponse/return');
            while (@$returns){
            $item = shift @$result;
            print "$item\n";
            }

            Regards
            Graham
          • Cristina Aurrecoechea
            THANKS! this is clearly my not understanding Perl. I was already using trace but I could not figure out how to extract the array from the unblessed reference.
            Message 5 of 6 , Apr 15 9:05 AM
            • 0 Attachment
              THANKS!

              this is clearly my not understanding Perl.
              I was already using trace but I could not figure out
              how to extract the array from the unblessed reference.

              Your solution works beautifully!!!

              >
              > $result = $soap->getNamelist();
              >
              > you should do something like this
              >
              > while (@$result) {
              > $item = shift @$result;
              > print "$item\n";
              > }
              >
            Your message has been successfully submitted and would be delivered to recipients shortly.