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

650Re: [soaplite] Re: Help needed: sending complex structures

Expand Messages
  • Paul Kulchenko
    Jul 18, 2001
    • 0 Attachment
      Hi, Adrian!

      > I have a similar service that doesn't have the Exchange value, and
      > have fewer return values, and that worked perfectly. I suspect the
      >
      > xsi:type="types:Exchanges" have something to do with it.
      You're right. The way SOAP::Lite works now is that for unknown schema
      it tries to parse complex data types as described in SOAP spec and
      since there is no information on how to process unknown simple type,
      it complains and stops processing.

      I won't tell you what to do for your current version, but in the new
      version (should be released today/tomorrow) you can do:

      package EncodedTypes;

      sub as_TickDirection { $_[1] }
      sub as_Exchanges { $_[1] }

      package main;

      .......

      $soap->deserializer->xmlschemas->{'http://marketdata.earthconnect.net/encodedTypes'}
      = 'EncodedTypes';

      So, you bind xmlnamespace to class that will process datatypes in
      that namespace. You can handle both complex and simple datatype, but
      you don't need to do it for complex ones as soon as default decoding
      is ok for you. I specified handlers for two datatypes: TickDirection
      and Exchanges and just return value. Any processing can apply, you
      can return complex datastructure or do whatever you want.

      Current version will also look for handlers in SOAP::Serializer class
      if no separate classes are specified, so you can also put them in
      SOAP::Serializer (or inherited class), but I'd rather keep them
      separate, esp because when SOAP::Lite gets full XML Schema support,
      so don't need to change your code to get new functionality (I hope
      :)).

      What for a new version and let me know how it works for you. I will
      also include this code as an example if you don't mind :).

      Best wishes, Paul.

      --- adrian@... wrote:
      > Hi Paul,
      >
      > Thanks! That worked perfectly. I have came across a second
      > problem, however, can you please advise on what I should do? I
      > have
      > called a web service, and by a tunneling application I can see that
      >
      > I get the results back, but when I call:
      > $s->WebService($var1);
      > Perl terminates, with the error message being the result of the Web
      >
      > Service. The Web Service returns a rather complex structure:
      >
      > <types:DetailedQuote id="id2" xsi:type="types:DetailedQuote">
      > <Symbol xsi:type="xsd:string">string</Symbol>
      > <CompanyName xsi:type="xsd:string">string</CompanyName>
      > <LastPrice xsi:type="xsd:decimal">decimal</LastPrice>
      > <LastPriceTime
      > xsi:type="xsd:dateTime">dateTime</LastPriceTime>
      > ...
      > <Exchange xsi:type="types:Exchanges"> one of NASDAQ or NYSE
      > or
      > AMEX or INDEX</Exchange>
      >
      > I have a similar service that doesn't have the Exchange value, and
      > have fewer return values, and that worked perfectly. I suspect the
      >
      > xsi:type="types:Exchanges" have something to do with it.
      >
      > I get the return value by:
      > my @struct = @{$s->WebService($var1)->result};
      > $symbol = $struct[0]->{Symbol};
      > but the problem is the program stops at $s->WebService($var1)
      > because it can't deserialize the result. If I use the other
      > service, WebService2, the above code works fine.
      >
      > Any suggestions?
      >
      > Adrian
      >
      >
      > --- In soaplite@y..., Paul Kulchenko <paulclinger@y...> wrote:
      > > Hi, Adrian!
      > >
      > > > > %header=('Key',"$key",'Type',"$type");
      > > > > @symbols=($symbol, "IBM");
      > > > > $var1 = SOAP::Data->type(boolean => false)->name('realtime');
      > > > > $var2 = SOAP::Data->type(array => @symbols)->name('Array');
      > > > > my $a = $s -> GetSimpleQuote($var1, $var2,SOAP::Header->name
      > > > > ('AuthenticationHeader' => %header));
      > > %header should be hashref, not hash:
      > >
      > > > > SOAP::Header->name('AuthenticationHeader' => %header);
      > > either:
      > >
      > > SOAP::Header->name('AuthenticationHeader' => \%header);
      > >
      > > or
      > >
      > > $header = {Key => $key, Type => $type};
      > > SOAP::Header->name('AuthenticationHeader' => $header);
      > >
      > > Hope it helps.
      > >
      > > Best wishes, Paul.
      >
      >
      >
      > ------------------------ 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!?
      Get personalized email addresses from Yahoo! Mail
      http://personal.mail.yahoo.com/
    • Show all 10 messages in this topic