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

Re: WSDL and arrays

Expand Messages
  • 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 1 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.