Results 1 to 8 of 8

Thread: Xml Serialization ???

  1. #1
    Join Date
    Jul 2012
    Posts
    40
    Qt products
    Qt4 Qt/Embedded

    Default Xml Serialization ???

    Hi all ,

    After executing a query, How i need to do XML- Serialization of the resultant query. How can i pass Serialization object to Web Service to get required response.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Xml Serialization ???

    Can you add some details to that? Execute what kind of query, which web services, etc?

    Cheers,
    _

  3. #3
    Join Date
    Jul 2012
    Posts
    40
    Qt products
    Qt4 Qt/Embedded

    Default Re: Xml Serialization ???

    Thanks for the reply....
    In Local database i save my transaction data ..I need to insert this data in server....so now i get my required data from local db to transfer to server through query. For example i got 5 rows with 10 columns........now to insert in server db,I need to do serialization for these result and hit the web service with that serialized object to pass these data and get inserted in the server....???? OR it can be solved in any other way if so plz give me an idea on it ..??

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Xml Serialization ???

    Generating XML for your query result should be quite easy with QXmlStreamWriter, the Qt documentation even has a full example for its usage.

    You basically create a QXmlStreamWriter object and have it operate on a QBuffer or QByteArray.
    Then you start the XML document by calling writeStartDocument(). At the end you finish the XML document by calling writeEndDocument().

    In between you iterate over your query and call writeStartElement(), writeEndElement() for creating XML elements/tags, using the tag names and structure specified by your web service's API.

    Cheers,
    _

  5. #5
    Join Date
    Jul 2012
    Posts
    40
    Qt products
    Qt4 Qt/Embedded

    Default Re: Xml Serialization ???

    Hi anda_skoa thankz for reply........That part of writing db data to xml is completed with DomDocument without any problem.
    My question is about how to hit the web service api through object as a parameter( i.e created in asp.net) .For example my service is http://serviceurl.com/postStudentDataMethod. ......This url accepts the student object in c# with id ,name , phone,address,age.....etc upt o 30. How to create that student object in qt and how to pass these object with those details to above url !

  6. #6
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 284 Times in 279 Posts

    Default Re: Xml Serialization ???

    I think this is what You need.

  7. #7
    Join Date
    Jul 2012
    Posts
    40
    Qt products
    Qt4 Qt/Embedded

    Default Re: Xml Serialization ???

    thankz for reply Lesiok.................In the given example,the response data is formated to xml ...But i need to pass a object to web service api..where the object holds 10 values(like name,area,ID,phno...etc) in xml kind of format...

  8. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Xml Serialization ???

    Well, sending data to a web service is usually done via HTTP POST, which is available in Qt through QNetworkAccessManager.

    How the post data has to be structured depends on the web service API.

    If it is a SOAP API and therefore has a WSDL file describing the API, you could use a code generate like the one from https://github.com/KDAB/KDSoap to generate Qt API for you.

    If it is something different, e.g. a REST interface using XML as the data format, you'll have send your XML data manually using QNetworkAccessManager.

    Cheers,
    _

Similar Threads

  1. Serialization problem
    By ayanda83 in forum Newbie
    Replies: 3
    Last Post: 23rd September 2012, 18:52
  2. XML serialization into a X3D scene
    By sajis997 in forum Newbie
    Replies: 1
    Last Post: 30th August 2011, 11:57
  3. Serialization and inheritance using Qt
    By totem in forum Qt Programming
    Replies: 5
    Last Post: 16th January 2011, 16:16
  4. QCache serialization
    By Flakes in forum Qt Programming
    Replies: 2
    Last Post: 10th January 2011, 17:44
  5. Serialization
    By donmorr in forum Qt Programming
    Replies: 4
    Last Post: 16th November 2006, 14:51

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.