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

Re: [soaplite] Returned objects & compression

Expand Messages
  • Paul Kulchenko
    Hi, Jean-Jack! ... Very strange. You re the first who reports about such problem and my tests don t show anything like this. Do you have a public server that I
    Message 1 of 7 , Sep 18, 2001
    • 0 Attachment
      Hi, Jean-Jack!

      > compression on -> I get back a proper SOM object (so ->result()
      > works)
      > compression off -> just a string (no object)
      Very strange. You're the first who reports about such problem and my
      tests don't show anything like this. Do you have a public server that
      I can hit to test? I can do it with my server, but everything seems
      to be ok.

      > Is this correct behaviour for the compression code?
      No, it's not. That's for sure ;)

      > On a side-line, is there a way to enable compression in the client
      > when
      > using a wsdl file? I fiddled around with -> options either on a
      It's a little bit tricky.

      $s = SOAP::Lite->service('http://www.ebi.ac.uk/xembl/XEMBL.wsdl');
      $s->proxy('http://fake/')
      ->transport
      ->options({compress_threshold => 100});

      --OR for one specific option--
      $s->proxy('http://fake/')
      ->transport
      ->options
      ->{compress_threshold} = 100;

      --OR short version--
      $s->proxy('http://fake/', options => {compress_threshold => 100});

      You can always use transport() method to get an access to low-level
      transport settings, but the feature is that transport object is not
      exist yet (it will be created during the first call, because
      transport depends on used URL), so you need to create it first using
      fake URL (only protocol part is important).

      proxy() creates transport object, transport() returns this object and
      you can call any methods you want. You can get/set options, timeout,
      cookies or anything else. You need to use proxy() call ONLY if you
      want to specify something before the first call. After that transport
      object already exists and can be used. Let me know if it doesn't work
      for you for any reason.

      Best wishes, Paul.

      --- "Jean-Jack M. Riethoven" <pow@...> wrote:
      >
      > Greetings!
      >
      > Just as you thought you got rid of me, here I am again :)
      >
      > > my $idlist = SOAP::Data->name(idslist => [
      > > map {SOAP::Data->name(item => $_)->type('string')} @IDLIST
      > > ]);
      >
      > Thank you for the explanation on the array passing - it makes it
      > quite a
      > bit clearer for me now. At the moment I have chosen to use a space
      > delimited string of ID's to represent an array - just because I
      > want to
      > keep the client kiss for the users. Luckily ID's are alphanumeric
      > only, so
      > this representation works great.
      >
      > My question is on another topic though:
      >
      > The result from my SOAP server always comes back as a normal string
      > - I
      > noticed in the examples you query them on faultcode or use
      > $result->result() to print the result. If I try to do that I get
      > the
      > 'cannot call methood 'result'..' error.
      >
      > I thought it was just me, but fiddling around with the compression
      > code I
      > noticed this:
      >
      > compression on -> I get back a proper SOM object (so ->result()
      > works)
      > compression off -> just a string (no object)
      >
      > My server just does a return $result (where $result is a normal
      > string),
      > nothing fancy.
      >
      > Is this correct behaviour for the compression code?
      >
      > On a side-line, is there a way to enable compression in the client
      > when
      > using a wsdl file? I fiddled around with -> options either on a
      > separate
      > line, or withing the ->service() method but they don't work. As far
      > as I
      > see compression can only be enabled client-side if using ->uri and
      > ->proxy
      > (.., options =>{..}).
      > Is that correct or am I overlooking something?
      >
      > Thank you in advance!
      >
      >
      > P.S. homepage for this project is at http://www.ebi.ac.uk/xembl/ -
      > there is
      > a link to a sample perl client there as well as the wsdl file)
      >
      > With kind regards,
      >
      > --
      > drs. Jean-Jack M. Riethoven
      >
      > EMBL Outstation - Hinxton pow@... ICQ#: 3433929
      > European Bioinformatics Institute Phone: (+44) 1223 494635
      > Wellcome Trust Genome Campus Fax : (+44) 1223 494468
      > Hinxton, Cambridge CB10 1SD URL :
      > http://industry.ebi.ac.uk/
      > UNITED KINGDOM
      >
      > Need to find bioinformatics or molecular biology web sites or
      > resources?
      > Use BioWurld at http://www.ebi.ac.uk/biowurld
      >
      >
      > 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/
      >
      >


      __________________________________________________
      Terrorist Attacks on U.S. - How can you help?
      Donate cash, emergency relief information
      http://dailynews.yahoo.com/fc/US/Emergency_Information/
    • Jean-Jack M. Riethoven
      Greetings, I have read the discussion on passing XML in strings with great interest. We are doing the same with our server, sending a blob of XML over the
      Message 2 of 7 , Sep 20, 2001
      • 0 Attachment
        Greetings,

        I have read the discussion on passing XML in strings with great interest.
        We are doing the same with our server, sending a blob of XML over the wire.

        This would all work perfectly if everyone has XML::Parser. When falling
        back on XML::Parser::Lite the %lt; are obviously not encoded back properly
        yet (see docs).

        I have been looking at the other methods that were suggested:

        1. return SOAP::Data->type(xml => $xmlblob)

        2. the use of <![CDATA[..]]>

        When trying to do 1. (my preferred method), I get warnings from the parser:

        xml processing instruction not at start of external entity at line 1,
        column 426, byte 426 at
        /sw/common/share/perl/site-perl/5.00503/alpha-osf1/XML/Parser.pm line 185

        Bascially, my $xmlblob is a fully valid and well-formed piece of xml,
        including the <?xml ?> start. Removing the first line warns about another
        processing instruction <?format DECIMAL=".">, removing that one warns about
        the <!DOCTYPE..> stuff.
        The Doctype stuff is required for the validation at the other side.


        The instructions on 2 were not completely clear to me, but I tried several
        forms at the server side:

        return "<![CDATA[" . $xmlblob . "]]>"
        return SOAP::Data->type(xml => ("<![CDATA[" . $xmlblob . "]]>")) (or with
        string as type)

        etc.. These didn't seem to work as well (still < and <![CDATA tags still
        in output.


        I am hoping to do everything server-side so I don't have to do anything
        manual at the client side - does anyone have a cookbook example how to use
        an xml blob (including PI's) without the need for decoding (in the event of
        absence of the XML::Parser module) ?

        With kind regards,

        --
        drs. Jean-Jack M. Riethoven

        EMBL Outstation - Hinxton pow@... ICQ#: 3433929
        European Bioinformatics Institute Phone: (+44) 1223 494635
        Wellcome Trust Genome Campus Fax : (+44) 1223 494468
        Hinxton, Cambridge CB10 1SD URL : http://industry.ebi.ac.uk/
        UNITED KINGDOM

        Need to find bioinformatics or molecular biology web sites or resources?
        Use BioWurld at http://www.ebi.ac.uk/biowurld
      • Paul Kulchenko
        Hi, Jean-Jack! ... You can always do base64 encoding, which will work with or without XML::Parser: return SOAP::Data- type(base64 = my XML fragment here );
        Message 3 of 7 , Sep 20, 2001
        • 0 Attachment
          Hi, Jean-Jack!

          > I am hoping to do everything server-side so I don't have to do
          > anything
          > manual at the client side - does anyone have a cookbook example how
          > to use
          > an xml blob (including PI's) without the need for decoding (in the
          > event of absence of the XML::Parser module) ?
          You can always do base64 encoding, which will work with or without
          XML::Parser:

          return SOAP::Data->type(base64 => 'my XML fragment here');

          To use XML::Parser::Lite you can also override as_string method and
          provide your own decoding inside it. In this case your application
          will stay clean and you can do it only when XML::Parser is not
          available. Let me know if you need more info on how to do that.

          Best wishes, Paul.

          --- "Jean-Jack M. Riethoven" <pow@...> wrote:
          >
          > Greetings,
          >
          > I have read the discussion on passing XML in strings with great
          > interest.
          > We are doing the same with our server, sending a blob of XML over
          > the wire.
          >
          > This would all work perfectly if everyone has XML::Parser. When
          > falling
          > back on XML::Parser::Lite the %lt; are obviously not encoded back
          > properly
          > yet (see docs).
          >
          > I have been looking at the other methods that were suggested:
          >
          > 1. return SOAP::Data->type(xml => $xmlblob)
          >
          > 2. the use of <![CDATA[..]]>
          >
          > When trying to do 1. (my preferred method), I get warnings from the
          > parser:
          >
          > xml processing instruction not at start of external entity at line
          > 1,
          > column 426, byte 426 at
          > /sw/common/share/perl/site-perl/5.00503/alpha-osf1/XML/Parser.pm
          > line 185
          >
          > Bascially, my $xmlblob is a fully valid and well-formed piece of
          > xml,
          > including the <?xml ?> start. Removing the first line warns about
          > another
          > processing instruction <?format DECIMAL=".">, removing that one
          > warns about
          > the <!DOCTYPE..> stuff.
          > The Doctype stuff is required for the validation at the other side.
          >
          >
          > The instructions on 2 were not completely clear to me, but I tried
          > several
          > forms at the server side:
          >
          > return "<![CDATA[" . $xmlblob . "]]>"
          > return SOAP::Data->type(xml => ("<![CDATA[" . $xmlblob . "]]>"))
          > (or with
          > string as type)
          >
          > etc.. These didn't seem to work as well (still < and <![CDATA
          > tags still
          > in output.
          >
          >
          > I am hoping to do everything server-side so I don't have to do
          > anything
          > manual at the client side - does anyone have a cookbook example how
          > to use
          > an xml blob (including PI's) without the need for decoding (in the
          > event of
          > absence of the XML::Parser module) ?
          >
          > With kind regards,
          >
          > --
          > drs. Jean-Jack M. Riethoven
          >
          > EMBL Outstation - Hinxton pow@... ICQ#: 3433929
          > European Bioinformatics Institute Phone: (+44) 1223 494635
          > Wellcome Trust Genome Campus Fax : (+44) 1223 494468
          > Hinxton, Cambridge CB10 1SD URL :
          > http://industry.ebi.ac.uk/
          > UNITED KINGDOM
          >
          > Need to find bioinformatics or molecular biology web sites or
          > resources?
          > Use BioWurld at http://www.ebi.ac.uk/biowurld
          >
          >
          >
          >
          > 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/
          >
          >


          __________________________________________________
          Terrorist Attacks on U.S. - How can you help?
          Donate cash, emergency relief information
          http://dailynews.yahoo.com/fc/US/Emergency_Information/
        • John T. Brown
          I m also having a problem passing an array from a Perl client using SOAP::Lite to a java server implemented with Glue1.2. I made the changes suggested to the
          Message 4 of 7 , Nov 15, 2001
          • 0 Attachment
            I'm also having a problem passing an array from a Perl client using
            SOAP::Lite to a java server implemented with Glue1.2. I made the changes

            suggested to the Perl client and I now get NoSuchMethodException.
            The wsdl is being generated by Glue for the Java server. It appears to
            be a problem with the soapenc parameter but I'm not very familiar
            with perl and I'm not sure how to correct it.

            Below I've included the beginning of the wsdl file generated by GLUE
            plus the method signature, the XML generated from a Java client for the
            same method, the perl client, and the results for the perl client.

            I would appreciate any input.

            Thanks,

            John Brown



            --------------------------------------------------
            Beginning of the wsdl file generated by GLUE, plus method signature

            <?xml version="1.0" encoding="UTF-8" ?>
            - <!-- generated by GLUE
            -->
            - <definitions name="MiningEntryService"
            targetNamespace="http://www.themindelectric.com/wsdl/MiningEntryService/"

            xmlns:tns="http://www.themindelectric.com/wsdl/MiningEntryService/"
            xmlns:electric="http://www.themindelectric.com/"
            xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
            xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
            xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
            xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
            xmlns="http://schemas.xmlsoap.org/wsdl/">
            - <types>
            - <schema xmlns="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://www.themindelectric.com/collections/"
            targetNamespace="http://www.themindelectric.com/collections/">
            - <complexType name="hashmap">
            - <sequence>
            - <element name="item" minOccurs="0" maxOccurs="unbounded">
            - <complexType>
            - <sequence>
            <element name="key" type="anyType" />
            <element name="value" type="anyType" />
            </sequence>
            </complexType>
            </element>
            </sequence>
            </complexType>
            - <complexType name="arraylist">
            - <sequence>
            <element name="item" minOccurs="0" maxOccurs="unbounded"
            type="anyType" />
            </sequence>
            </complexType>
            ...
            - <message name="getCurrentMProteinAccession32SoapIn">
            <part name="userCertificate" type="xsd:base64Binary" />
            <part name="anAccessionNumberList"
            xmlns:ns1="http://www.themindelectric.com/collections/"
            type="ns1:arraylist" />
            </message>
            - <message name="getCurrentMProteinAccession32SoapOut">
            <part name="Result"
            xmlns:ns1="http://www.themindelectric.com/collections/"
            type="ns1:hashmap" />
            </message>
            ...

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

            The XML generated for a Java client executing the same method (this
            works).

            <?xml version="1.0" encoding="UTF-8" ?>
            - <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
            xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
            soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
            - <soap:Body>
            - <n:getCurrentMProteinAccession
            xmlns:n="http://tempuri.org/com.mpi.tdd.tdapi.api.MiningEntryService">
            <userCertificate href="#id0" />
            <anAccessionNumberList href="#id1" />
            </n:getCurrentMProteinAccession>
            <id0 id="id0" soapenc:root="0"
            xsi:type="xsd:base64Binary">6s/i5y/37smr9+Xv32g=</id0>
            - <id1 id="id1" soapenc:root="0"
            xmlns:ns2="http://www.themindelectric.com/collections/"
            xsi:type="ns2:arraylist">
            <item xsi:type="xsd:string">MP1255147</item>
            <item xsi:type="xsd:string">14273</item>
            </id1>
            </soap:Body>
            </soap:Envelope>

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

            Perl Client
            ===========

            #!/mpi/usr/bin/perl5.6.0

            use strict;

            use lib "/prod/infra/lib/perl5";

            use SOAP::Lite;
            use Data::Dumper;
            use MIME::Base64;

            my ($user, $passwd) = ("userid", "passwd");
            my $cert = certificate($user, $passwd);
            $cert = encode_base64($cert);

            # set the certificate datatype to base64Binary.
            my $cert_data = SOAP::Data->type('base64Binary' => $cert);

            # Specify the input accession number for the message.
            my @accessions = qw(MP1255147 14273);
            my $accessionList = SOAP::Data->name(arraylist => [
            map {SOAP::Data->name(item => $_)->type('string')} @accessions
            ]);

            # Specify the URL for the tdapi web server.
            my $proxy = SOAP::Lite->uri('')
            -> proxy('http://elbonia.mpi.com:8084/MES/urn:MiningEntryService')
            -> on_debug(sub{print@_});

            # Send the message
            my $result = $proxy -> getCurrentMProteinAccession($cert_data,
            $accessionList);

            if ($result->fault) {
            die "ERROR: ", join (", ", $result->faultcode, $result->faultstring);
            }
            else {
            print Dumper($result->result),"\n";
            }

            sub certificate
            {
            my ($user, $passwd) = @_;
            my $str = "$user:$passwd";
            $str =~ tr/\x00-\x7f\x80-\xff/\x80-\xff\x00-\x7f/;
            return $str;
            }


            Results
            =======

            $ getCurrentMProteinAccessionList.pl
            POST http://elbonia.mpi.com:8084/MES/urn:MiningEntryService
            Accept: text/xml
            Accept: multipart/*
            Content-Length: 700
            Content-Type: text/xml; charset=utf-8
            SOAPAction: "#getCurrentMProteinAccession"

            <?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/1999/XMLSchema-instance"
            xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
            xmlns:xsd="http://www.w3.org/1999/XMLSchema"><SOAP-ENV:Body><getCurrentMProteinAccession

            xmlns=""><c-gensym5 xsi:type="xsd:base64Binary">8asj5+659+Xc4+/t4tI=
            </c-gensym5><arraylist SOAP-ENC:arrayType="xsd:string[2]"
            xsi:type="SOAP-ENC:Array"><item
            xsi:type="xsd:string">MP1255147</item><item

            xsi:type="xsd:string">14273</item></arraylist></getCurrentMProteinAccession></SOAP-ENV:Body></SOAP-ENV:Envelope>

            HTTP/1.1 500 (Internal Server Error) Server Error
            Connection: close
            Date: Mon, 12 Nov 2001 20:09:35 GMT
            Server: Netscape-Enterprise/4.1
            Content-Length: 1182
            Content-Type: text/xml; charset=UTF-8
            Client-Date: Mon, 12 Nov 2001 20:04:57 GMT

            <?xml version='1.0' encoding='UTF-8'?>
            <soap:Envelope xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
            xmlns:xsd='http://www.w3.org/1999/XMLSchema'
            xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'
            xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
            soap:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/
            '><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>getCurrentMProteinAccession</faultstring><detail><stacktrace>java.lang.NoSuchMethodException:

            getCurrentMProteinAccession
            at electric.net.soap.SOAPBinding.getOperation(Unknown Source)
            at electric.net.soap.SOAP.invoke(Unknown Source)
            at electric.net.soap.SOAP.invoke(Unknown Source)
            at electric.net.soap.http.SOAPHandler.service(Unknown Source)
            at electric.server.http.ServletServer.service(Unknown Source)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java, Compiled
            Code)
            at
            com.netscape.server.http.servlet.NSServletRunner.Service(NSServletRunner.java,

            Compiled Code)
            </stacktrace></detail><electric:exception
            xmlns:electric='http://www.themindelectric.com/
            '><name>java.lang.NoSuchMethodException</name></electric:exception></soap:Fault></soap:Body></soap:Envelope>



            --- In soaplite@y..., Paul Kulchenko <paulclinger@y...> wrote:
            > Hi, Jean-Jack!
            >
            > > To make to service more fucntional, I need to pass an array of
            > > strings to
            > > the SOAP server. I have to following call in the client:
            > >
            > > my $soap = SOAP::Lite
            > > -> service('http://www.ebi.ac.uk/xembl/XEMBL.wsdl');
            > >
            > > $result = $soap->FullSequence($FORMAT, @IDLIST);
            > first of all, in most cases you need to pass an array reference
            > instead of list:
            >
            > [@IDLIST] or \@IDLIST instead of @IDLIST
            >
            > It won't help in this particular case though, because support for
            > complex types is limited in SOAP::Lite.
            >
            > You can however supply your own representation using SOAP::Data
            > interface and it'll override settings in WSDL.
            >
            > To make it work, use simple type definition, and then do something
            > like this (untested):
            >
            > my $soap = SOAP::Lite
            > -> service('http://www.ebi.ac.uk/xembl/XEMBL.wsdl');
            >
            > my $idlist = SOAP::Data->name(idslist => [
            > map {SOAP::Data->name(item => $_)->type('string')} @IDLIST
            > ]);
            >
            > $result = $soap->FullSequence($FORMAT, $idlist);
            >
            > Future version will definitely have better support for complex

            types.
            > Let me know if you still have any problems.
            >
            > Best wishes, Paul.
          Your message has been successfully submitted and would be delivered to recipients shortly.