Results 1 to 4 of 4

Thread: Connecting to an FTP server and calling web service files?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2020
    Location
    Michigan
    Posts
    8
    Qt products
    Qt5
    Platforms
    MacOS X Windows Android
    Thanks
    1

    Default Re: Connecting to an FTP server and calling web service files?

    Hi Chris, thank you for your response - I appreciate it. I am working with a console application versus a GUI app and the slots / signals still confuse me a bit. I re-wrote my ftp a bit but I am not sure all of this is necessary compared to my initial post. I assume the way to do the signal and slots is the QObject::connect lines? For the web service PHP, I assume this should go into the main.cpp file versus placing it on the actual page even though I want it to send the information to the file on a button click?

    Qt Code:
    1. QNetworkAccessManager netMan;
    2. QNetworkReply* const repl = netMan.get(QNetworkRequest(QUrl::fromUserInput("ftp url direct to file")));
    3. QObject::connect(repl,&QNetworkReply::readyRead,[repl]()->void{qDebug().noquote() << repl->readAll();});
    4. QObject::connect(repl,QOverload<QNetworkReply::NetworkError>::of(&QNetworkReply::error),[repl]()->void{qDebug() << "Error: " + repl->errorString();});
    5. QObject::connect(repl,&QNetworkReply::finished,repl,&QNetworkReply::deleteLater);
    6. QObject::connect(&netMan,&QNetworkAccessManager::authenticationRequired,repl,[repl](QNetworkReply *reply, QAuthenticator *authenticator)->void{
    7. if(reply!=repl)
    8. return;
    9. authenticator->setUser(" ");
    10. authenticator->setPassword(" ");
    11. });
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Connecting to an FTP server and calling web service files?

    Quote Originally Posted by luckachi View Post
    Hi Chris, thank you for your response - I appreciate it. I am working with a console application versus a GUI app and the slots / signals still confuse me a bit. I re-wrote my ftp a bit but I am not sure all of this is necessary compared to my initial post. I assume the way to do the signal and slots is the QObject::connect lines?
    The connect() calls are part of the signal/slot mechanism. The other part is a running event loop that delivers emitted signals to listening slots. You need these components on the client side regardless of GUI/console choice. On a quick inspection your code snippet looks OK for the first part. For a beginner it may be easier to follow if you split the slots into standalone functions because you can then trace execution more obviously with your debugger. You need to be careful about the scope of the netMan object: it needs to exist to process requests/responses.

    I assume you have read the docs
    For the web service PHP, I assume this should go into the main.cpp file versus placing it on the actual page even though I want it to send the information to the file on a button click?
    All the client code belongs in the client application. The server providing your service is just another place you communicate with, and it does not matter how that server implements the service (C++, PHP, Java, or COBOL ). If you are using a mechanism like SOAP then you have an agreed way to express requests to the server and receive responses from it. The SOAP requests and responses are the payload of (usually) an HTTP request and response. You can see an example pair for a simple service: https://www.dataaccess.com/webservic...=NumberToWords

    I am not sure where a button click comes from in a console application. However, the process of constructing and sending a SOAP request is the same regardless of the event (button click, timer, whatever...).

Similar Threads

  1. Connecting to MySQL Server using SSL (AWS RDS)
    By sathhin in forum Qt Programming
    Replies: 0
    Last Post: 8th June 2016, 14:15
  2. Problems connecting to SQL Server 2005 from Windows 7
    By redBeard in forum Qt Programming
    Replies: 1
    Last Post: 3rd May 2012, 00:18
  3. QSslSocket - problem with connecting to the server
    By kremuwa in forum Qt Programming
    Replies: 9
    Last Post: 26th August 2010, 15:40
  4. connecting 2 dylib files
    By munna in forum Installation and Deployment
    Replies: 1
    Last Post: 22nd November 2006, 13:52

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.