Results 1 to 6 of 6

Thread: Qt SOAP: parsing response message

  1. #1
    Join Date
    Jun 2012
    Posts
    13
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qt SOAP: parsing response message

    Hello,
    I have the following Qt SOAP getresponse code:
    Qt Code:
    1. void MainWindow::getResponse()
    2. {
    3. /*
    4.   * Get a reference to a response message.
    5.   */
    6. const QtSoapMessage &message = http.getResponse();
    7.  
    8. /*
    9.   * Check if the message is a SOAP Fault message.
    10.   */
    11. if(message.isFault()) {
    12. QMessageBox::critical(this, "Error", message.faultString().toString());
    13. return;
    14. } else {
    15. // print the return value
    16. const QtSoapType &response = message.returnValue();
    17. ui->textEdit->setText(response["GetWhoISResult"].value().toString().toLatin1().constData());
    18. }
    19. }
    To copy to clipboard, switch view to plain text mode 

    I get the following response XML message: I'd like to convert it's GetWhoISResult to QString, then display it in QTextBox.
    ui->textEdit->setText(message.toXmlString());
    Qt Code:
    1. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/1999/XMLSchema">
    2. <SOAP-ENV:Body xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    3. <GetWhoISResponse xmlns="http://www.webservicex.net">
    4. <GetWhoISResult xmlns="http://www.webservicex.net" xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">previous request is being processed for 173.201.44.188</GetWhoISResult>
    5. </GetWhoISResponse>
    6. </SOAP-ENV:Body>
    7. </SOAP-ENV:Envelope>
    To copy to clipboard, switch view to plain text mode 

    This code fails:
    ui->textEdit->setText(response["GetWhoISResult"].value().toString().toLatin1().constData());
    I get nothing.

    How can I try to solve this?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt SOAP: parsing response message

    Try response.value().toString()
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jun 2012
    Posts
    13
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt SOAP: parsing response message

    It doesn't help.

    I modified code:
    Qt Code:
    1. void MainWindow::getResponse()
    2. {
    3. /*
    4.   * Get a reference to a response message.
    5.   */
    6. const QtSoapMessage &message = http.getResponse();
    7.  
    8. /*
    9.   * Check if the message is a SOAP Fault message.
    10.   */
    11. if(message.isFault()) {
    12. QMessageBox::critical(this, "Error", message.faultString().toString());
    13. return;
    14. } else {
    15. // print the return value
    16. const QtSoapType &response = message.returnValue();
    17. if(response["GetWhoISResult"].isValid())
    18. ui->textEdit->setText(response["GetWhoISResult"].value().toString());
    19. else {
    20. QMessageBox::critical(this, "Info", response.errorString());
    21. ui->textEdit->setText(message.toXmlString());
    22. }
    23. }
    To copy to clipboard, switch view to plain text mode 

    Got error:
    "Unknown error"

    XML message:
    Qt Code:
    1. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/1999/XMLSchema">
    2. <SOAP-ENV:Body xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    3. <GetWhoISResponse xmlns="http://www.webservicex.net">
    4. <GetWhoISResult xmlns="http://www.webservicex.net" xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">
    5. DOMAIN NAME: wp.pl&#xd;
    6. registrant type: organization&#xd;
    7. nameservers: ns2.wp.pl. [153.19.102.182]&#xd;
    8. ns1.wp.pl. [212.77.102.200]&#xd;
    9. ns1.task.gda.pl. [153.19.250.101]&#xd;
    10. created: 1998.04.28 13:00:00&#xd;
    11. last modified: 2008.12.18 10:11:20&#xd;
    12. renewal date: 2013.04.27 14:00:00&#xd;
    13. &#xd;
    14. option created: 2011.01.27 17:08:58&#xd;
    15. option expiration date: 2014.01.27 17:08:58&#xd;
    16. &#xd;
    17. dnssec: Unsigned&#xd;
    18. &#xd;
    19. &#xd;
    20. REGISTRAR:&#xd;
    21. NASK&#xd;
    22. ul. Wawozowa 18&#xd;
    23. 02-796 Warszawa&#xd;
    24. Polska/Poland&#xd;
    25. +48.22 3808300&#xd;
    26. info@dns.pl&#xd;
    27. &#xd;
    28. WHOIS displays data with a delay not exceeding 15 minutes in relation to the .pl Registry system&#xd;
    29. Registrant data available at http://dns.pl/cgi-bin/en_whois.pl</GetWhoISResult>
    30. </GetWhoISResponse>
    31. </SOAP-ENV:Body>
    32. </SOAP-ENV:Envelope>
    To copy to clipboard, switch view to plain text mode 

    If I type a name of wrong SOAP object I get the same: "Unknown error". However, it seems to me that "GetWhoISResult" is what I need.
    Last edited by newb_developer; 22nd June 2012 at 21:26. Reason: fixed in source and forum, but the error the same

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt SOAP: parsing response message

    Cast the response object to QtSoapStruct and use the latter's class API to access the proper member of the structure.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jun 2012
    Posts
    13
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt SOAP: parsing response message

    I tried:
    Qt Code:
    1. /*
    2.   * Get a reference to a response message.
    3.   */
    4. const QtSoapMessage &message = http.getResponse();
    5.  
    6. /*
    7.   * Check if the message is a SOAP Fault message.
    8.   */
    9. if(message.isFault()) {
    10. QMessageBox::critical(this, "Error", message.faultString().toString());
    11. return;
    12. } else {
    13. // print the return value
    14. const QtSoapType &response = message.returnValue();
    15.  
    16. ui->textEdit->setText((QtSoapStruct)response["GetWhoISResponse"]);
    17. }
    To copy to clipboard, switch view to plain text mode 
    Compile error:
    Qt Code:
    1. C2440: 'type cast' : cannot convert from 'const QtSoapType' to 'QtSoapStruct'
    2. No constructor could take the source type, or constructor overload resolution was ambiguous
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt SOAP: parsing response message

    If you have a const object then cast it to a const type. If it doesn't work then you need to do the conversion to QtSoapStruct indirectly somehow. I remember fixing something in QtSoap for my own needs but I don't remember if it was related to that cast or not, it was a couple of years ago.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Qt soap api?
    By newb_developer in forum Qt Programming
    Replies: 3
    Last Post: 19th June 2012, 21:28
  2. Replies: 3
    Last Post: 5th June 2012, 21:23
  3. Facing difficulty in parsing xml response in qt
    By newtolinux in forum Qt Programming
    Replies: 1
    Last Post: 14th December 2010, 13:59
  4. Document/literal Soap Message..
    By rmagro in forum Qt Programming
    Replies: 1
    Last Post: 2nd July 2009, 17:05
  5. SOAP message
    By rohan_m_e in forum Qt Programming
    Replies: 2
    Last Post: 3rd December 2008, 09:01

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.