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

RE: [soaplite] XML message wrapping/unwrapping

Expand Messages
  • Paul Kulchenko
    Hi, Lon! ... That s correct advice, however there is one more thing. Your XML code isn t valid, because it has more than one root. XML parser will complain if
    Message 1 of 3 , Nov 21, 2001
    • 0 Attachment
      Hi, Lon!

      --- Sean.Meisner@... wrote:
      > The way I do this type of thing is, after the SOAP call returns,
      > I grab the XML fragment as a string ($acme_response in your case)
      > and process it in my application code using one of the XML parsing
      > modules on CPAN. I tend to use XML::XPath and XML::Twig. I
      That's correct advice, however there is one more thing. Your XML code
      isn't valid, because it has more than one root. XML parser will
      complain if you try to parse something like this:

      <RESULT>Success!</RESULT><DATETIME>Jan 01 2002 02:35:40</DATETIME>

      you either need to wrap it into one more element (so there will be
      single root element), or insert it as an XML fragment and access
      using SOAP::Lite's capabilities. For example, on server side you may
      use something like this:

      SOAP::Data->type(xml => q!<RESULT>Success!</RESULT><DATETIME>Jan 01
      2002 02:35:40</DATETIME>!)

      and then on client side:

      my($result, $datetime) = $service->doOrder($acme_request);

      Best wishes, Paul.

      > > -----Original Message-----
      > > From: kowalski [mailto:kowalski@...]
      > > Sent: Wednesday, November 21, 2001 10:57 AM
      > > To: soaplite@yahoogroups.com
      > > Subject: [soaplite] XML message wrapping/unwrapping
      > >
      > >
      > >
      > > Hi, I know there are lots of other questions on the thread
      > > but I think this would be of benefit to many other SOAP::Lite
      > > developers. If there's a reference or walkthrough somewhere,
      > > please post the URL. I can't get past this problem and I
      > > think an example would be a great help.
      > >
      > > I am creating a perl client using SOAP::Lite to talk to a
      > > J2EE service published via WSDL. The service (call it ACME)
      > > can accept my fragments of XML without using a DTD (we have a
      > > very limited set of tags). My request would be as so
      > > (formatted for clarity, not correct Perl syntax)
      > >
      > >
      > > $acme_request = "<USERNAME>kowalski</USERNAME>
      > > <PASSWORD>qwerty</PASSWORD>
      > >
      > <PURCHASE_ITEM>XM1_ROCKETSKATES</PURCHASE_ITEM>
      > > <PURCHASE_QTY>10<PURCHASE_QTY>";
      > >
      > > And the response, wrapped in XML, could include:
      > >
      > > <RESULT>Success!</RESULT><DATETIME>Jan 01 2002
      > 02:35:40</DATETIME>
      > >
      > > ========= Begin ACME client ==========
      > >
      > > #!perl -w
      > >
      > > use SOAP::Lite;
      > >
      > > my $service = SOAP::Lite
      > > -> service('http://www.acme.com/WSDL/acme.wsdl');
      > >
      > > my $acme_response = $service->doOrder($acme_request);
      > >
      > > ========= END ACME client ==========
      > >
      > >
      > > My questions:
      > >
      > > 1. How do I parse the xml response ($acme_response in
      > > this case) to extract the tags I want? I've seen your
      > > discussions on using SOAP::Data but the light is not going on
      > > for me. How do I break the tagset of the XML response?
      > >
      > > 2. If my method throws a fault, can I use the same XML
      > > parser to get the fault information? Acme will return a
      > > detailed description of the fault and I would like to extract
      > > that detail and throw it back to the calling function.
      > >
      > > I see references to SOAP::Data on this group but am
      > > unable to find a complete description in the documentation or
      > > on soaplite.com (aside from a brief discussion in one of the
      > > presentations.)
      > >
      > > Any help would be very...um, helpful. Thanks so much.
      > >
      > >
      > >
      > > Lon Miller
      > >
      > >
      > > 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/
      > >
      > >
      >
      > ------------------------ 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!?
      Make a great connection at Yahoo! Personals.
      http://personals.yahoo.com
    Your message has been successfully submitted and would be delivered to recipients shortly.