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

SOAP Lite Client with Apache SOAP Server

Expand Messages
  • ft@sbs.co.at
    Hi. I tried to access a webservice developed with the Apache SOAP Libraries with SOAPLite. I always get an error with the Apache Serializer. So I compared the
    Message 1 of 3 , May 28, 2002
    • 0 Attachment
      Hi.
      I tried to access a webservice developed with the Apache SOAP Libraries
      with SOAPLite. I always get an error with the Apache Serializer. So I
      compared the SOAP-Message sent by an Apache SOAP Client in Java and by a
      small SOAPLite-Script. The Server should replay a complex type.
      I can see no real difference, except the
      encoding-style is included with the methodname in the Apache SOAP Client
      (and of course, the java-version is working ...). Has anybody had the same
      problem or some good advice ?
      Thanks in advance,
      Treml Florian

      The request as sent by the Apache SOAP Client:

      <?xml version='1.0' encoding='UTF-8'?>
      <SOAP-ENV:Envelope
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <SOAP-ENV:Body>
      <ns1:getAccountDetails xmlns:ns1="urn:ejb.User" SOAP-ENV:encodingStyle="
      http://schemas.xmlsoap.org/soap/encoding/">
      <clientID xsi:type="xsd:string">client2</clientID>
      <accountID xsi:type="xsd:int">0</accountID>
      </ns1:getAccountDetails>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>

      The request as sent by the SOAPLite-client:

      <?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:SOAP-ENV="
      http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="
      http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="
      http://www.w3.org/1999/XMLSchema"><SOAP-ENV:Body><namesp1:getAccountDetails
      xmlns:namesp1="urn:ejb.User"><clientID xsi:type
      ="xsd:string">client2</clientID><accountID xsi:type
      ="xsd:int">0</accountID></namesp1:getAccountDetails></SOAP-ENV:Body></SOAP-ENV:Envelope>


      The Fault-Response:

      <?xml version='1.0' encoding='UTF-8'?>
      <SOAP-ENV:Envelope xmlns:SOAP-ENV="
      http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="
      http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="
      http://www.w3.org/2001/XMLSchema">
      <SOAP-ENV:Body>
      <SOAP-ENV:Fault>
      <faultcode>SOAP-ENV:Server</faultcode>
      <faultstring>java.lang.IllegalArgumentException: No Serializer found to
      serialize a 'org.apache.soap.rpc.Parameter' using encoding style
      'null'.</faultstring>
      <faultactor>/kixfswebservices/servlet/rpcrouter</faultactor>
      </SOAP-ENV:Fault>

      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>


      The Perl-Script:

      use SOAP::Lite;

      my $user_ws = SOAP::Lite
      -> uri('urn:ejb.User')
      -> proxy('http://localhost:8081/kixfswebservices/servlet/rpcrouter');

      my $arg1 = SOAP::Data->type(string => 'client2')->name('clientID');
      my $arg2 = SOAP::Data->type(int => 0)->name('accountID');

      my $result = $user_ws -> getAccountDetails($arg1, $arg2) -> result;

      print $result;
    • Paul Kulchenko
      Hi, ft! I don t see any reason why this request should fail either. The only reason that comes to my mind is an error in one of Java XML Parsers that didn t
      Message 2 of 3 , May 28, 2002
      • 0 Attachment
        Hi, ft!

        I don't see any reason why this request should fail either.

        The only reason that comes to my mind is an error in one of Java XML
        Parsers that didn't undertstand prefixed attribute if namespace for
        that attribute was declared on the same element, but later:

        > <SOAP-ENV:Envelope xmlns:SOAP-ENC="
        > http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="
        > http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="
        > http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="
        > http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="
        > http://www.w3.org/1999/XMLSchema">

        SOAP-ENV:encodingStyle is used before SOAP-ENV prefix is declared.
        It's perfectly valid XML, but that parser had problems with it. It
        was later fixed.

        you may try to include encodingStyle attribute with the method
        element and see whether it helps:

        my $method = SOAP::Data
        ->name('getAccountDetails')
        ->encodingStyle('http://schemas.xmlsoap.org/soap/encoding/');
        my $result = $user_ws -> call($method, $arg1, $arg2) -> result;

        --OR--

        you may try to specify XML Schema 2001:

        my $user_ws = SOAP::Lite
        -> uri('urn:ejb.User')
        ->
        proxy('http://localhost:8081/kixfswebservices/servlet/rpcrouter')
        -> xmlschema('http://www.w3.org/2001/XMLSchema')
        ;

        Let me know whether it works for you.

        Best wishes, Paul.

        --- ft@... wrote:
        > Hi.
        > I tried to access a webservice developed with the Apache SOAP
        > Libraries
        > with SOAPLite. I always get an error with the Apache Serializer. So
        > I
        > compared the SOAP-Message sent by an Apache SOAP Client in Java and
        > by a
        > small SOAPLite-Script. The Server should replay a complex type.
        > I can see no real difference, except the
        > encoding-style is included with the methodname in the Apache SOAP
        > Client
        > (and of course, the java-version is working ...). Has anybody had
        > the same
        > problem or some good advice ?
        > Thanks in advance,
        > Treml Florian
        >
        > The request as sent by the Apache SOAP Client:
        >
        > <?xml version='1.0' encoding='UTF-8'?>
        > <SOAP-ENV:Envelope
        > xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
        > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        > xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        > <SOAP-ENV:Body>
        > <ns1:getAccountDetails xmlns:ns1="urn:ejb.User"
        > SOAP-ENV:encodingStyle="
        > http://schemas.xmlsoap.org/soap/encoding/">
        > <clientID xsi:type="xsd:string">client2</clientID>
        > <accountID xsi:type="xsd:int">0</accountID>
        > </ns1:getAccountDetails>
        > </SOAP-ENV:Body>
        > </SOAP-ENV:Envelope>
        >
        > The request as sent by the SOAPLite-client:
        >
        > <?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:SOAP-ENV="
        > http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="
        > http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="
        >
        http://www.w3.org/1999/XMLSchema"><SOAP-ENV:Body><namesp1:getAccountDetails
        > xmlns:namesp1="urn:ejb.User"><clientID xsi:type
        > ="xsd:string">client2</clientID><accountID xsi:type
        >
        ="xsd:int">0</accountID></namesp1:getAccountDetails></SOAP-ENV:Body></SOAP-ENV:Envelope>
        >
        >
        > The Fault-Response:
        >
        > <?xml version='1.0' encoding='UTF-8'?>
        > <SOAP-ENV:Envelope xmlns:SOAP-ENV="
        > http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="
        > http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="
        > http://www.w3.org/2001/XMLSchema">
        > <SOAP-ENV:Body>
        > <SOAP-ENV:Fault>
        > <faultcode>SOAP-ENV:Server</faultcode>
        > <faultstring>java.lang.IllegalArgumentException: No Serializer
        > found to
        > serialize a 'org.apache.soap.rpc.Parameter' using encoding style
        > 'null'.</faultstring>
        > <faultactor>/kixfswebservices/servlet/rpcrouter</faultactor>
        > </SOAP-ENV:Fault>
        >
        > </SOAP-ENV:Body>
        > </SOAP-ENV:Envelope>
        >
        >
        > The Perl-Script:
        >
        > use SOAP::Lite;
        >
        > my $user_ws = SOAP::Lite
        > -> uri('urn:ejb.User')
        > ->
        > proxy('http://localhost:8081/kixfswebservices/servlet/rpcrouter');
        >
        > my $arg1 = SOAP::Data->type(string => 'client2')->name('clientID');
        > my $arg2 = SOAP::Data->type(int => 0)->name('accountID');
        >
        > my $result = $user_ws -> getAccountDetails($arg1, $arg2) -> result;
        >
        > print $result;
        >
        >
        >
        >
        >
        >
        > ------------------------ Yahoo! Groups Sponsor
        >
        > 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/
        >
        >


        __________________________________________________
        Do You Yahoo!?
        Yahoo! - Official partner of 2002 FIFA World Cup
        http://fifaworldcup.yahoo.com
      • ft@sbs.co.at
        Hi Paul, Thanks for the good advice. In fact, it was exactly the problem that the encodingStyle isn t included within the method-element. Additionally, the
        Message 3 of 3 , May 29, 2002
        • 0 Attachment
          Hi Paul,
          Thanks for the good advice. In fact, it was exactly the problem that the
          encodingStyle isn't included within the method-element. Additionally, the
          Apache SOAP Server insists on including the namespace definition within the
          same element of the XML-Stream. I had to code a special Serializer, which
          adds the encoding style and it's namespace automatically to the
          method-element as following:

          package MySerializer; @MySerializer::ISA = 'SOAP::Serializer';
          sub envelope {
          if ($_[1] =~ /^(?:method|response)$/) {
          $_[2] = SOAP::Data->name($_[2])
          ->uri('urn:ejb.User')
          ->encodingStyle
          ("http://schemas.xmlsoap.org/soap/encoding/");
          $_[2]->attr()->{'xmlns:SOAP-ENV'}
          = 'http://schemas.xmlsoap.org/soap/envelope/';
          }

          shift->SUPER::envelope(@_);


          If anybody knows a more elegant way of solving this problem, help would be
          appreciated.
          Thanx,
          Treml Florian
        Your message has been successfully submitted and would be delivered to recipients shortly.