Results 1 to 11 of 11

Thread: sending soap request using QNetworkAccessManager question

  1. #1
    Join Date
    Mar 2010
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default sending soap request using QNetworkAccessManager question

    I recently had to edit my program to send my soap message that is already in a qdomdocument, so I used QNetworkAccess Manager to send it, but is there anyway to actually send it without using signals and slots? Because for QNetworkAccessManager, the connect method uses signal and slots, is there a way to go around it and actually send the soap request without using signal and slot?

    Here's a fragment of my code

    Qt Code:
    1. connect(&manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(finished(QNetworkReply *)) );
    2.  
    3. QNetworkAccessManager manager;
    4. QString data = document.toString();
    5.  
    6. QNetworkRequest networkReq;
    7. networkReq.setHeader(QNetworkRequest::ContentTypeHeader, QLatin1String("text/xml;charset=utf-8"));
    8. networkReq.setRawHeader("SOAPAction", "myurl");
    9. networkReq.setUrl(url);
    10.  
    11. QNetworkReply *r = manager.post(networkReq, data.toAscii());
    To copy to clipboard, switch view to plain text mode 

    Currently this is what Im doing, but I would prefer to NOT use signal and slots, before this there was QHttp but unfortunately it has been removed and replaced with QNetworkAccessManager, so can anyone advice me how I could change my codes to not use signal and slots?

    Thanks

  2. #2
    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: sending soap request using QNetworkAccessManager question

    What do you mean by "without signals and slots"? QHttp was not removed, by the way, it's just obsolete. How did you use QHttp "without signals and slots"?

  3. #3
    Join Date
    Mar 2010
    Location
    Capelle aan den IJssel, Netherlands
    Posts
    24
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: sending soap request using QNetworkAccessManager question

    In short, you can't!
    I have had some trouble with QNetworkAccessManager before.

    It has nice functionality, but if you want anything specific, it does not let you
    My problem was, that you cannot receive data in parts, which i needed (so when you do a http request and flush data every now and then, it will not trigger anything).

  4. #4
    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: sending soap request using QNetworkAccessManager question

    Quote Originally Posted by _Stefan View Post
    In short, you can't!
    Oh, really? Are you sure?

    My problem was, that you cannot receive data in parts, which i needed (so when you do a http request and flush data every now and then, it will not trigger anything).
    Hmm... How did you try to read the data? Upon the readyRead() signal?

  5. #5
    Join Date
    Mar 2010
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: sending soap request using QNetworkAccessManager question

    Such as sending the request and recieving it without the use of SIGNAL and SLOT.

    For instance just using a code to set the host and then send the domdoc as a SOAP request to the server. I dont want to use SIGNAL and SLOT as Im creating a dll which will be given to my clients and they may not have Qt installed..

  6. #6
    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: sending soap request using QNetworkAccessManager question

    So.... why are you posting this in a Qt forum if you don't want to use Qt?

  7. #7
    Join Date
    Mar 2010
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: sending soap request using QNetworkAccessManager question

    Please do not misunderstand, I am using Qt but I just do not wish to use the SIGNAL and SLOT, hence I'm asking whether there is a way to send my domdocument as a SOAP request without using SIGNAL and SLOT

  8. #8
    Join Date
    Aug 2009
    Location
    Greece, Chania
    Posts
    63
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: sending soap request using QNetworkAccessManager question

    Quote Originally Posted by babymonsta View Post
    Please do not misunderstand, I am using Qt but I just do not wish to use the SIGNAL and SLOT, hence I'm asking whether there is a way to send my domdocument as a SOAP request without using SIGNAL and SLOT
    There's a logical bug in the above sentence, you are using Qt for your projects and you don't want signal/slots because the client may not have Qt installed?

    There may probably be a way to do it without signal/slots, I guess you need to write some functions using the event mechanism of Qt.

    Anyway, bellow it's not an answer to your question but just pointing out an alternative to QNetworkAccessManager, you may want to check this QtSOAP.

  9. #9
    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: sending soap request using QNetworkAccessManager question

    QtSoap uses QHttp internally and operates on signals and slots as well. In its current form it doesn't let you send more than one message at once as well, so it's kind of a limitation. I modified it some time ago to use QNetworkAccessManager as the transport layer but it requires Qt and signals and slots

  10. #10
    Join Date
    Mar 2010
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: sending soap request using QNetworkAccessManager question

    Currently Im still using the signal and slot method from QNetworkAccessManager connect() method but is there really no way to just get the QNetworkReply without using the signal and slot? Because I tried to just use the manager to post the data and I didnt use the connect() method, my networkreply came back empty, so Im thinking maybe because the reply was retrieved at the wrong time (hence why signal and slot is very good at this part - to be able to get the response when a signal is emitted), but in short there really is no method to not have to use signal and slots?

  11. #11
    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: sending soap request using QNetworkAccessManager question

    But what is wrong with signals and slots? You can make your code pseudo-synchronous with QEventLoop if asynchronous call is a problem.

Similar Threads

  1. QNetworkAccessManager question
    By _Stefan in forum Qt Programming
    Replies: 1
    Last Post: 5th March 2010, 12:21
  2. QNetworkAccessManager get request causing QSslSocket errors
    By Runtime Technologies in forum Qt Programming
    Replies: 5
    Last Post: 29th July 2009, 22:57
  3. soap and web services
    By rmagro in forum Qt Programming
    Replies: 13
    Last Post: 24th November 2008, 11:34
  4. Trouble sending request with QHttp
    By WinchellChung in forum Newbie
    Replies: 2
    Last Post: 27th June 2007, 18:50
  5. Qhttp::request(...) method and GET request
    By mikhailt in forum Qt Programming
    Replies: 4
    Last Post: 15th September 2006, 12:26

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.