chanakya has asked for the wisdom of the Perl Monks concerning the following question:

Greetings everyone!

I'm working on a small project where the following needs to be done:

1) Create a script which can receive/generate and send data as XML.
i) The script should generate an xml(when a new trouble ticket is created) from the database and POST it to a URL (this URL exists on the client side, something like /call/client/newTAC ).

A sample xml is given below (the format is the same while receiving/sending)

<?xml version="1.0" endocing="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefa +ult="qualified"> <xs:element name="Incident"> <xs:complexType> <xs:sequence> <xs:element ref="Header"/> <xs:element ref="ProviderID"/> <xs:element ref="ProviderClientOrg"/> <xs:element ref="ProviderTicketType"/> </xs:sequence> </xs:complexType> <xs:element> <xs:element name="Transaction"> <xs:complexType> <xs:sequence> <xs:element ref="TransactionType"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="Metrics"> <xs:complexType> <xs:sequence> <xs:element ref="ServiceRestoredDate"/> <xs:element ref="TicketOpenedDate"/> <xs:element ref="TicketClosedDate"/> <xs:element ref="TicketOwner"/> </xs:sequence> </xs:complexType> </xs:element> : : : </xs:schema>
Can anyone has any idea how to proceed with this. I suppose my script should be in daemon mode for receiving the data.
Is it possible to generate the xml from the database as shown above or should it be done programatically. Can you also let me know how can my script receive/send data (pseudo code).

Thank you one and all in advance.

Edit by BazB: change pre to code tags.

Replies are listed 'Best First'.
Re: Script to accept/send data as XML (SOAP) format
by gellyfish (Monsignor) on Feb 28, 2005 at 12:15 UTC

    Er, that isn't the XML that your application is going to send or receive - that is an XSD Schema defining the format of that XML, unfortunately what you have shown us is incomplete in such a way that we cannot infer what that format would be.

    /J\

Re: Script to accept/send data as XML (SOAP) format
by Joost (Canon) on Feb 28, 2005 at 13:33 UTC
    Unless you're going to encode the XML documents you're sending into a SOAP string, this doesn't look like SOAP to me.

    You're probably better off without SOAP anyway, if you want my opinion; it's way too complex.

    Since you're mentioning soap, I guess you want to send/recieve this xml data over HTTP in typical request/response order. For that, you don't need a seperate deamon process; just post with LWP::UserAgent and get the response from the response object.

    updated: fixed url

      gellyfish, you are correct the document was an XSD document. Just got to know that XSD is the predecessor to DTD.
      Joost, I need to send the soap envelope through HTTPS POST to a particular URL, for this alone I can use LWP::UserAgent but what about receiving part...
      For my script to receive shouldn't it be in daemon mode..?

      The basic idea is simple i) to generate an SOAP XML message and post it to a URL, and get the response object
      ii) To receive the SOAP XML message , parse it and give out a response object.

      Correct me if I'm wrong anywhere.

Re: Script to accept/send data as XML (SOAP) format
by JediWizard (Deacon) on Feb 28, 2005 at 14:21 UTC

    Excuse me if I am missing something obvious here, but it seems to me you should investigate SOAP::Lite. I'll not get into the XML, but if you want to create a process which can recieve data, act on it, and transmitt a response, the work of intpreting xml, and encoding a rersponse as xml, has already been done for you.

    May the Force be with you