Results 1 to 5 of 5

Thread: QTSoapMessage Question

  1. #1
    Join Date
    Jul 2010
    Posts
    23
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question QTSoapMessage Question

    I want to create a SOAP message based on the following XM file:
    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <SOAP-ENV:Envelope
    3. xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    4. xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
    5. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    6. xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    7. xmlns:ns2="http://www.remotereality.com/HubbleSOAP.xsd3"
    8. xmlns:ns3="http://www.remotereality.com/HubbleSOAP/binding/cameracontrol"
    9. xmlns:ns4="http://www.remotereality.com/HubbleSOAP/binding/videoprocamp"
    10. xmlns:ns5="http://www.remotereality.com/HubbleSOAP/binding/jpegCODEC"
    11. xmlns:ns6="http://www.remotereality.com/HubbleSOAP/binding/viewcontrol"
    12. xmlns:ns7="http://www.remotereality.com/HubbleSOAP/binding/KSPropertySet">
    13. <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    14. <ns6:SetAngles>
    15. <index>0</index>
    16. <yaw>0.0</yaw>
    17. <pitch>0.0</pitch>
    18. <roll>0.0</roll>
    19. </ns6:SetAngles>
    20. </SOAP-ENV:Body>
    21. </SOAP-ENV:Envelope>
    To copy to clipboard, switch view to plain text mode 

    I am a newbie when it comes to SOAP. Could anybody show me in detail using the QTSoapMessage class on how to do it? Thanks.

  2. #2
    Join Date
    Jul 2010
    Posts
    23
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QTSoapMessage Question

    Never mind, I got it now. Any example for parsing the QTSoapMessage? Thanks.

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

    Default Re: QTSoapMessage Question

    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.


  4. #4
    Join Date
    Jul 2010
    Posts
    23
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QTSoapMessage Question

    In the getResponse method, all I got are the method names, but no data are shown. There is something wrong with the parser.
    Qt Code:
    1. void Google::getResponse()
    2. {
    3. // Set cursor back to normal shape.
    4. QApplication::restoreOverrideCursor();
    5.  
    6. // Reset resultView.
    7. resultView->clear();
    8.  
    9. // Get the response, check for error.
    10. const QtSoapMessage &resp = http.getResponse();
    11. if (resp.isFault()) {
    12. resultView->setHtml(tr("<b>Query failed</b>: ")
    13. + resp.faultString().value().toString());
    14. return;
    15. }
    16.  
    17. // Extract the return value from this method response, check for
    18. // errors.
    19. const QtSoapType &res = resp.returnValue();
    20. if (!res.isValid()) {
    21. resultView->append(tr("Invalid return value"));
    22. return;
    23. }
    24.  
    25. // Generate resultView output. Make it resemble the actual web
    26. // output from http://www.google.com/.
    27. QString header(tr("Searched the web for <b>%1</b>, results %2 - %3 "
    28. "of about %4. Search took %5 seconds.<br><hr>")
    29. .arg(res["searchQuery"].toString())
    30. .arg(res["startIndex"].toInt())
    31. .arg(res["endIndex"].toInt())
    32. .arg(res["estimatedTotalResultsCount"].toInt())
    33. .arg(res["searchTime"].value().toDouble(), 0, 'f', 2));
    34.  
    35. const QtSoapType &resultElements = res["resultElements"];
    36. QString allElements;
    37.  
    38. for (int i = 0; i < resultElements.count(); ++i) {
    39. const QtSoapType &resultElement = res["resultElements"][i];
    40.  
    41. QString cat = resultElement["directoryCategory"]["fullViewableName"].toString();
    42. QString summary = resultElement["summary"].toString();
    43. QString title = resultElement["title"].toString();
    44. QString snippet = resultElement["snippet"].toString();
    45. QString url = resultElement["URL"].toString();
    46. QString cachedSize = resultElement["cachedSize"].toString();
    47.  
    48. QString thisElement = "<br>";
    49.  
    50. if (!title.isEmpty()) {
    51. thisElement += "<font color=\"#0000FF\"><b><u>"
    52. + title + "</u></b></font><br>";
    53. } else {
    54. thisElement += "<font color=\"#0000FF\"><b><u>"
    55. + url + "</u></b></font><br>";
    56. }
    57.  
    58. if (!snippet.isEmpty())
    59. thisElement += snippet + "<br>";
    60.  
    61. if (!summary.isEmpty()) {
    62. thisElement += "<font color=\"#808080\">Description:</font> "
    63. + summary + "<br>";
    64. }
    65.  
    66. if (!cat.isEmpty()) {
    67. thisElement += "<font color=\"#808080\">Category: <u>"
    68. + cat + "</u></font><br>";
    69. }
    70.  
    71. if (!title.isEmpty()) {
    72. thisElement += "<font color=\"#008000\"><u>" + url
    73. + "</u> - " + cachedSize + "</font><br>";
    74. }
    75.  
    76. allElements += thisElement;
    77. }
    78.  
    79. // Update the resultView.
    80. resultView->setHtml(header + allElements);
    81. }
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jul 2010
    Posts
    23
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QTSoapMessage Question

    Here are my xml response data:
    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. <GetFieldOfViewResponse xmlns="http://www.remotereality.com/HubbleSOAP/binding/viewcontrol">
    4. <HRESULT xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" >0</HRESULT>
    5. <d1 xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" >6.2831853071795862</d1>
    6. <d2 xsi:type="xsd:string" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" >0</d2>
    7. </GetFieldOfViewResponse>
    8. </SOAP-ENV:Body>
    9. </SOAP-ENV:Envelope>
    To copy to clipboard, switch view to plain text mode 
    I got the method name, but with no data at all.

    Here are my codes:
    Qt Code:
    1. void MainWindow::getResponse()
    2. {
    3. const QtSoapMessage &message = http.getResponse();
    4. if (message.isFault()) {
    5. return;
    6. }
    7.  
    8. const QtSoapType &response= message.returnValue();
    9. qDebug("Data are: %s)",
    10. response["HRESULT"].value().toString().toLatin1().constData(),
    11. response["d1"].value().toString().toLatin1().constData(),
    12. response["d2"].value().toString().toLatin1().constData());
    13. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 3
    Last Post: 4th December 2009, 08:52
  2. Error on QtSoapMessage::toXmlString
    By noo in forum Qt Programming
    Replies: 0
    Last Post: 27th October 2009, 09: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.