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

Re: [soaplite] Accessing XML Data attributes (was Re: Newbie question)

Expand Messages
  • Paul Kulchenko
    Hi, Robert! ... Oops, my fault. I didn t realize that package declaration is in the same file as your server code. That s Perl s feature. You need to wrap
    Message 1 of 9 , Oct 22, 2001
      Hi, Robert!

      > Fault: SOAP-ENV:Server, Can't call method "dataof" on unblessed
      > reference at /www/one/cgi-bin/server.cgi line 17.
      Oops, my fault. I didn't realize that 'package' declaration is in the
      same file as your server code. That's Perl's feature. You need to
      wrap "package ONE" and the rest into BEGIN block for @ISA declaration
      to be valid. Hope it helps.

      Best wishes, Paul.

      --- Silly Yahoo Readers <theonetowhommyrefers@...> wrote:
      > Quick follow-up... (I meet with the biz partner in an hour and have
      >
      > to sound smart...) I get this error:
      >
      > Fault: SOAP-ENV:Server, Can't call method "dataof" on unblessed
      > reference at /www/one/cgi-bin/server.cgi line 17.
      >
      > Here's my updated server (not cleaned up):
      >
      > #!/usr/local/bin/perl -w
      > use SOAP::Transport::HTTP;
      >
      > SOAP::Transport::HTTP::CGI
      > -> dispatch_to('ONE')
      > -> handle;
      >
      > package ONE;
      > @ONE::ISA = 'SOAP::Server::Parameters';
      >
      >
      > sub dump {
      > my $env = pop;
      > my ($class, @params) = @_;
      > use Data::Dumper;
      > #return Dumper(@params);
      > return $env->dataof('//Test/Question')->attr->{type};
      > }
      >
      >
      > --- In soaplite@y..., Paul Kulchenko <paulclinger@y...> wrote:
      > > Hi, Robert!
      > >
      > > --- Silly Yahoo Readers <theonetowhommyrefers@y...> wrote:
      > > > Sometime around 3 AM I started getting it... ;-) Thanks for
      > your
      > > ;)
      > >
      > > > How do I access the attributes in the XML Data?
      > > you need to do something like this (you can find more details in
      > docs
      > > and examples):
      > >
      > > > package ONE;
      > > @ONE::ISA = 'SOAP::Server::Parameters';
      > > >
      > > > sub dump {
      > > my $env = pop;
      > > > my ($class, @params) = @_;
      > > > use Data::Dumper;
      > > > #return Dumper(@params); # Dumps DOM tree, no attributes
      > > return $env->dataof('//Test/Question')->attr->{type}
      > > # should return "short answer"
      > > # dataof() returns SOAP::Data attribute that you can access
      > > # for attributes and other information
      > > > return $params[0]->{ROOT}->{some}->{node}; # access elements
      > > > }
      > >
      > > Best wishes, Paul.
      > >
      > > --- Silly Yahoo Readers <theonetowhommyrefers@y...> wrote:
      > > > Paul,
      > > >
      > > > Sometime around 3 AM I started getting it... ;-) Thanks for
      > your
      > > > input in this forum, etc.
      > > >
      > > > Now I'm using type(xml =>...) and am able to get the elements
      > (not
      > > > the attributes) of the XML record. Is there a way to get the
      > > > attributes, too? I can get at the elements with a simple
      > > >
      > > > return "root__child: $_[0]->{root}->{child}";
      > > >
      > > > How do I access the attributes in the XML Data?
      > > >
      > > > Here's my simple server:
      > > >
      > > > #!/usr/local/bin/perl -w
      > > > use SOAP::Transport::HTTP;
      > > >
      > > > SOAP::Transport::HTTP::CGI
      > > > -> dispatch_to('ONE')
      > > > -> handle;
      > > >
      > > > package ONE;
      > > >
      > > > sub dump {
      > > > my ($class, @params) = @_;
      > > > use Data::Dumper;
      > > > #return Dumper(@params); # Dumps DOM tree, no attributes
      > > > return $params[0]->{ROOT}->{some}->{node}; # access elements
      > > > }
      > > >
      > > > exit;
      > > >
      > > > --- In soaplite@y..., Paul Kulchenko <paulclinger@y...> wrote:
      > > > > Hi, Robert!
      > > > >
      > > > > SOAP::Data->type(xml => ...) is the way to send XML fragment
      > that
      > > > > will look like XML on wire. SOAP::Lite doesn't do any
      > validation
      > > > in
      > > > > this case, so it's quite possible that generated XML (by
      > itself
      > > > or
      > > > in
      > > > > combination with SOAP envelope) is invalid. ->type(base64
      > => ...)
      > > > > doesn't have this problem and always generate valid XML. You
      > may
      > > > see
      > > > > what do you have on wire if you switch on debug info on
      > client
      > > > side
      > > > > with ->on_debug(sub{print@_}).
      > > > >
      > > > > If you insert XML as a fragment I do not recommend you to use
      > > > > unqualified 'id' attributes, because they may interfere
      > with 'id'
      > > > > attribute that is used by SOAP itself (yet you'll be able to
      > > > access
      > > > > that attribute).
      > > > >
      > > > > > > 4) What's the best way to send/receive a well-formed
      > > > > > > and x-schema validating XML data record for import
      > > > > > > into a local database?
      > > > > I would say base64 is the best way to go (esp. if XML
      > processing
      > > > is
      > > > > required on another side anyway), because if you encode XML
      > as a
      > > > > fragment you'll need to write custom deserializer to process
      > your
      > > > > data. Let me know if you have any questions.
      > > > >
      > > > > Best wishes, Paul.
      > > > >
      > > > > --- Silly Yahoo Readers <theonetowhommyrefers@y...> wrote:
      > > > > > Since writing the below I found the SOAP::Data->type(...)
      > > > thingy
      > > > > > (attribute? directive?) and played around with a few
      > settings.
      > > > When
      > > > > > I
      > > > > > specify the default (base64) my server finds and parses the
      > > > > > message.
      > > > > > When I specify 'xml' I get the following error:
      > > > > >
      > > > > > Fault: SOAP-ENV:Server, not well-formed (invalid token) at
      > line
      > > >
      > > > 1,
      > > > > > column 4, byte 4 at
      > /usr/local/lib/perl5/site_perl/5.6.1/i686-
      > > > > > linux/XML/Parser.pm line 185
      > > > > >
      > > > > > *Sigh* Help?
      > > > > >
      > > > > > --
      > > > > > Robert Taylor
      > > > > >
      > > > > > --- In soaplite@y..., Robert Taylor
      > <theonetowhommyrefers@y...>
      > > > > > wrote:
      > > > > > > I created my first data-based connected SOAP
      > > > > > > client/server combination using SOAP-Lite. Now I want
      > > > > > > my business partner to be able to use my HTTPS/CGI
      > > > > > > SOAP server and have run into a problem.
      > > > > > >
      > > > > > > My goal is to receive an XML record for import into my
      > > > > > > (MySQL) database. The partner defined the record but
      > > > > > > I'm defining the SOAP service.
      > > > > > >
      > > > > > > A few questions:
      > > > > > >
      > > > > > > 1) If the @lines in "$soap->store(@lines)" contains a
      > > > > > > well-formed and x-schema validated XML file, why is
      > > > > > > the payload (right term?) serialized?
      > > > > > >
      > > > > > > 2) Related to (1) -- the data sent to the server is
      > > > > > > encoded (base 64?). Must it be?
      > > > > > >
      > > > > > > 3) My partner is coding his own client (not using
      > > > > > > SOAP::Lite, but something in C++ on an MS platform --
      > > > > > > not using .NET tools either). He's sending basically
      > > > > > > handcrafted SOAP messages with the Body a simple XML
      > > > > > > file. When I showed him the output of my client.cgi
      > > > > > > (below) using the "on_debug" method he balked at the
      > > > > > > Base64 and <c-gensym6 xsi:type="xsd:int"> wrappers on
      > > > > > > the XML file.
      > > > > > >
      > > > > > > Pretend my XML Data looks like this:
      > > > > > >
      > > > > > > <Test>
      > > > > > > <Question id="1" type="short answer"><text>What is
      > > > > > > the correct spelling of your name?</text></Question>
      > > > > > > <Question id="2" type="multiple choice"><text>What
      > > > > > > is your gender?</text>
      > > > > > > <option id="A">Male</option>
      > > > > > > <option id="B">Female</option>
      >
      === message truncated ===


      __________________________________________________
      Do You Yahoo!?
      Make a great connection at Yahoo! Personals.
      http://personals.yahoo.com
    • Silly Yahoo Readers
      Works beautifully! Now i kan go bee smaRt n act learneded. (Later I make sure I really understand it!). Thanks. -- Robert Taylor ... the ... declaration ...
      Message 2 of 9 , Oct 22, 2001
        Works beautifully! Now i kan go bee smaRt 'n act learneded. (Later I
        make sure I really understand it!).

        Thanks.

        --
        Robert Taylor


        --- In soaplite@y..., Paul Kulchenko <paulclinger@y...> wrote:
        > Hi, Robert!
        >
        > > Fault: SOAP-ENV:Server, Can't call method "dataof" on unblessed
        > > reference at /www/one/cgi-bin/server.cgi line 17.
        > Oops, my fault. I didn't realize that 'package' declaration is in
        the
        > same file as your server code. That's Perl's feature. You need to
        > wrap "package ONE" and the rest into BEGIN block for @ISA
        declaration
        > to be valid. Hope it helps.
        >
        > Best wishes, Paul.
        >
        > --- Silly Yahoo Readers <theonetowhommyrefers@y...> wrote:
        > > Quick follow-up... (I meet with the biz partner in an hour and
        have
        > >
        > > to sound smart...) I get this error:
        > >
        > > Fault: SOAP-ENV:Server, Can't call method "dataof" on unblessed
        > > reference at /www/one/cgi-bin/server.cgi line 17.
        > >
        > > Here's my updated server (not cleaned up):
        > >
        > > #!/usr/local/bin/perl -w
        > > use SOAP::Transport::HTTP;
        > >
        > > SOAP::Transport::HTTP::CGI
        > > -> dispatch_to('ONE')
        > > -> handle;
        > >
        > > package ONE;
        > > @ONE::ISA = 'SOAP::Server::Parameters';
        > >
        > >
        > > sub dump {
        > > my $env = pop;
        > > my ($class, @params) = @_;
        > > use Data::Dumper;
        > > #return Dumper(@params);
        > > return $env->dataof('//Test/Question')->attr->{type};
        > > }
        > >
        > >
        > > --- In soaplite@y..., Paul Kulchenko <paulclinger@y...> wrote:
        > > > Hi, Robert!
        > > >
        > > > --- Silly Yahoo Readers <theonetowhommyrefers@y...> wrote:
        > > > > Sometime around 3 AM I started getting it... ;-) Thanks for
        > > your
        > > > ;)
        > > >
        > > > > How do I access the attributes in the XML Data?
        > > > you need to do something like this (you can find more details
        in
        > > docs
        > > > and examples):
        > > >
        > > > > package ONE;
        > > > @ONE::ISA = 'SOAP::Server::Parameters';
        > > > >
        > > > > sub dump {
        > > > my $env = pop;
        > > > > my ($class, @params) = @_;
        > > > > use Data::Dumper;
        > > > > #return Dumper(@params); # Dumps DOM tree, no attributes
        > > > return $env->dataof('//Test/Question')->attr->{type}
        > > > # should return "short answer"
        > > > # dataof() returns SOAP::Data attribute that you can access
        > > > # for attributes and other information
        > > > > return $params[0]->{ROOT}->{some}->{node}; # access
        elements
        > > > > }
        > > >
        > > > Best wishes, Paul.
        > > >
        > > > --- Silly Yahoo Readers <theonetowhommyrefers@y...> wrote:
        > > > > Paul,
        > > > >
        > > > > Sometime around 3 AM I started getting it... ;-) Thanks for
        > > your
        > > > > input in this forum, etc.
        > > > >
        > > > > Now I'm using type(xml =>...) and am able to get the elements
        > > (not
        > > > > the attributes) of the XML record. Is there a way to get the
        > > > > attributes, too? I can get at the elements with a simple
        > > > >
        > > > > return "root__child: $_[0]->{root}->{child}";
        > > > >
        > > > > How do I access the attributes in the XML Data?
        > > > >
        > > > > Here's my simple server:
        > > > >
        > > > > #!/usr/local/bin/perl -w
        > > > > use SOAP::Transport::HTTP;
        > > > >
        > > > > SOAP::Transport::HTTP::CGI
        > > > > -> dispatch_to('ONE')
        > > > > -> handle;
        > > > >
        > > > > package ONE;
        > > > >
        > > > > sub dump {
        > > > > my ($class, @params) = @_;
        > > > > use Data::Dumper;
        > > > > #return Dumper(@params); # Dumps DOM tree, no attributes
        > > > > return $params[0]->{ROOT}->{some}->{node}; # access
        elements
        > > > > }
        > > > >
        > > > > exit;
        > > > >
        > > > > --- In soaplite@y..., Paul Kulchenko <paulclinger@y...> wrote:
        > > > > > Hi, Robert!
        > > > > >
        > > > > > SOAP::Data->type(xml => ...) is the way to send XML
        fragment
        > > that
        > > > > > will look like XML on wire. SOAP::Lite doesn't do any
        > > validation
        > > > > in
        > > > > > this case, so it's quite possible that generated XML (by
        > > itself
        > > > > or
        > > > > in
        > > > > > combination with SOAP envelope) is invalid. ->type(base64
        > > => ...)
        > > > > > doesn't have this problem and always generate valid XML. You
        > > may
        > > > > see
        > > > > > what do you have on wire if you switch on debug info on
        > > client
        > > > > side
        > > > > > with ->on_debug(sub{print@_}).
        > > > > >
        > > > > > If you insert XML as a fragment I do not recommend you to
        use
        > > > > > unqualified 'id' attributes, because they may interfere
        > > with 'id'
        > > > > > attribute that is used by SOAP itself (yet you'll be able to
        > > > > access
        > > > > > that attribute).
        > > > > >
        > > > > > > > 4) What's the best way to send/receive a well-formed
        > > > > > > > and x-schema validating XML data record for import
        > > > > > > > into a local database?
        > > > > > I would say base64 is the best way to go (esp. if XML
        > > processing
        > > > > is
        > > > > > required on another side anyway), because if you encode XML
        > > as a
        > > > > > fragment you'll need to write custom deserializer to
        process
        > > your
        > > > > > data. Let me know if you have any questions.
        > > > > >
        > > > > > Best wishes, Paul.
        > > > > >
        > > > > > --- Silly Yahoo Readers <theonetowhommyrefers@y...> wrote:
        > > > > > > Since writing the below I found the SOAP::Data->type(...)
        > > > > thingy
        > > > > > > (attribute? directive?) and played around with a few
        > > settings.
        > > > > When
        > > > > > > I
        > > > > > > specify the default (base64) my server finds and parses
        the
        > > > > > > message.
        > > > > > > When I specify 'xml' I get the following error:
        > > > > > >
        > > > > > > Fault: SOAP-ENV:Server, not well-formed (invalid token)
        at
        > > line
        > > > >
        > > > > 1,
        > > > > > > column 4, byte 4 at
        > > /usr/local/lib/perl5/site_perl/5.6.1/i686-
        > > > > > > linux/XML/Parser.pm line 185
        > > > > > >
        > > > > > > *Sigh* Help?
        > > > > > >
        > > > > > > --
        > > > > > > Robert Taylor
        > > > > > >
        > > > > > > --- In soaplite@y..., Robert Taylor
        > > <theonetowhommyrefers@y...>
        > > > > > > wrote:
        > > > > > > > I created my first data-based connected SOAP
        > > > > > > > client/server combination using SOAP-Lite. Now I want
        > > > > > > > my business partner to be able to use my HTTPS/CGI
        > > > > > > > SOAP server and have run into a problem.
        > > > > > > >
        > > > > > > > My goal is to receive an XML record for import into my
        > > > > > > > (MySQL) database. The partner defined the record but
        > > > > > > > I'm defining the SOAP service.
        > > > > > > >
        > > > > > > > A few questions:
        > > > > > > >
        > > > > > > > 1) If the @lines in "$soap->store(@lines)" contains a
        > > > > > > > well-formed and x-schema validated XML file, why is
        > > > > > > > the payload (right term?) serialized?
        > > > > > > >
        > > > > > > > 2) Related to (1) -- the data sent to the server is
        > > > > > > > encoded (base 64?). Must it be?
        > > > > > > >
        > > > > > > > 3) My partner is coding his own client (not using
        > > > > > > > SOAP::Lite, but something in C++ on an MS platform --
        > > > > > > > not using .NET tools either). He's sending basically
        > > > > > > > handcrafted SOAP messages with the Body a simple XML
        > > > > > > > file. When I showed him the output of my client.cgi
        > > > > > > > (below) using the "on_debug" method he balked at the
        > > > > > > > Base64 and <c-gensym6 xsi:type="xsd:int"> wrappers on
        > > > > > > > the XML file.
        > > > > > > >
        > > > > > > > Pretend my XML Data looks like this:
        > > > > > > >
        > > > > > > > <Test>
        > > > > > > > <Question id="1" type="short answer"><text>What is
        > > > > > > > the correct spelling of your name?</text></Question>
        > > > > > > > <Question id="2" type="multiple choice"><text>What
        > > > > > > > is your gender?</text>
        > > > > > > > <option id="A">Male</option>
        > > > > > > > <option id="B">Female</option>
        > >
        > === message truncated ===
        >
        >
        > __________________________________________________
        > Do You Yahoo!?
        > Make a great connection at Yahoo! Personals.
        > http://personals.yahoo.com
      • David Inglis
        Could anybody please provide asssistance with the following, I have got to convert the following from a microsoft to perl what would I need to do with soap
        Message 3 of 9 , Oct 24, 2004
          Could anybody please provide asssistance with the following, I have got to
          convert the following from a microsoft to perl what would I need to do with
          soap lite to achieve the following


          There are three steps that need to be performed to invoke a web service function
          these are:
          1. Create the SOAP client object:
          Set objSoapClient = Server.CreateObject("MSSOAP.SoapClient30")

          2. Initialise the SOAP client using the Web Services Definition Language (WSDL)
          file as input using the following code snippet.
          Const WSDL_URL =
          "http://national.atdw.com.au/soap/AustralianTourismWebService.asmx?WSDL"
          objSoapClient.ClientProperty("ServerHTTPRequest") = True
          objSoapClient.mssoapinit ( WSDL_URL )

          3. Invoke the ATWS command function CommandHandler with the Distributor Key,
          command name and command parameters.
          strResult = ObjSoapClient.CommandHandler( strDistributorKey, _
          strCommandName"), _
          strCommandParameters )

          The strDistributorKey is your unique Distributor Key value that you were
          provided when you became an authorized ATDW Distributor.
          The strCommandName is the name of the ATWS command Handler Command Function that
          you wish to invoke, e.g. QueryProducts
          The strCommandParameters are the xml formatted input command parameters specific
          for the command function that is being invoked.




          --
          Regards


          David Inglis

          ideloveto.com.au ideloveto.com
          reddunes.com.au reddunes.com
          limpfrog.com.au limpfrog.com





          ----------------------------------------------------------------
          This message was sent using IMP, the Internet Messaging Program.
        Your message has been successfully submitted and would be delivered to recipients shortly.