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

Re: [soaplite] More about Problem with WSDL file with document-literal style

Expand Messages
  • Weidong Wang
    Thanks, Paul. This is very helpful. I am getting to generate the envelope that I want. Here is what I found out: 1. Without using a WSDL file To make
    Message 1 of 4 , Jul 2 8:26 AM
    • 0 Attachment
      Thanks, Paul. This is very helpful. I am getting to generate the envelope
      that I want.

      Here is what I found out:

      1. Without using a WSDL file

      To make "call($data)" to work, the $data should also include the top level
      tag. In this case, it is "GetLastTradePrice". So I made it like:

      $data =
      SOAP::Data->name(GetLastTradePrice)->uri('http://example.com/StockQuoteServi
      ce/')
      ->type(ordered_hash => [tickerSymbol => SOAP::Data->type('' =>
      'MSFT')]);

      That generates the envelope body like this:

      <SOAP-ENV:Body>
      <namesp1:GetLastTradePrice
      xmlns:namesp1="http://example.com/StockQuoteService/">
      <tickerSymbol>MSFT</tickerSymbol>
      </namesp1:GetLastTradePrice>
      </SOAP-ENV:Body>

      2. Using a wsdl with service() call

      I have to call with an operation name, and in this case, the default
      serializer will generate an envelope that I don't like:

      $data = SOAP::Data->name(tickerSymbol => 'MSFT')->type('');

      SOAP::Lite
      -> service('file:stockquote.wsdl')
      -> serializer(SOAP::Serializer::Literal->new)
      -> GetLastTradePrice($data);

      <SOAP-ENV:Body>
      <c-gensym3 xsi:type="xsd:string">GetLastTradePrice</c-gensym3>
      <tickerSymbol>MSFT</tickerSymbol>
      </SOAP-ENV:Body>

      So what I did is to add another "shift" in the "envelope" sub:

      BEGIN {
      package SOAP::Serializer::Literal;
      @SOAP::Serializer::Literal::ISA = 'SOAP::Serializer';
      sub envelope {
      my $self = shift; shift; shift; # let it always be 'freeform'
      $self->SUPER::envelope(freeform => @_);
      }
      }

      and call with the data that includes the top level operation name, like the
      case to use call() in #1:

      $data =
      SOAP::Data->name(GetLastTradePrice)->uri('http://example.com/StockQuoteServi
      ce/')
      ->type(ordered_hash => [tickerSymbol => SOAP::Data->type('' =>
      'MSFT')]);

      SOAP::Lite
      -> service('file:stockquote.wsdl')
      -> serializer(SOAP::Serializer::Literal->new)
      -> GetLastTradePrice($data);

      And this generates the same envelope as in #1.

      Thanks again.

      Weidong


      ----- Original Message -----
      From: "Paul Kulchenko" <paulclinger@...>
      To: "Weidong Wang" <wwang@...>; <soaplite@yahoogroups.com>
      Sent: Tuesday, July 02, 2002 2:07 AM
      Subject: Re: [soaplite] More about Problem with WSDL file with
      document-literal style


      > Hi, Weidong!
      >
      > > How do I work around it?
      > You may use Literal serializer:
      >
      > BEGIN {
      > package SOAP::Serializer::Literal;
      > @SOAP::Serializer::Literal::ISA = 'SOAP::Serializer';
      > sub envelope {
      > my $self = shift; shift; # let it always be 'freeform'
      > $self->SUPER::envelope(freeform => @_);
      > }
      > }
      >
      > and use it like this:
      >
      > my $data = SOAP::Data->name(body => 'MSFT')->type('');
      >
      > SOAP::Lite
      > -> proxy('http://localhost/')
      > -> serializer(SOAP::Serializer::Literal->new)
      > -> call($data);
      >
      > This should also work with service() interface, just register the
      > serializer. Let me know if you have any problems.
      >
      > Best wishes, Paul.
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.